Skip to content

[2.0] Add PHP-CS-Ffixer #120

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

Merged
merged 7 commits into from
Nov 20, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/phpspec.yml
/phpunit.xml
/vendor/
/.php_cs.cache
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',
'spec'
]);

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

return $config;
14 changes: 0 additions & 14 deletions .styleci.yml

This file was deleted.

96 changes: 49 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,64 @@ language: php
sudo: false

cache:
directories:
- $HOME/.composer/cache/files
directories:
- $HOME/.composer/cache/files

env:
global:
- TEST_COMMAND="composer test"
global:
- TEST_COMMAND="composer test"

branches:
except:
- /^analysis-.*$/
except:
- /^analysis-.*$/

php:
- 7.0
- 7.1
- 7.2

matrix:
fast_finish: true
include:
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"

# Test the latest stable release
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.2
env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="leanphp/phpspec-code-coverage"

# Test LTS versions
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^2"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^3"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^4" STABILITY="rc"

# Latest dev release
- php: 7.1
env: STABILITY="dev"

allow_failures:
- php: 7.3
sudo: required
- env: STABILITY="dev"
fast_finish: true
allow_failures:
- php: 7.3

jobs:
include:
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.2
env: COVERAGE=true DEPENDENCIES="leanphp/phpspec-code-coverage"
script:
- composer test-ci
after_success:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml --revision=$TRAVIS_COMMIT
# Test LTS versions
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^2"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^3"
- php: 7.1
env: DEPENDENCIES="dunglas/symfony-lock:^4" STABILITY="rc"

# Latest dev release
- php: 7.3
sudo: required
before_install:
- composer remove --dev friendsofphp/php-cs-fixer
- env: STABILITY="dev"

before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;

install:
- cat composer.json
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
- cat composer.json
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

script:
- composer validate --strict --no-check-lock
- $TEST_COMMAND

after_success:
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
- composer validate --strict --no-check-lock
- composer test
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"guzzlehttp/psr7": "^1.4",
"phpspec/phpspec": "^3.4 || ^4.2",
"phpspec/prophecy": ">=1.8",
"sebastian/comparator": ">=2"
"sebastian/comparator": ">=2",
"friendsofphp/php-cs-fixer": "^2.2"
},
"suggest": {
"php-http/logger-plugin": "PSR-3 Logger plugin",
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/phpspec run",
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
},
Expand Down
6 changes: 3 additions & 3 deletions spec/BatchClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@

