Skip to content

Commit 0af69c9

Browse files
author
Михаил Красильников
committed
Fix code style with PHP-CS-Fixer
1 parent e982c56 commit 0af69c9

16 files changed

+109
-96
lines changed

src/Client.php

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Http\Client\Curl;
34

45
use Http\Client\Exception;
@@ -13,61 +14,61 @@
1314
use Psr\Http\Message\ResponseInterface;
1415

1516
/**
16-
* PSR-7 compatible cURL based HTTP client
17+
* PSR-7 compatible cURL based HTTP client.
1718
*
1819
* @license http://opensource.org/licenses/MIT MIT
19-
*
2020
* @author Михаил Красильников <m.krasilnikov@yandex.ru>
2121
* @author Blake Williams <github@shabbyrobe.org>
2222
*
2323
* @api
24+
*
2425
* @since 1.0
2526
*/
2627
class Client implements HttpClient, HttpAsyncClient
2728
{
2829
/**
29-
* cURL options
30+
* cURL options.
3031
*
3132
* @var array
3233
*/
3334
private $options;
3435

3536
/**
36-
* PSR-7 message factory
37+
* PSR-7 message factory.
3738
*
3839
* @var MessageFactory
3940
*/
4041
private $messageFactory;
4142

4243
/**
43-
* PSR-7 stream factory
44+
* PSR-7 stream factory.
4445
*
4546
* @var StreamFactory
4647
*/
4748
private $streamFactory;
4849

4950
/**
50-
* cURL synchronous requests handle
51+
* cURL synchronous requests handle.
5152
*
5253
* @var resource|null
5354
*/
5455
private $handle = null;
5556

5657
/**
57-
* Simultaneous requests runner
58+
* Simultaneous requests runner.
5859
*
5960
* @var MultiRunner|null
6061
*/
6162
private $multiRunner = null;
6263

6364
/**
64-
* Create new client
65+
* Create new client.
6566
*
6667
* @param MessageFactory|null $messageFactory HTTP Message factory
6768
* @param StreamFactory|null $streamFactory HTTP Stream factory
6869
* @param array $options cURL options (see http://php.net/curl_setopt)
6970
*
70-
* @throws \Http\Discovery\Exception\NotFoundException If factory discovery failed.
71+
* @throws \Http\Discovery\Exception\NotFoundException If factory discovery failed
7172
*
7273
* @since 1.0
7374
*/
@@ -82,7 +83,7 @@ public function __construct(
8283
}
8384

8485
/**
85-
* Release resources if still active
86+
* Release resources if still active.
8687
*/
8788
public function __destruct()
8889
{
@@ -98,13 +99,13 @@ public function __destruct()
9899
*
99100
* @return ResponseInterface
100101
*
101-
* @throws \Http\Client\Exception\NetworkException In case of network problems.
102-
* @throws \Http\Client\Exception\RequestException On invalid request.
103-
* @throws \InvalidArgumentException For invalid header names or values.
104-
* @throws \RuntimeException If creating the body stream fails.
102+
* @throws \Http\Client\Exception\NetworkException In case of network problems
103+
* @throws \Http\Client\Exception\RequestException On invalid request
104+
* @throws \InvalidArgumentException For invalid header names or values
105+
* @throws \RuntimeException If creating the body stream fails
105106
*
106-
* @since 1.6 \UnexpectedValueException replaced with RequestException.
107-
* @since 1.6 Throw NetworkException on network errors.
107+
* @since 1.6 \UnexpectedValueException replaced with RequestException
108+
* @since 1.6 Throw NetworkException on network errors
108109
* @since 1.0
109110
*/
110111
public function sendRequest(RequestInterface $request)
@@ -149,11 +150,11 @@ public function sendRequest(RequestInterface $request)
149150
*
150151
* @return Promise
151152
*
152-
* @throws \Http\Client\Exception\RequestException On invalid request.
153-
* @throws \InvalidArgumentException For invalid header names or values.
154-
* @throws \RuntimeException If creating the body stream fails.
153+
* @throws \Http\Client\Exception\RequestException On invalid request
154+
* @throws \InvalidArgumentException For invalid header names or values
155+
* @throws \RuntimeException If creating the body stream fails
155156
*
156-
* @since 1.6 \UnexpectedValueException replaced with RequestException.
157+
* @since 1.6 \UnexpectedValueException replaced with RequestException
157158
* @since 1.0
158159
*/
159160
public function sendAsyncRequest(RequestInterface $request)
@@ -175,14 +176,14 @@ public function sendAsyncRequest(RequestInterface $request)
175176
}
176177

177178
/**
178-
* Generates cURL options
179+
* Generates cURL options.
179180
*
180181
* @param RequestInterface $request
181182
* @param ResponseBuilder $responseBuilder
182183
*
183-
* @throws \Http\Client\Exception\RequestException On invalid request.
184-
* @throws \InvalidArgumentException For invalid header names or values.
185-
* @throws \RuntimeException if can not read body
184+
* @throws \Http\Client\Exception\RequestException On invalid request
185+
* @throws \InvalidArgumentException For invalid header names or values
186+
* @throws \RuntimeException if can not read body
186187
*
187188
* @return array
188189
*/
@@ -231,7 +232,7 @@ private function createCurlOptions(RequestInterface $request, ResponseBuilder $r
231232
}
232233

233234
/**
234-
* Return cURL constant for specified HTTP version
235+
* Return cURL constant for specified HTTP version.
235236
*
236237
* @param string $requestVersion
237238
*
@@ -311,7 +312,7 @@ private function addRequestBodyOptions(RequestInterface $request, array $options
311312
}
312313

313314
/**
314-
* Create headers array for CURLOPT_HTTPHEADER
315+
* Create headers array for CURLOPT_HTTPHEADER.
315316
*
316317
* @param RequestInterface $request
317318
* @param array $options cURL options
@@ -338,7 +339,7 @@ private function createHeaders(RequestInterface $request, array $options)
338339
}
339340
}
340341
foreach ($values as $value) {
341-
$curlHeaders[] = $name . ': ' . $value;
342+
$curlHeaders[] = $name.': '.$value;
342343
}
343344
}
344345
/*
@@ -351,11 +352,11 @@ private function createHeaders(RequestInterface $request, array $options)
351352
}
352353

353354
/**
354-
* Create new ResponseBuilder instance
355+
* Create new ResponseBuilder instance.
355356
*
356357
* @return ResponseBuilder
357358
*
358-
* @throws \RuntimeException If creating the stream from $body fails.
359+
* @throws \RuntimeException If creating the stream from $body fails
359360
*/
360361
private function createResponseBuilder()
361362
{

src/CurlPromise.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Http\Client\Curl;
34

45
use Http\Promise\Promise;
@@ -12,20 +13,19 @@
1213
* Reason is replaced by an object where its class implement a Http\Client\Exception.
1314
*
1415
* @license http://opensource.org/licenses/MIT MIT
15-
*
1616
* @author Михаил Красильников <m.krasilnikov@yandex.ru>
1717
*/
1818
class CurlPromise implements Promise
1919
{
2020
/**
21-
* Shared promise core
21+
* Shared promise core.
2222
*
2323
* @var PromiseCore
2424
*/
2525
private $core;
2626

2727
/**
28-
* Requests runner
28+
* Requests runner.
2929
*
3030
* @var MultiRunner
3131
*/
@@ -49,13 +49,13 @@ public function __construct(PromiseCore $core, MultiRunner $runner)
4949
* If you do not care about one of the cases, you can set the corresponding callable to null
5050
* The callback will be called when the response or exception arrived and never more than once.
5151
*
52-
* @param callable $onFulfilled Called when a response will be available.
52+
* @param callable $onFulfilled Called when a response will be available
5353
* @param callable $onRejected Called when an error happens.
5454
*
55-
* You must always return the Response in the interface or throw an Exception.
55+
* You must always return the Response in the interface or throw an Exception
5656
*
5757
* @return Promise Always returns a new promise which is resolved with value of the executed
58-
* callback (onFulfilled / onRejected).
58+
* callback (onFulfilled / onRejected)
5959
*/
6060
public function then(callable $onFulfilled = null, callable $onRejected = null)
6161
{
@@ -90,7 +90,7 @@ public function getState()
9090
*
9191
* @return \Psr\Http\Message\ResponseInterface|null Resolved value, null if $unwrap is set to false
9292
*
93-
* @throws \Http\Client\Exception The rejection reason.
93+
* @throws \Http\Client\Exception The rejection reason
9494
*/
9595
public function wait($unwrap = true)
9696
{
@@ -103,6 +103,7 @@ public function wait($unwrap = true)
103103

104104
return $this->core->getResponse();
105105
}
106+
106107
return null;
107108
}
108109
}

src/MultiRunner.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<?php
2+
23
namespace Http\Client\Curl;
34

45
use Http\Client\Exception\RequestException;
56

67
/**
7-
* Simultaneous requests runner
8+
* Simultaneous requests runner.
89
*
910
* @license http://opensource.org/licenses/MIT MIT
10-
*
1111
* @author Михаил Красильников <m.krasilnikov@yandex.ru>
1212
*/
1313
class MultiRunner
1414
{
1515
/**
16-
* cURL multi handle
16+
* cURL multi handle.
1717
*
1818
* @var resource|null
1919
*/
2020
private $multiHandle = null;
2121

2222
/**
23-
* Awaiting cores
23+
* Awaiting cores.
2424
*
2525
* @var PromiseCore[]
2626
*/
2727
private $cores = [];
2828

2929
/**
30-
* Release resources if still active
30+
* Release resources if still active.
3131
*/
3232
public function __destruct()
3333
{
@@ -37,7 +37,7 @@ public function __destruct()
3737
}
3838

3939
/**
40-
* Add promise to runner
40+
* Add promise to runner.
4141
*
4242
* @param PromiseCore $core
4343
*/
@@ -58,7 +58,7 @@ public function add(PromiseCore $core)
5858
}
5959

6060
/**
61-
* Remove promise from runner
61+
* Remove promise from runner.
6262
*
6363
* @param PromiseCore $core
6464
*/
@@ -68,6 +68,7 @@ public function remove(PromiseCore $core)
6868
if ($existed === $core) {
6969
curl_multi_remove_handle($this->multiHandle, $core->getHandle());
7070
unset($this->cores[$index]);
71+
7172
return;
7273
}
7374
}
@@ -122,6 +123,7 @@ private function findCoreByHandle($handle)
122123
return $core;
123124
}
124125
}
126+
125127
return null;
126128
}
127129
}

0 commit comments

Comments
 (0)