Skip to content

Fix cs and remove old support for php versions #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ vendor/
composer.lock
phpspec.yml
phpunit.xml
/.php_cs.cache
/tests/server/ssl/*.pem
/tests/server/ssl/*.key
/tests/server/ssl/*.req
27 changes: 18 additions & 9 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<?php

/*
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally
* with composer.
*
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/
$config = PhpCsFixer\Config::create();
$config->setRules([
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => [
'syntax' => 'short',
],
'no_empty_phpdoc' => true,
'no_superfluous_phpdoc_tags' => true,
]);

use SLLH\StyleCIBridge\ConfigBridge;
$finder = PhpCsFixer\Finder::create();
$finder->in([
'src',
'tests'
]);

return ConfigBridge::create();
$config->setFinder($finder);

return $config;
12 changes: 3 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ cache:
- $HOME/.composer/cache

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

env:
global:
Expand All @@ -21,15 +20,10 @@ branches:
- /^analysis-.*$/

matrix:
allow_failures:
- php: hhvm
dist: trusty
fast_finish: true
include:
- php: 5.5
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
- php: hhvm
dist: trusty

before_install:
- travis_retry composer self-update
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
}
],
"require": {
"php": "^5.5 || ^7.0",
"php": "^7.1",
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0",
"php-http/httplug": "^1.0",
"php-http/message-factory": "^1.0.2",
"php-http/discovery": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2",
"guzzlehttp/psr7": "^1.2",
"php-http/client-integration-tests": "^0.6",
"php-http/message": "^1.0",
Expand All @@ -35,6 +36,8 @@
}
},
"scripts": {
"cs-check": "vendor/bin/php-cs-fixer fix --dry-run",
"cs-fix": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/phpunit",
"test-ci": "vendor/bin/phpunit --coverage-clover build/coverage.xml"
},
Expand Down
1 change: 0 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ protected function configure(array $config = [])
/**
* Return remote socket from the request.
*
* @param RequestInterface $request
*
* @throws InvalidRequestException When no remote can be determined from the request
*
Expand Down
11 changes: 4 additions & 7 deletions src/RequestWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ trait RequestWriter
/**
* Write a request to a socket.
*
* @param resource $socket
* @param RequestInterface $request
* @param int $bufferSize
* @param resource $socket
* @param int $bufferSize
*
* @throws BrokenPipeException
*/
Expand All @@ -37,9 +36,8 @@ protected function writeRequest($socket, RequestInterface $request, $bufferSize
/**
* Write Body of the request.
*
* @param resource $socket
* @param RequestInterface $request
* @param int $bufferSize
* @param resource $socket
* @param int $bufferSize
*
* @throws BrokenPipeException
*/
Expand All @@ -63,7 +61,6 @@ protected function writeBody($socket, RequestInterface $request, $bufferSize = 8
/**
* Produce the header of request as a string based on a PSR Request.
*
* @param RequestInterface $request
*
* @return string
*/
Expand Down
4 changes: 1 addition & 3 deletions src/ResponseReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ trait ResponseReader
/**
* Read a response from a socket.
*
* @param RequestInterface $request
* @param resource $socket
* @param resource $socket
*
* @throws TimeoutException When the socket timed out
* @throws BrokenPipeException When the response cannot be read
Expand Down Expand Up @@ -89,7 +88,6 @@ protected function readResponse(RequestInterface $request, $socket)
* Create the stream.
*
* @param $socket
* @param ResponseInterface $response
*
* @return Stream
*/
Expand Down
6 changes: 3 additions & 3 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class BaseTestCase extends TestCase

public function startServer($name)
{
$filename = __DIR__ . '/server/' . $name . '.php';
$pipes = [];
$filename = __DIR__.'/server/'.$name.'.php';
$pipes = [];

if (!Semaphore::acquire()) {
$this->fail('Could not connect to server');
}

$this->servers[$name] = proc_open('php '. $filename, [], $pipes);
$this->servers[$name] = proc_open('php '.$filename, [], $pipes);
sleep(1);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Semaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function acquire()
return false;
}
}
self::$openConnections++;
++self::$openConnections;

return true;
}
Expand All @@ -35,6 +35,6 @@ public static function release()
{
// Do no be too quick
usleep(500000);
self::$openConnections--;
--self::$openConnections;
}
}
1 change: 0 additions & 1 deletion tests/SocketClientFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Http\Client\Socket\Tests;

use Http\Client\Tests\HttpFeatureTest;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Http\Client\Socket\Client as SocketHttpClient;

class SocketClientFeatureTest extends HttpFeatureTest
Expand Down
1 change: 0 additions & 1 deletion tests/SocketHttpAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Http\Client\Socket\Tests;

use Http\Client\Tests\HttpClientTest;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use Http\Client\Socket\Client as SocketHttpClient;

