Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Connection/AsyncTcpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function __construct($remote_address, array $context_option = [])
$this->_remoteHost = $address_info['host'];
$this->_remotePort = $address_info['port'];
$this->_remoteURI = "{$address_info['path']}{$address_info['query']}";
$scheme = isset($address_info['scheme']) ? $address_info['scheme'] : 'tcp';
$scheme = $address_info['scheme'] ?? 'tcp';
$this->_remoteAddress = 'unix' === strtolower($scheme)
? substr($remote_address, strpos($remote_address, '/') + 2)
: $this->_remoteHost . ':' . $this->_remotePort;
Expand Down
14 changes: 7 additions & 7 deletions src/Protocols/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function get($name = null, $default = null)
if (null === $name) {
return $this->_data['get'];
}
return isset($this->_data['get'][$name]) ? $this->_data['get'][$name] : $default;
return $this->_data['get'][$name] ?? $default;
}

/**
Expand All @@ -116,7 +116,7 @@ public function post($name = null, $default = null)
if (null === $name) {
return $this->_data['post'];
}
return isset($this->_data['post'][$name]) ? $this->_data['post'][$name] : $default;
return $this->_data['post'][$name] ?? $default;
}

/**
Expand All @@ -135,7 +135,7 @@ public function header($name = null, $default = null)
return $this->_data['headers'];
}
$name = \strtolower($name);
return isset($this->_data['headers'][$name]) ? $this->_data['headers'][$name] : $default;
return $this->_data['headers'][$name] ?? $default;
}

/**
Expand All @@ -154,7 +154,7 @@ public function cookie($name = null, $default = null)
if ($name === null) {
return $this->_data['cookie'];
}
return isset($this->_data['cookie'][$name]) ? $this->_data['cookie'][$name] : $default;
return $this->_data['cookie'][$name] ?? $default;
}

/**
Expand All @@ -171,7 +171,7 @@ public function file($name = null)
if (null === $name) {
return $this->_data['files'];
}
return isset($this->_data['files'][$name]) ? $this->_data['files'][$name] : null;
return $this->_data['files'][$name] ?? null;
}

/**
Expand Down Expand Up @@ -372,7 +372,7 @@ protected function parseHeadFirstLine()
$first_line = \strstr($this->_buffer, "\r\n", true);
$tmp = \explode(' ', $first_line, 3);
$this->_data['method'] = $tmp[0];
$this->_data['uri'] = isset($tmp[1]) ? $tmp[1] : '/';
$this->_data['uri'] = $tmp[1] ?? '/';
}

/**
Expand Down Expand Up @@ -637,7 +637,7 @@ public function __set($name, $value)
*/
public function __get($name)
{
return isset($this->properties[$name]) ? $this->properties[$name] : null;
return $this->properties[$name] ?? null;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/Protocols/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,8 @@ public function withoutHeader($name)
*/
public function getHeader($name)
{
if (!isset($this->_header[$name])) {
return null;
}
return $this->_header[$name];

return $this->_header[$name] ?? null;
}

/**
Expand Down Expand Up @@ -375,8 +373,8 @@ protected function createHeadForFile($file_info)
}

$file_info = \pathinfo($file);
$extension = isset($file_info['extension']) ? $file_info['extension'] : '';
$base_name = isset($file_info['basename']) ? $file_info['basename'] : 'unknown';
$extension = $file_info['extension'] ?? '';
$base_name = $file_info['basename'] ?? 'unknown';
if (!isset($headers['Content-Type'])) {
if (isset(self::$_mimeTypeMap[$extension])) {
$head .= "Content-Type: " . self::$_mimeTypeMap[$extension] . "\r\n";
Expand Down
2 changes: 1 addition & 1 deletion src/Protocols/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getId()
*/
public function get($name, $default = null)
{
return isset($this->_data[$name]) ? $this->_data[$name] : $default;
return $this->_data[$name] ?? $default;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Protocols/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function input($buffer, ConnectionInterface $connection)
if ($recv_len >= $current_frame_length) {
$ping_data = static::decode(\substr($buffer, 0, $current_frame_length), $connection);
$connection->consumeRecvBuffer($current_frame_length);
$tmp_connection_type = isset($connection->websocketType) ? $connection->websocketType : static::BINARY_TYPE_BLOB;
$tmp_connection_type = $connection->websocketType ?? static::BINARY_TYPE_BLOB;
$connection->websocketType = "\x8a";
$ping_cb = $connection->onWebSocketPing ?? $connection->worker->onWebSocketPing ?? false;
if ($ping_cb) {
Expand All @@ -172,7 +172,7 @@ public static function input($buffer, ConnectionInterface $connection)
if ($recv_len >= $current_frame_length) {
$pong_data = static::decode(\substr($buffer, 0, $current_frame_length), $connection);
$connection->consumeRecvBuffer($current_frame_length);
$tmp_connection_type = isset($connection->websocketType) ? $connection->websocketType : static::BINARY_TYPE_BLOB;
$tmp_connection_type = $connection->websocketType ?? static::BINARY_TYPE_BLOB;
$connection->websocketType = "\x8a";
// Try to emit onWebSocketPong callback.
$pong_cb = $connection->onWebSocketPong ?? $connection->worker->onWebSocketPong ?? false;
Expand Down
3 changes: 1 addition & 2 deletions src/Protocols/Ws.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ public static function sendHandshake(TcpConnection $connection)
$host = $port === 80 ? $connection->getRemoteHost() : $connection->getRemoteHost() . ':' . $port;
// Handshake header.
$connection->websocketSecKey = \base64_encode(random_bytes(16));
$user_header = isset($connection->headers) ? $connection->headers :
(isset($connection->wsHttpHeader) ? $connection->wsHttpHeader : null);
$user_header = $connection->headers ?? $connection->wsHttpHeader ?? null;
$user_header_str = '';
if (!empty($user_header)) {
if (\is_array($user_header)) {
Expand Down