for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace RedMoon\TinkerServer;
class Connection
{
protected $socket;
protected $host;
public function __construct($host)
$this->host = $host;
}
public function write(array $namedParameters): bool
if (! $this->socket = $this->socket ?: $this->createSocket()) {
return false;
set_error_handler([self::class, 'nullErrorHandler']);
try {
$encodedPayload = base64_encode(serialize($namedParameters))."\n";
if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) {
return true;
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
fclose($this->socket);
$this->socket = $this->createSocket();
} finally {
restore_error_handler();
private static function nullErrorHandler($t, $m)
$t
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$m
// no-op
private function createSocket()
return stream_socket_client($this->host, $errno, $errstr, 3, STREAM_CLIENT_CONNECT);