Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed Sep 5, 2018
1 parent 0d6816a commit 0d7e985
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion lib/Browser.php
Expand Up @@ -245,7 +245,7 @@ private function prepareMultipart(string $name, string $content, string $boundar
}

// Set a default content-length header
if ($length = strlen($content)) {
if ($length = \strlen($content)) {
$fileHeaders['Content-Length'] = (string) $length;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Client/AbstractCurl.php
Expand Up @@ -54,7 +54,7 @@ protected function createHandle()
*/
protected function releaseHandle($curl): void
{
if (count($this->handles) >= $this->maxHandles) {
if (\count($this->handles) >= $this->maxHandles) {
curl_close($curl);
} else {
// Remove all callback functions as they can hold onto references
Expand All @@ -81,7 +81,7 @@ protected function releaseHandle($curl): void
*/
protected function prepare($curl, RequestInterface $request, ParameterBag $options): ResponseBuilder
{
if (defined('CURLOPT_PROTOCOLS')) {
if (\defined('CURLOPT_PROTOCOLS')) {
curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
}
Expand All @@ -104,7 +104,7 @@ protected function prepare($curl, RequestInterface $request, ParameterBag $optio
}
}

return strlen($data);
return \strlen($data);
});

curl_setopt($curl, CURLOPT_WRITEFUNCTION, function ($ch, $data) use ($responseBuilder) {
Expand Down Expand Up @@ -235,7 +235,7 @@ private function getProtocolVersion(RequestInterface $request): int
case '1.1':
return CURL_HTTP_VERSION_1_1;
case '2.0':
if (defined('CURL_HTTP_VERSION_2_0')) {
if (\defined('CURL_HTTP_VERSION_2_0')) {
return CURL_HTTP_VERSION_2_0;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Client/MultiCurl.php
Expand Up @@ -68,7 +68,7 @@ protected function configureOptions(OptionsResolver $resolver): void

public function count(): int
{
return count($this->queue);
return \count($this->queue);
}

/**
Expand All @@ -95,7 +95,7 @@ public function proceed(): void
}

foreach ($this->queue as $i => $queueItem) {
if (2 !== count($queueItem)) {
if (2 !== \count($queueItem)) {
// We have already prepared this curl
continue;
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public function proceed(): void
unset($this->queue[$i]);

// callback
call_user_func($options->get('callback'), $request, $response, $exception);
\call_user_func($options->get('callback'), $request, $response, $exception);
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Configuration/ParameterBag.php
Expand Up @@ -55,8 +55,8 @@ public function add(array $parameters = []): self
// Make sure to merge Curl parameters
if (isset($this->parameters['curl'])
&& isset($parameters['curl'])
&& is_array($this->parameters['curl'])
&& is_array($parameters['curl'])) {
&& \is_array($this->parameters['curl'])
&& \is_array($parameters['curl'])) {
$parameters['curl'] = array_replace($this->parameters['curl'], $parameters['curl']);
}

Expand Down Expand Up @@ -107,6 +107,6 @@ public function getIterator(): \ArrayIterator
*/
public function count(): int
{
return count($this->parameters);
return \count($this->parameters);
}
}
2 changes: 1 addition & 1 deletion lib/Message/HeaderConverter.php
Expand Up @@ -33,7 +33,7 @@ public static function toBuzzHeaders(array $headers): array
$buzz = [];

foreach ($headers as $key => $values) {
if (!is_array($values)) {
if (!\is_array($values)) {
$buzz[] = sprintf('%s: %s', $key, $values);
} else {
foreach ($values as $value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Message/ResponseBuilder.php
Expand Up @@ -34,7 +34,7 @@ public function __construct($responseFactory)
public function setStatus(string $input): void
{
$parts = explode(' ', $input, 3);
if (count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) {
if (\count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) {
throw new InvalidArgumentException(sprintf('"%s" is not a valid HTTP status line', $input));
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Middleware/CallbackMiddleware.php
Expand Up @@ -33,7 +33,7 @@ class CallbackMiddleware implements MiddlewareInterface
*/
public function __construct($callable)
{
if (!is_callable($callable)) {
if (!\is_callable($callable)) {
throw new InvalidArgumentException('The argument is not callable.');
}

Expand All @@ -42,14 +42,14 @@ public function __construct($callable)

public function handleRequest(RequestInterface $request, callable $next)
{
$request = call_user_func($this->callable, $request);
$request = \call_user_func($this->callable, $request);

return $next($request);
}

public function handleResponse(RequestInterface $request, ResponseInterface $response, callable $next)
{
$response = call_user_func($this->callable, $request, $response);
$response = \call_user_func($this->callable, $request, $response);

return $next($request, $response);
}
Expand Down
24 changes: 12 additions & 12 deletions lib/Middleware/DigestAuthMiddleware.php
Expand Up @@ -210,7 +210,7 @@ private function getClientNonce(): ?string
// If it is set then increment it.
++$this->nonceCount;
// Ensure nonceCount is zero-padded at the start of the string to a length of 8
while (strlen($this->nonceCount) < 8) {
while (\strlen($this->nonceCount) < 8) {
$this->nonceCount = '0'.$this->nonceCount;
}
}
Expand Down Expand Up @@ -347,7 +347,7 @@ private function getHeader(): ?string
}

// Remove the last comma from the header
$header = substr($header, 0, strlen($header) - 1);
$header = substr($header, 0, \strlen($header) - 1);
// Discard the Client Nonce if OPTION_DISCARD_CLIENT_NONCE is set.
if ($this->options & self::OPTION_DISCARD_CLIENT_NONCE) {
$this->discardClientNonce();
Expand Down Expand Up @@ -470,20 +470,20 @@ private function getResponse(): ?string
private function getQOP(): ?string
{
// Has the server specified any options for Quality of Protection
if (count($this->qop) > 0) {
if (\count($this->qop) > 0) {
if ($this->options & self::OPTION_QOP_AUTH_INT) {
if (in_array('auth-int', $this->qop)) {
if (\in_array('auth-int', $this->qop)) {
return 'auth-int';
}
if (in_array('auth', $this->qop)) {
if (\in_array('auth', $this->qop)) {
return 'auth';
}
}
if ($this->options & self::OPTION_QOP_AUTH) {
if (in_array('auth', $this->qop)) {
if (\in_array('auth', $this->qop)) {
return 'auth';
}
if (in_array('auth-int', $this->qop)) {
if (\in_array('auth-int', $this->qop)) {
return 'auth-int';
}
}
Expand Down Expand Up @@ -608,7 +608,7 @@ private function parseWwwAuthenticateHeader(string $wwwAuthenticate): void
if ('Digest ' == substr($wwwAuthenticate, 0, 7)) {
$this->setAuthenticationMethod('Digest');
// Remove "Digest " from start of header
$wwwAuthenticate = substr($wwwAuthenticate, 7, strlen($wwwAuthenticate) - 7);
$wwwAuthenticate = substr($wwwAuthenticate, 7, \strlen($wwwAuthenticate) - 7);

$nameValuePairs = $this->parseNameValuePairs($wwwAuthenticate);

Expand Down Expand Up @@ -644,7 +644,7 @@ private function parseWwwAuthenticateHeader(string $wwwAuthenticate): void
if ('Basic ' == substr($wwwAuthenticate, 0, 6)) {
$this->setAuthenticationMethod('Basic');
// Remove "Basic " from start of header
$wwwAuthenticate = substr($wwwAuthenticate, 6, strlen($wwwAuthenticate) - 6);
$wwwAuthenticate = substr($wwwAuthenticate, 6, \strlen($wwwAuthenticate) - 6);

$nameValuePairs = $this->parseNameValuePairs($wwwAuthenticate);

Expand Down Expand Up @@ -821,10 +821,10 @@ private function unquoteString(string $str = null): ?string
{
if ($str) {
if ('"' == substr($str, 0, 1)) {
$str = substr($str, 1, strlen($str) - 1);
$str = substr($str, 1, \strlen($str) - 1);
}
if ('"' == substr($str, strlen($str) - 1, 1)) {
$str = substr($str, 0, strlen($str) - 1);
if ('"' == substr($str, \strlen($str) - 1, 1)) {
$str = substr($str, 0, \strlen($str) - 1);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Middleware/History/Journal.php
Expand Up @@ -33,7 +33,7 @@ public function record(RequestInterface $request, ResponseInterface $response, f
public function addEntry(Entry $entry): void
{
array_push($this->entries, $entry);
$this->entries = array_slice($this->entries, $this->getLimit() * -1);
$this->entries = \array_slice($this->entries, $this->getLimit() * -1);
end($this->entries);
}

Expand Down Expand Up @@ -77,7 +77,7 @@ public function clear(): void

public function count(): int
{
return count($this->entries);
return \count($this->entries);
}

public function setLimit(int $limit): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/MiddlewareChainTest.php
Expand Up @@ -104,14 +104,14 @@ public function __construct(callable $requestCallable, callable $responseCallabl

public function handleRequest(RequestInterface $request, callable $next)
{
call_user_func($this->requestCallable, $request);
\call_user_func($this->requestCallable, $request);

return $next($request);
}

public function handleResponse(RequestInterface $request, ResponseInterface $response, callable $next)
{
call_user_func($this->responseCallable, $request, $request);
\call_user_func($this->responseCallable, $request, $request);

return $next($request, $response);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/CurlIntegrationTest.php
Expand Up @@ -22,10 +22,10 @@ protected function createHttpAdapter()
*/
public function testSendRequest($method, $uri, array $headers, $body)
{
if (defined('HHVM_VERSION')) {
if (\defined('HHVM_VERSION')) {
static::markTestSkipped('This test can not run under HHVM');
}
if (null !== $body && in_array($method, ['GET', 'HEAD', 'TRACE'], true)) {
if (null !== $body && \in_array($method, ['GET', 'HEAD', 'TRACE'], true)) {
static::markTestSkipped('cURL can not send body using '.$method);
}
parent::testSendRequest($method, $uri, $headers, $body);
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/MultiCurlIntegrationTest.php
Expand Up @@ -22,10 +22,10 @@ protected function createHttpAdapter()
*/
public function testSendRequest($method, $uri, array $headers, $body)
{
if (defined('HHVM_VERSION')) {
if (\defined('HHVM_VERSION')) {
static::markTestSkipped('This test can not run under HHVM');
}
if (null !== $body && in_array($method, ['GET', 'HEAD', 'TRACE'], true)) {
if (null !== $body && \in_array($method, ['GET', 'HEAD', 'TRACE'], true)) {
static::markTestSkipped('cURL can not send body using '.$method);
}
parent::testSendRequest($method, $uri, $headers, $body);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/BrowserTest.php
Expand Up @@ -140,7 +140,7 @@ public function submitFormProvider()
'user%5Bname%5D=Kris+Wallsmith&user%5Bemail%5D=foo%40bar.com',
];
yield [
['email' => 'foo@bar.com', 'image' => ['path' => dirname(__DIR__).'/Resources/pixel.gif']],
['email' => 'foo@bar.com', 'image' => ['path' => \dirname(__DIR__).'/Resources/pixel.gif']],
[],
['Content-Type' => 'regex|^multipart/form-data; boundary=".+"$|'],
'regex|--[0-9a-f\.]+
Expand All @@ -157,11 +157,11 @@ public function submitFormProvider()
|', ];
yield [
['email' => 'foo@bar.com', 'image' => [
'path' => dirname(__DIR__).'/Resources/pixel.gif',
'path' => \dirname(__DIR__).'/Resources/pixel.gif',
'contentType' => 'image/gif',
'filename' => 'my-pixel.gif',
], 'other-image' => [
'path' => dirname(__DIR__).'/Resources/pixel.gif',
'path' => \dirname(__DIR__).'/Resources/pixel.gif',
'contentType' => 'image/gif',
'filename' => 'other-pixel.gif',
]],
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Client/FunctionalTest.php
Expand Up @@ -134,7 +134,7 @@ public function testMultiCurlExecutesRequestsConcurently()

$calls = [];
$callback = function (RequestInterface $request, ResponseInterface $response = null, ClientException $exception = null) use (&$calls) {
$calls[] = func_get_args();
$calls[] = \func_get_args();
};

for ($i = 3; $i > 0; --$i) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Configuration/ParameterBagTest.php
Expand Up @@ -93,14 +93,14 @@ public function testGetIterator()
$this->assertEquals($parameters[$key], $val);
}

$this->assertEquals(count($parameters), $i);
$this->assertEquals(\count($parameters), $i);
}

public function testCount()
{
$parameters = ['foo' => 'bar', 'hello' => 'world'];
$bag = new ParameterBag($parameters);

$this->assertCount(count($parameters), $bag);
$this->assertCount(\count($parameters), $bag);
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Middleware/CallbackMiddlewareTest.php
Expand Up @@ -21,10 +21,10 @@ public function testCallback()
$requestOut = new Request('POST', '/');

$middleware = new CallbackMiddleware(function () use ($requestIn, $responseIn, $requestOut, $responseOut) {
$calls[] = $args = func_get_args();
$calls[] = $args = \func_get_args();
$this->assertEquals($requestIn, $args[0]);

if (2 === count($args)) {
if (2 === \count($args)) {
$this->assertEquals($responseIn, $args[1]);

return $responseOut;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Middleware/History/JournalTest.php
Expand Up @@ -53,7 +53,7 @@ public function testRecordEnforcesLimit()
$journal->record($this->request2, $this->response2);
$journal->record($this->request3, $this->response3);

$this->assertEquals(2, count($journal));
$this->assertEquals(2, \count($journal));
}

public function testGetLastReturnsTheLastEntry()
Expand Down Expand Up @@ -105,7 +105,7 @@ public function testForeachIteratesReversedEntries(Journal $journal)
public function testClearRemovesEntries(Journal $journal)
{
$journal->clear();
$this->assertEquals(0, count($journal));
$this->assertEquals(0, \count($journal));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Util/CookieJarTest.php
Expand Up @@ -25,10 +25,10 @@ public function testProcessSetCookieHeadersSetsCookies()

$cookies = $jar->getCookies();

$this->assertEquals(2, count($cookies));
$this->assertEquals(2, \count($cookies));
foreach ($cookies as $cookie) {
$this->assertEquals('www.example.com', $cookie->getAttribute(Cookie::ATTR_DOMAIN));
$this->assertTrue(in_array($cookie->getName(), ['SESSION1', 'SESSION2']));
$this->assertTrue(\in_array($cookie->getName(), ['SESSION1', 'SESSION2']));
}
}

Expand Down Expand Up @@ -59,7 +59,7 @@ public function testClearExpiredCookiesRemovesExpiredCookies()
$jar->addCookie($cookie);
$jar->clearExpiredCookies();

$this->assertEquals(0, count($jar->getCookies()));
$this->assertEquals(0, \count($jar->getCookies()));

$cookie = new Cookie();
$cookie->setName('SESSION');
Expand All @@ -70,7 +70,7 @@ public function testClearExpiredCookiesRemovesExpiredCookies()
$jar->addCookie($cookie);
$jar->clearExpiredCookies();

$this->assertEquals(0, count($jar->getCookies()));
$this->assertEquals(0, \count($jar->getCookies()));
}

public function testClear()
Expand All @@ -82,9 +82,9 @@ public function testClear()

$jar = new CookieJar();
$jar->addCookie($cookie);
$this->assertEquals(1, count($jar->getCookies()));
$this->assertEquals(1, \count($jar->getCookies()));

$jar->clear();
$this->assertEquals(0, count($jar->getCookies()));
$this->assertEquals(0, \count($jar->getCookies()));
}
}

0 comments on commit 0d7e985

Please sign in to comment.