class SocketHttpAdapterTest extends HttpClientTest
Expand Down
64 changes: 32 additions & 32 deletions tests/SocketHttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SocketHttpClientTest extends BaseTestCase
{
public function createClient($options = array())
public function createClient($options = [])
{
$messageFactory = new GuzzleMessageFactory();

Expand All @@ -18,7 +18,7 @@ public function createClient($options = array())
public function testTcpSocketDomain()
{
$this->startServer('tcp-server');
$client = $this->createClient(['remote_socket' => '127.0.0.1:19999']);
$client = $this->createClient(['remote_socket' => '127.0.0.1:19999']);
$response = $client->get('/', []);

$this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response);
Expand All @@ -30,14 +30,14 @@ public function testTcpSocketDomain()
*/
public function testNoRemote()
{
$client = $this->createClient();
$client = $this->createClient();
$client->get('/', []);
}

public function testRemoteInUri()
{
$this->startServer('tcp-server');
$client = $this->createClient();
$client = $this->createClient();
$response = $client->get('http://127.0.0.1:19999/', []);

$this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response);
Expand All @@ -47,7 +47,7 @@ public function testRemoteInUri()
public function testRemoteInHostHeader()
{
$this->startServer('tcp-server');
$client = $this->createClient();
$client = $this->createClient();
$response = $client->get('/', ['Host' => '127.0.0.1:19999']);

$this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response);
Expand All @@ -67,13 +67,13 @@ public function testBrokenSocket()
public function testSslRemoteInUri()
{
$this->startServer('tcp-ssl-server');
$client = $this->createClient([
$client = $this->createClient([
'stream_context_options' => [
'ssl' => [
'peer_name' => 'socket-adapter',
'cafile' => __DIR__ . '/server/ssl/ca.pem'
]
]
'cafile' => __DIR__.'/server/ssl/ca.pem',
],
],
]);
$response = $client->get('https://127.0.0.1:19999/', []);

Expand All @@ -85,8 +85,8 @@ public function testUnixSocketDomain()
{
$this->startServer('unix-domain-server');

$client = $this->createClient([
'remote_socket' => 'unix://'.__DIR__.'/server/server.sock'
$client = $this->createClient([
'remote_socket' => 'unix://'.__DIR__.'/server/server.sock',
]);
$response = $client->get('/', []);

Expand All @@ -99,23 +99,23 @@ public function testUnixSocketDomain()
*/
public function testNetworkExceptionOnConnectError()
{
$client = $this->createClient(['remote_socket' => '127.0.0.1:19999']);
$client = $this->createClient(['remote_socket' => '127.0.0.1:19999']);
$client->get('/', []);
}

public function testSslConnection()
{
$this->startServer('tcp-ssl-server');

$client = $this->createClient([
$client = $this->createClient([
'remote_socket' => '127.0.0.1:19999',
'ssl' => true,
'ssl' => true,
'stream_context_options' => [
'ssl' => [
'peer_name' => 'socket-adapter',
'cafile' => __DIR__ . '/server/ssl/ca.pem'
]
]
'cafile' => __DIR__.'/server/ssl/ca.pem',
],
],
]);
$response = $client->get('/', []);

Expand All @@ -131,16 +131,16 @@ public function testSslConnectionWithClientCertificate()

$this->startServer('tcp-ssl-server-client');

$client = $this->createClient([
$client = $this->createClient([
'remote_socket' => '127.0.0.1:19999',
'ssl' => true,
'ssl' => true,
'stream_context_options' => [
'ssl' => [
'peer_name' => 'socket-adapter',
'cafile' => __DIR__ . '/server/ssl/ca.pem',
'local_cert' => __DIR__ . '/server/ssl/client-and-key.pem'
]
]
'peer_name' => 'socket-adapter',
'cafile' => __DIR__.'/server/ssl/ca.pem',
'local_cert' => __DIR__.'/server/ssl/client-and-key.pem',
],
],
]);
$response = $client->get('/', []);

Expand All @@ -156,15 +156,15 @@ public function testInvalidSslConnectionWithClientCertificate()

$this->startServer('tcp-ssl-server-client');

$client = $this->createClient([
$client = $this->createClient([
'remote_socket' => '127.0.0.1:19999',
'ssl' => true,
'ssl' => true,
'stream_context_options' => [
'ssl' => [
'peer_name' => 'socket-adapter',
'cafile' => __DIR__ . '/server/ssl/ca.pem'
]
]
'peer_name' => 'socket-adapter',
'cafile' => __DIR__.'/server/ssl/ca.pem',
],
],
]);
$response = $client->get('/', []);

Expand All @@ -179,7 +179,7 @@ public function testNetworkExceptionOnSslError()
{
$this->startServer('tcp-server');

$client = $this->createClient(['remote_socket' => '127.0.0.1:19999', 'ssl' => true]);
$client = $this->createClient(['remote_socket' => '127.0.0.1:19999', 'ssl' => true]);
$client->get('/', []);
}

Expand All @@ -188,7 +188,7 @@ public function testNetworkExceptionOnSslError()
*/
public function testNetworkExceptionOnTimeout()
{
$client = $this->createClient(['timeout' => 10]);
$client = $this->createClient(['timeout' => 10]);
$client->get('http://php.net', []);
}
}
Loading