Skip to content

Commit bb98f24

Browse files
authored
Merge pull request #120 from Jean85/add-cs-fixer
[2.0] Add PHP-CS-Ffixer
2 parents 859f4c5 + 1cf0f9e commit bb98f24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+313
-409
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/phpspec.yml
55
/phpunit.xml
66
/vendor/
7+
/.php_cs.cache

.php_cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<?php
22

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

11-
use SLLH\StyleCIBridge\ConfigBridge;
14+
$finder = PhpCsFixer\Finder::create();
15+
$finder->in([
16+
'src',
17+
'spec'
18+
]);
1219

13-
return ConfigBridge::create();
20+
$config->setFinder($finder);
21+
22+
return $config;

.styleci.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.travis.yml

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,64 @@ language: php
22
sudo: false
33

44
cache:
5-
directories:
6-
- $HOME/.composer/cache/files
5+
directories:
6+
- $HOME/.composer/cache/files
77

88
env:
9-
global:
10-
- TEST_COMMAND="composer test"
9+
global:
10+
- TEST_COMMAND="composer test"
1111

1212
branches:
13-
except:
14-
- /^analysis-.*$/
13+
except:
14+
- /^analysis-.*$/
15+
16+
php:
17+
- 7.0
18+
- 7.1
19+
- 7.2
1520

1621
matrix:
17-
fast_finish: true
18-
include:
19-
- php: 7.0
20-
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
21-
22-
# Test the latest stable release
23-
- php: 7.0
24-
- php: 7.1
25-
- php: 7.2
26-
- php: 7.2
27-
env: COVERAGE=true TEST_COMMAND="composer test-ci" DEPENDENCIES="leanphp/phpspec-code-coverage"
28-
29-
# Test LTS versions
30-
- php: 7.1
31-
env: DEPENDENCIES="dunglas/symfony-lock:^2"
32-
- php: 7.1
33-
env: DEPENDENCIES="dunglas/symfony-lock:^3"
34-
- php: 7.1
35-
env: DEPENDENCIES="dunglas/symfony-lock:^4" STABILITY="rc"
36-
37-
# Latest dev release
38-
- php: 7.1
39-
env: STABILITY="dev"
40-
41-
allow_failures:
42-
- php: 7.3
43-
sudo: required
44-
- env: STABILITY="dev"
22+
fast_finish: true
23+
allow_failures:
24+
- php: 7.3
25+
26+
jobs:
27+
include:
28+
- php: 7.0
29+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
30+
- php: 7.2
31+
env: COVERAGE=true DEPENDENCIES="leanphp/phpspec-code-coverage"
32+
script:
33+
- composer test-ci
34+
after_success:
35+
- wget https://scrutinizer-ci.com/ocular.phar
36+
- php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml --revision=$TRAVIS_COMMIT
37+
# Test LTS versions
38+
- php: 7.1
39+
env: DEPENDENCIES="dunglas/symfony-lock:^2"
40+
- php: 7.1
41+
env: DEPENDENCIES="dunglas/symfony-lock:^3"
42+
- php: 7.1
43+
env: DEPENDENCIES="dunglas/symfony-lock:^4" STABILITY="rc"
44+
45+
# Latest dev release
46+
- php: 7.3
47+
sudo: required
48+
before_install:
49+
- composer remove --dev friendsofphp/php-cs-fixer
50+
- env: STABILITY="dev"
4551

4652
before_install:
47-
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
48-
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
49-
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
53+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
54+
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
55+
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
5056

5157
install:
52-
- cat composer.json
53-
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
54-
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
55-
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
58+
- cat composer.json
59+
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
60+
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
61+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
5662

