@@ -35,7 +35,7 @@ |
||
| 35 | 35 | parent::__construct($socket, 0); |
| 36 | 36 | if ($remoteAddress) { |
| 37 | 37 | $components = parse_url($remoteAddress); |
| 38 | - $this->remoteAddress = $components['host'] . ':' . $components['port']; |
|
| 38 | + $this->remoteAddress = $components['host'].':'.$components['port']; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -211,9 +211,9 @@ |
||
| 211 | 211 | private function onEvent(LeEvent $event, $eventFlags) |
| 212 | 212 | { |
| 213 | 213 | $map = [ |
| 214 | - LeCallbackInterface::EVENT_READ => [ EV_READ, RequestDescriptor::RDS_READ ], |
|
| 215 | - LeCallbackInterface::EVENT_WRITE => [ EV_WRITE, RequestDescriptor::RDS_WRITE ], |
|
| 216 | - LeCallbackInterface::EVENT_TIMEOUT => [ EV_TIMEOUT, 0 ], |
|
| 214 | + LeCallbackInterface::EVENT_READ => [EV_READ, RequestDescriptor::RDS_READ], |
|
| 215 | + LeCallbackInterface::EVENT_WRITE => [EV_WRITE, RequestDescriptor::RDS_WRITE], |
|
| 216 | + LeCallbackInterface::EVENT_TIMEOUT => [EV_TIMEOUT, 0], |
|
| 217 | 217 | ]; |
| 218 | 218 | |
| 219 | 219 | $descriptor = $event->getRequestDescriptor(); |
@@ -108,8 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | private function calculateAttemptsCount($seconds, $usec) |
| 110 | 110 | { |
| 111 | - $result = $seconds !== null ? ceil(($seconds * 1E6 + $usec) / self::ATTEMPT_DELAY) : |
|
| 112 | - self::ATTEMPT_COUNT_FOR_INFINITE_TIMEOUT; |
|
| 111 | + $result = $seconds !== null ? ceil(($seconds * 1E6 + $usec) / self::ATTEMPT_DELAY) : self::ATTEMPT_COUNT_FOR_INFINITE_TIMEOUT; |
|
| 113 | 112 | if ($result < self::ATTEMPT_COUNT_FOR_INFINITE_TIMEOUT) { |
| 114 | 113 | $result = self::ATTEMPT_COUNT_FOR_INFINITE_TIMEOUT; |
| 115 | 114 | } |
@@ -328,8 +327,8 @@ discard block |
||
| 328 | 327 | */ |
| 329 | 328 | public function removeAllSocketOperations(StreamResourceInterface $streamResource) |
| 330 | 329 | { |
| 331 | - $opList = [ OperationInterface::OPERATION_READ, |
|
| 332 | - OperationInterface::OPERATION_WRITE ]; |
|
| 330 | + $opList = [OperationInterface::OPERATION_READ, |
|
| 331 | + OperationInterface::OPERATION_WRITE]; |
|
| 333 | 332 | |
| 334 | 333 | foreach ($opList as $op) { |
| 335 | 334 | $this->removeSocketOperation($streamResource, $op); |
@@ -52,18 +52,17 @@ discard block |
||
| 52 | 52 | if ($test !== 0) { |
| 53 | 53 | throw new SendDataException( |
| 54 | 54 | $this->socket, |
| 55 | - trim('Failed to send data. ' . $this->getLastPhpErrorMessage()) |
|
| 55 | + trim('Failed to send data. '.$this->getLastPhpErrorMessage()) |
|
| 56 | 56 | ); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $written = $isOutOfBand ? |
| 60 | - $this->writeOobData($resource, $data) : |
|
| 61 | - fwrite($resource, $data, strlen($data)); |
|
| 60 | + $this->writeOobData($resource, $data) : fwrite($resource, $data, strlen($data)); |
|
| 62 | 61 | |
| 63 | 62 | if ($written === false) { |
| 64 | 63 | throw new SendDataException( |
| 65 | 64 | $this->socket, |
| 66 | - trim('Failed to send data. ' . $this->getLastPhpErrorMessage()) |
|
| 65 | + trim('Failed to send data. '.$this->getLastPhpErrorMessage()) |
|
| 67 | 66 | ); |
| 68 | 67 | } |
| 69 | 68 | |
@@ -136,7 +135,7 @@ discard block |
||
| 136 | 135 | if ($data === false) { |
| 137 | 136 | throw new RecvDataException( |
| 138 | 137 | $this->socket, |
| 139 | - trim('Failed to read data. ' . $this->getLastPhpErrorMessage()) |
|
| 138 | + trim('Failed to read data. '.$this->getLastPhpErrorMessage()) |
|
| 140 | 139 | ); |
| 141 | 140 | } |
| 142 | 141 | |
@@ -190,9 +189,8 @@ discard block |
||
| 190 | 189 | private function resolveReadAttempts(array $context, $currentAttempts) |
| 191 | 190 | { |
| 192 | 191 | return ($context['countCycles'] === 1 && empty($context['dataBeforeIo'])) || |
| 193 | - ($context['countCycles'] > 1 && $context['isStreamDataEmpty']) ? |
|
| 194 | - $currentAttempts - 1 : |
|
| 195 | - self::READ_ATTEMPTS; |
|
| 192 | + ($context['countCycles'] > 1 && $context['isStreamDataEmpty']) ? |
|
| 193 | + $currentAttempts - 1 : self::READ_ATTEMPTS; |
|
| 196 | 194 | |
| 197 | 195 | } |
| 198 | 196 | |
@@ -213,7 +211,7 @@ discard block |
||
| 213 | 211 | if ($written < 0) { |
| 214 | 212 | throw new SendDataException( |
| 215 | 213 | $this->socket, |
| 216 | - trim('Failed to send data. ' . $this->getLastPhpErrorMessage()) |
|
| 214 | + trim('Failed to send data. '.$this->getLastPhpErrorMessage()) |
|
| 217 | 215 | ); |
| 218 | 216 | } |
| 219 | 217 | |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | $lastError = error_get_last(); |
| 54 | 54 | if ($lastError) { |
| 55 | 55 | $phpMessage = explode(':', $lastError['message'], 2); |
| 56 | - $phpMessage = trim(trim(end($phpMessage)), '.') . '.'; |
|
| 56 | + $phpMessage = trim(trim(end($phpMessage)), '.').'.'; |
|
| 57 | 57 | return $phpMessage; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -174,8 +174,7 @@ discard block |
||
| 174 | 174 | '[#%s, %s]', |
| 175 | 175 | preg_replace('/Resource id #(\d+)/i', '$1', (string) $this->resource), |
| 176 | 176 | $this->remoteAddress |
| 177 | - ) : |
|
| 178 | - '[closed socket]'; |
|
| 177 | + ) : '[closed socket]'; |
|
| 179 | 178 | } |
| 180 | 179 | |
| 181 | 180 | /** |
@@ -218,7 +217,7 @@ discard block |
||
| 218 | 217 | 'unix' => self::SOCKET_TYPE_UNIX, |
| 219 | 218 | ]; |
| 220 | 219 | |
| 221 | - $regexp = '#^('. implode('|', array_keys($map)) . ')_socket$#'; |
|
| 220 | + $regexp = '#^('.implode('|', array_keys($map)).')_socket$#'; |
|
| 222 | 221 | foreach ($parts as $part) { |
| 223 | 222 | if (preg_match($regexp, $part, $pockets)) { |
| 224 | 223 | return $map[$pockets[1]]; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | protected function terminateRequest() |
| 118 | 118 | { |
| 119 | 119 | parent::terminateRequest(); |
| 120 | - $this->base = null; |
|
| 120 | + $this->base = null; |
|
| 121 | 121 | |
| 122 | 122 | $this->connectStage = null; |
| 123 | 123 | $this->ioStage = null; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | case LeCallbackInterface::EVENT_READ: |
| 182 | 182 | // fall down |
| 183 | 183 | case LeCallbackInterface::EVENT_WRITE: |
| 184 | - $result = $this->ioStage->processStage([ $requestDescriptor ]); |
|
| 184 | + $result = $this->ioStage->processStage([$requestDescriptor]); |
|
| 185 | 185 | $doResetEvent = empty($result); |
| 186 | 186 | |
| 187 | 187 | break; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $event = new ReadEvent( |
| 114 | 114 | $executor, |
| 115 | 115 | $socket, |
| 116 | - $meta[ RequestExecutorInterface::META_USER_CONTEXT ], |
|
| 116 | + $meta[RequestExecutorInterface::META_USER_CONTEXT], |
|
| 117 | 117 | $frame, |
| 118 | 118 | true |
| 119 | 119 | ); |
@@ -140,8 +140,7 @@ discard block |
||
| 140 | 140 | if (!$counter) { |
| 141 | 141 | $meta = $descriptor->getMetadata(); |
| 142 | 142 | $counter = new SpeedRateCounter($minRate, $duration); |
| 143 | - $time = $meta[RequestExecutorInterface::META_LAST_IO_START_TIME] ?: |
|
| 144 | - $meta[RequestExecutorInterface::META_CONNECTION_FINISH_TIME]; |
|
| 143 | + $time = $meta[RequestExecutorInterface::META_LAST_IO_START_TIME] ?: $meta[RequestExecutorInterface::META_CONNECTION_FINISH_TIME]; |
|
| 145 | 144 | $counter->advance($time, 0); |
| 146 | 145 | $descriptor->registerCounter($name, $counter); |
| 147 | 146 | } |
@@ -165,16 +164,16 @@ discard block |
||
| 165 | 164 | $map = [ |
| 166 | 165 | RequestDescriptor::COUNTER_RECV_MIN_RATE => [ |
| 167 | 166 | 'resetCounter' => RequestDescriptor::COUNTER_SEND_MIN_RATE, |
| 168 | - 'minSpeed' => $meta[ RequestExecutorInterface::META_MIN_RECEIVE_SPEED ], |
|
| 169 | - 'duration' => $meta[ RequestExecutorInterface::META_MIN_RECEIVE_SPEED_DURATION ], |
|
| 167 | + 'minSpeed' => $meta[RequestExecutorInterface::META_MIN_RECEIVE_SPEED], |
|
| 168 | + 'duration' => $meta[RequestExecutorInterface::META_MIN_RECEIVE_SPEED_DURATION], |
|
| 170 | 169 | 'bytesCounter' => RequestExecutorInterface::META_BYTES_RECEIVED, |
| 171 | 170 | 'speedCounter' => RequestExecutorInterface::META_RECEIVE_SPEED, |
| 172 | 171 | 'exception' => ['AsyncSockets\Exception\SlowSpeedTransferException', 'tooSlowDataReceiving'], |
| 173 | 172 | ], |
| 174 | 173 | RequestDescriptor::COUNTER_SEND_MIN_RATE => [ |
| 175 | 174 | 'resetCounter' => RequestDescriptor::COUNTER_RECV_MIN_RATE, |
| 176 | - 'minSpeed' => $meta[ RequestExecutorInterface::META_MIN_SEND_SPEED ], |
|
| 177 | - 'duration' => $meta[ RequestExecutorInterface::META_MIN_SEND_SPEED_DURATION ], |
|
| 175 | + 'minSpeed' => $meta[RequestExecutorInterface::META_MIN_SEND_SPEED], |
|
| 176 | + 'duration' => $meta[RequestExecutorInterface::META_MIN_SEND_SPEED_DURATION], |
|
| 178 | 177 | 'bytesCounter' => RequestExecutorInterface::META_BYTES_SENT, |
| 179 | 178 | 'speedCounter' => RequestExecutorInterface::META_SEND_SPEED, |
| 180 | 179 | 'exception' => ['AsyncSockets\Exception\SlowSpeedTransferException', 'tooSlowDataSending'], |
@@ -182,7 +181,7 @@ discard block |
||
| 182 | 181 | ]; |
| 183 | 182 | |
| 184 | 183 | if (!isset($map[$name])) { |
| 185 | - throw new \LogicException('Can not process counter ' . $name . ' in transfer operation'); |
|
| 184 | + throw new \LogicException('Can not process counter '.$name.' in transfer operation'); |
|
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | $info = $map[$name]; |