class BatchClientSpec extends ObjectBehavior
{
function let(HttpClient $client)
public function let(HttpClient $client)
{
$this->beAnInstanceOf('Http\Client\Common\BatchClient', [$client]);
}

function it_send_multiple_request_using_send_request(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response1, ResponseInterface $response2)
public function it_send_multiple_request_using_send_request(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response1, ResponseInterface $response2)
{
$client->sendRequest($request1)->willReturn($response1);
$client->sendRequest($request2)->willReturn($response2);

$this->sendRequests([$request1, $request2])->shouldReturnAnInstanceOf('Http\Client\Common\BatchResult');
}

function it_throw_batch_exception_if_one_or_more_request_failed(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response)
public function it_throw_batch_exception_if_one_or_more_request_failed(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response)
{
$client->sendRequest($request1)->willReturn($response);
$client->sendRequest($request2)->willThrow('Http\Client\Exception\HttpException');
Expand Down
10 changes: 5 additions & 5 deletions spec/BatchResultSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

class BatchResultSpec extends ObjectBehavior
{
function it_is_initializable()
public function it_is_initializable()
{
$this->beAnInstanceOf('Http\Client\Common\BatchResult');
}

function it_is_immutable(RequestInterface $request, ResponseInterface $response)
public function it_is_immutable(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

Expand All @@ -23,7 +23,7 @@ function it_is_immutable(RequestInterface $request, ResponseInterface $response)
$new->getResponses()->shouldReturn([$response]);
}

function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
public function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

Expand All @@ -33,7 +33,7 @@ function it_has_a_responses(RequestInterface $request, ResponseInterface $respon
$new->getResponses()->shouldReturn([$response]);
}

function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
public function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
{
$new = $this->addResponse($request, $response);

Expand All @@ -43,7 +43,7 @@ function it_has_a_response_for_a_request(RequestInterface $request, ResponseInte
$new->isSuccessful($request)->shouldReturn(true);
}

function it_keeps_exception_after_add_request(RequestInterface $request1, Exception $exception, RequestInterface $request2, ResponseInterface $response)
public function it_keeps_exception_after_add_request(RequestInterface $request1, Exception $exception, RequestInterface $request2, ResponseInterface $response)
{
$new = $this->addException($request1, $exception);
$new = $new->addResponse($request2, $response);
Expand Down
14 changes: 7 additions & 7 deletions spec/EmulatedHttpAsyncClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@

class EmulatedHttpAsyncClientSpec extends ObjectBehavior
{
function let(HttpClient $httpClient)
public function let(HttpClient $httpClient)
{
$this->beConstructedWith($httpClient);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Common\EmulatedHttpAsyncClient');
}

function it_is_an_http_client()
public function it_is_an_http_client()
{
$this->shouldImplement('Http\Client\HttpClient');
}

function it_is_an_async_http_client()
public function it_is_an_async_http_client()
{
$this->shouldImplement('Http\Client\HttpAsyncClient');
}

function it_emulates_a_successful_request(
public function it_emulates_a_successful_request(
HttpClient $httpClient,
RequestInterface $request,
ResponseInterface $response
Expand All @@ -39,14 +39,14 @@ function it_emulates_a_successful_request(
$this->sendAsyncRequest($request)->shouldReturnAnInstanceOf('Http\Client\Promise\HttpFulfilledPromise');
}

function it_emulates_a_failed_request(HttpClient $httpClient, RequestInterface $request)
public function it_emulates_a_failed_request(HttpClient $httpClient, RequestInterface $request)
{
$httpClient->sendRequest($request)->willThrow('Http\Client\Exception\TransferException');

$this->sendAsyncRequest($request)->shouldReturnAnInstanceOf('Http\Client\Promise\HttpRejectedPromise');
}

function it_decorates_the_underlying_client(
public function it_decorates_the_underlying_client(
HttpClient $httpClient,
RequestInterface $request,
ResponseInterface $response
Expand Down
15 changes: 7 additions & 8 deletions spec/EmulatedHttpClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace spec\Http\Client\Common;

use Http\Client\Exception\TransferException;
use Http\Client\HttpClient;
use Http\Client\HttpAsyncClient;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
Expand All @@ -12,27 +11,27 @@

class EmulatedHttpClientSpec extends ObjectBehavior
{
function let(HttpAsyncClient $httpAsyncClient)
public function let(HttpAsyncClient $httpAsyncClient)
{
$this->beConstructedWith($httpAsyncClient);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Common\EmulatedHttpClient');
}

function it_is_an_http_client()
public function it_is_an_http_client()
{
$this->shouldImplement('Http\Client\HttpClient');
}

function it_is_an_async_http_client()
public function it_is_an_async_http_client()
{
$this->shouldImplement('Http\Client\HttpAsyncClient');
}

function it_emulates_a_successful_request(
public function it_emulates_a_successful_request(
HttpAsyncClient $httpAsyncClient,
RequestInterface $request,
Promise $promise,
Expand All @@ -47,7 +46,7 @@ function it_emulates_a_successful_request(
$this->sendRequest($request)->shouldReturn($response);
}

function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise)
public function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise)
{
$promise->wait()->shouldBeCalled();
$promise->getState()->willReturn(Promise::REJECTED);
Expand All @@ -58,7 +57,7 @@ function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestI
$this->shouldThrow('Http\Client\Exception')->duringSendRequest($request);
}

function it_decorates_the_underlying_client(
public function it_decorates_the_underlying_client(
HttpAsyncClient $httpAsyncClient,
RequestInterface $request,
Promise $promise
Expand Down
11 changes: 5 additions & 6 deletions spec/Exception/BatchExceptionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,32 @@
namespace spec\Http\Client\Common\Exception;

use Http\Client\Common\BatchResult;
use Http\Client\Exception;
use PhpSpec\ObjectBehavior;

class BatchExceptionSpec extends ObjectBehavior
{
function let()
public function let()
{
$batchResult = new BatchResult();
$this->beConstructedWith($batchResult);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Common\Exception\BatchException');
}

function it_is_a_runtime_exception()
public function it_is_a_runtime_exception()
{
$this->shouldHaveType('RuntimeException');
}

function it_is_an_exception()
public function it_is_an_exception()
{
$this->shouldImplement('Http\Client\Exception');
}

function it_has_a_batch_result()
public function it_has_a_batch_result()
{
$this->getResult()->shouldHaveType('Http\Client\Common\BatchResult');
}
Expand Down
Loading