Skip to content

Commit eaa76e6

Browse files
committed
qa: minor style changes and refactors
- multi-line ternaries should have each element start on a line of its own. - pass the connection timeout value to `setupSocket()` (in case the constant is not defined) - consistency in annotation spacing and definition Signed-off-by: Matthew Weier O'Phinney <[email protected]>
1 parent 9c02e80 commit eaa76e6

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/Protocol/Imap.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
namespace Laminas\Mail\Protocol;
1010

11-
use Laminas\Stdlib\ErrorHandler;
12-
1311
class Imap
1412
{
1513
use ProtocolTrait;
@@ -84,7 +82,7 @@ public function connect($host, $port = null, $ssl = false)
8482
}
8583
}
8684

87-
$this->setupSocket($host, $port);
85+
$this->setupSocket($host, $port, self::TIMEOUT_CONNECTION);
8886

8987
if (! $this->assumedNextLine('* OK')) {
9088
throw new Exception\RuntimeException('host doesn\'t allow connection');

src/Protocol/Pop3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function connect($host, $port = null, $ssl = false)
8989
}
9090
}
9191

92-
$this->setupSocket($host, $port);
92+
$this->setupSocket($host, $port, self::TIMEOUT_CONNECTION);
9393

9494
$welcome = $this->readResponse();
9595

src/Protocol/ProtocolTrait.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Laminas\Mail\Protocol;
1010

11+
use Laminas\Stdlib\ErrorHandler;
12+
1113
/**
1214
* https://bugs.php.net/bug.php?id=69195
1315
*/
@@ -37,9 +39,8 @@ public function getCryptoMethod()
3739
/**
3840
* Do not validate SSL certificate
3941
*
40-
* @param bool $novalidatecert Set to true to disable certificate validation
41-
*
42-
* @return Imap|Pop3
42+
* @param bool $novalidatecert Set to true to disable certificate validation
43+
* @return self
4344
*/
4445
public function setNoValidateCert(bool $novalidatecert)
4546
{
@@ -70,25 +71,27 @@ private function prepareSocketOptions()
7071
'verify_peer_name' => false,
7172
'verify_peer' => false,
7273
]
73-
] : [];
74+
]
75+
: [];
7476
}
7577

7678
/**
7779
* Setup connection socket
7880
*
7981
* @param string $host hostname or IP address of IMAP server
8082
* @param int|null $port of IMAP server, default is 143 (993 for ssl)
81-
*
83+
* @param int $timeout timeout in seconds for initiating session
8284
* @return void
85+
* @throws Exception\RuntimeException If unable to connect to host.
8386
*/
84-
protected function setupSocket($host, $port)
87+
protected function setupSocket($host, $port, $timeout)
8588
{
8689
ErrorHandler::start();
8790
$this->socket = stream_socket_client(
8891
$host . ":" . $port,
8992
$errno,
9093
$errstr,
91-
self::TIMEOUT_CONNECTION,
94+
$timeout,
9295
STREAM_CLIENT_CONNECT,
9396
stream_context_create($this->prepareSocketOptions())
9497
);

0 commit comments

Comments
 (0)