5763
script:
58-
- composer validate --strict --no-check-lock
59-
- $TEST_COMMAND
60-
61-
after_success:
62-
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
63-
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
64+
- composer validate --strict --no-check-lock
65+
- composer test

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"guzzlehttp/psr7": "^1.4",
2323
"phpspec/phpspec": "^3.4 || ^4.2",
2424
"phpspec/prophecy": ">=1.8",
25-
"sebastian/comparator": ">=2"
25+
"sebastian/comparator": ">=2",
26+
"friendsofphp/php-cs-fixer": "^2.2"
2627
},
2728
"suggest": {
2829
"php-http/logger-plugin": "PSR-3 Logger plugin",
@@ -35,6 +36,8 @@
3536
}
3637
},
3738
"scripts": {
39+
"cs-check": "vendor/bin/php-cs-fixer fix --dry-run",
40+
"cs-fix": "vendor/bin/php-cs-fixer fix",
3841
"test": "vendor/bin/phpspec run",
3942
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
4043
},

spec/BatchClientSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99

1010
class BatchClientSpec extends ObjectBehavior
1111
{
12-
function let(HttpClient $client)
12+
public function let(HttpClient $client)
1313
{
1414
$this->beAnInstanceOf('Http\Client\Common\BatchClient', [$client]);
1515
}
1616

17-
function it_send_multiple_request_using_send_request(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response1, ResponseInterface $response2)
17+
public function it_send_multiple_request_using_send_request(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response1, ResponseInterface $response2)
1818
{
1919
$client->sendRequest($request1)->willReturn($response1);
2020
$client->sendRequest($request2)->willReturn($response2);
2121

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

25-
function it_throw_batch_exception_if_one_or_more_request_failed(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response)
25+
public function it_throw_batch_exception_if_one_or_more_request_failed(HttpClient $client, RequestInterface $request1, RequestInterface $request2, ResponseInterface $response)
2626
{
2727
$client->sendRequest($request1)->willReturn($response);
2828
$client->sendRequest($request2)->willThrow('Http\Client\Exception\HttpException');

spec/BatchResultSpec.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
class BatchResultSpec extends ObjectBehavior
1111
{
12-
function it_is_initializable()
12+
public function it_is_initializable()
1313
{
1414
$this->beAnInstanceOf('Http\Client\Common\BatchResult');
1515
}
1616

17-
function it_is_immutable(RequestInterface $request, ResponseInterface $response)
17+
public function it_is_immutable(RequestInterface $request, ResponseInterface $response)
1818
{
1919
$new = $this->addResponse($request, $response);
2020

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

26-
function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
26+
public function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
2727
{
2828
$new = $this->addResponse($request, $response);
2929

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

36-
function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
36+
public function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
3737
{
3838
$new = $this->addResponse($request, $response);
3939

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

46-
function it_keeps_exception_after_add_request(RequestInterface $request1, Exception $exception, RequestInterface $request2, ResponseInterface $response)
46+
public function it_keeps_exception_after_add_request(RequestInterface $request1, Exception $exception, RequestInterface $request2, ResponseInterface $response)
4747
{
4848
$new = $this->addException($request1, $exception);
4949
$new = $new->addResponse($request2, $response);

spec/EmulatedHttpAsyncClientSpec.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99

1010
class EmulatedHttpAsyncClientSpec extends ObjectBehavior
1111
{
12-
function let(HttpClient $httpClient)
12+
public function let(HttpClient $httpClient)
1313
{
1414
$this->beConstructedWith($httpClient);
1515
}
1616

17-
function it_is_initializable()
17+
public function it_is_initializable()
1818
{
1919
$this->shouldHaveType('Http\Client\Common\EmulatedHttpAsyncClient');
2020
}
2121

22-
function it_is_an_http_client()
22+
public function it_is_an_http_client()
2323
{
2424
$this->shouldImplement('Http\Client\HttpClient');
2525
}
2626

27-
function it_is_an_async_http_client()
27+
public function it_is_an_async_http_client()
2828
{
2929
$this->shouldImplement('Http\Client\HttpAsyncClient');
3030
}
3131

32-
function it_emulates_a_successful_request(
32+
public function it_emulates_a_successful_request(
3333
HttpClient $httpClient,
3434
RequestInterface $request,
3535
ResponseInterface $response
@@ -39,14 +39,14 @@ function it_emulates_a_successful_request(
3939
$this->sendAsyncRequest($request)->shouldReturnAnInstanceOf('Http\Client\Promise\HttpFulfilledPromise');
4040
}
4141

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

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

49-
function it_decorates_the_underlying_client(
49+
public function it_decorates_the_underlying_client(
5050
HttpClient $httpClient,
5151
RequestInterface $request,
5252
ResponseInterface $response

spec/EmulatedHttpClientSpec.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace spec\Http\Client\Common;
44

55
use Http\Client\Exception\TransferException;
6-
use Http\Client\HttpClient;
76
use Http\Client\HttpAsyncClient;
87
use Http\Promise\Promise;
98
use Psr\Http\Message\RequestInterface;
@@ -12,27 +11,27 @@
1211

1312
class EmulatedHttpClientSpec extends ObjectBehavior
1413
{
15-
function let(HttpAsyncClient $httpAsyncClient)
14+
public function let(HttpAsyncClient $httpAsyncClient)
1615
{
1716
$this->beConstructedWith($httpAsyncClient);
1817
}
1918

20-
function it_is_initializable()
19+
public function it_is_initializable()
2120
{
2221
$this->shouldHaveType('Http\Client\Common\EmulatedHttpClient');
2322
}
2423

25-
function it_is_an_http_client()
24+
public function it_is_an_http_client()
2625
{
2726
$this->shouldImplement('Http\Client\HttpClient');
2827
}
2928

30-
function it_is_an_async_http_client()
29+
public function it_is_an_async_http_client()
3130
{
3231
$this->shouldImplement('Http\Client\HttpAsyncClient');
3332
}
3433

35-
function it_emulates_a_successful_request(
34+
public function it_emulates_a_successful_request(
3635
HttpAsyncClient $httpAsyncClient,
3736
RequestInterface $request,
3837
Promise $promise,
@@ -47,7 +46,7 @@ function it_emulates_a_successful_request(
4746
$this->sendRequest($request)->shouldReturn($response);
4847
}
4948

50-
function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise)
49+
public function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestInterface $request, Promise $promise)
5150
{
5251
$promise->wait()->shouldBeCalled();
5352
$promise->getState()->willReturn(Promise::REJECTED);
@@ -58,7 +57,7 @@ function it_emulates_a_failed_request(HttpAsyncClient $httpAsyncClient, RequestI
5857
$this->shouldThrow('Http\Client\Exception')->duringSendRequest($request);
5958
}
6059

61-
function it_decorates_the_underlying_client(
60+
public function it_decorates_the_underlying_client(
6261
HttpAsyncClient $httpAsyncClient,
6362
RequestInterface $request,
6463
Promise $promise

spec/Exception/BatchExceptionSpec.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,32 @@
33
namespace spec\Http\Client\Common\Exception;
44

55
use Http\Client\Common\BatchResult;
6-
use Http\Client\Exception;
76
use PhpSpec\ObjectBehavior;
87

98
class BatchExceptionSpec extends ObjectBehavior
109
{
11-
function let()
10+
public function let()
1211
{
1312
$batchResult = new BatchResult();
1413
$this->beConstructedWith($batchResult);
1514
}
1615

17-
function it_is_initializable()
16+
public function it_is_initializable()
1817
{
1918
$this->shouldHaveType('Http\Client\Common\Exception\BatchException');
2019
}
2120

22-
function it_is_a_runtime_exception()
21+
public function it_is_a_runtime_exception()
2322
{
2423
$this->shouldHaveType('RuntimeException');
2524
}
2625

27-
function it_is_an_exception()
26+
public function it_is_an_exception()
2827
{
2928
$this->shouldImplement('Http\Client\Exception');
3029
}
3130

32-
function it_has_a_batch_result()
31+
public function it_has_a_batch_result()
3332
{
3433
$this->getResult()->shouldHaveType('Http\Client\Common\BatchResult');
3534
}

0 commit comments

Comments
 (0)