Skip to content

Commit c66c61c

Browse files
author
abluchet
committed
Merge remote-tracking branch 'upstream/2.2' into merge-2.2
2 parents 3e5d629 + 435d445 commit c66c61c

File tree

13 files changed

+117
-66
lines changed

13 files changed

+117
-66
lines changed

.circleci/config.yml

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ reusable-steps:
2525
- npm-cache-{{ .Revision }}
2626
- npm-cache-{{ .Branch }}
2727
- npm-cache
28+
- &restore-php-cs-fixer-cache
29+
restore_cache:
30+
keys:
31+
- php-cs-fixer-cache-{{ .Revision }}
32+
- php-cs-fixer-cache-{{ .Branch }}
33+
- php-cs-fixer-cache
2834
- &save-composer-cache-by-branch
2935
save_cache:
3036
paths:
@@ -45,6 +51,16 @@ reusable-steps:
4551
paths:
4652
- ~/.npm
4753
key: npm-cache-{{ .Revision }}-{{ .BuildNum }}
54+
- &save-php-cs-fixer-cache-by-branch
55+
save_cache:
56+
paths:
57+
- .php_cs.cache
58+
key: php-cs-fixer-cache-{{ .Branch }}-{{ .BuildNum }}
59+
- &save-php-cs-fixer-cache-by-revision
60+
save_cache:
61+
paths:
62+
- .php_cs.cache
63+
key: php-cs-fixer-cache-{{ .Revision }}-{{ .BuildNum }}
4864
- &update-composer
4965
run:
5066
name: Update Composer
@@ -55,7 +71,55 @@ reusable-steps:
5571
command: composer update --prefer-dist --no-progress --no-suggest --ansi
5672

5773
jobs:
58-
phpunit-php-7.2-coverage:
74+
php-cs-fixer:
75+
docker:
76+
- image: circleci/php:7.2-node-browsers
77+
environment:
78+
PHP_CS_FIXER_FUTURE_MODE: 1
79+
working_directory: ~/api-platform/core
80+
steps:
81+
- checkout
82+
- *restore-composer-cache
83+
- *restore-php-cs-fixer-cache
84+
- *disable-xdebug-php-extension
85+
- *disable-php-memory-limit
86+
- *update-composer
87+
- run:
88+
name: Install PHP-CS-Fixer
89+
command: composer global require friendsofphp/php-cs-fixer:^2.12
90+
- *save-composer-cache-by-revision
91+
- *save-composer-cache-by-branch
92+
- run:
93+
name: Run PHP-CS-Fixer
94+
command: |-
95+
export PATH="$PATH:$HOME/.composer/vendor/bin"
96+
php-cs-fixer fix --dry-run --diff --ansi
97+
- *save-php-cs-fixer-cache-by-revision
98+
- *save-php-cs-fixer-cache-by-branch
99+
100+
phpstan:
101+
docker:
102+
- image: circleci/php:7.2-node-browsers
103+
working_directory: ~/api-platform/core
104+
steps:
105+
- checkout
106+
- *restore-composer-cache
107+
- *disable-xdebug-php-extension
108+
- *disable-php-memory-limit
109+
- *update-composer
110+
- *update-project-dependencies
111+
- run:
112+
name: Install PHPStan
113+
command: composer global require phpstan/phpstan:^0.8
114+
- *save-composer-cache-by-revision
115+
- *save-composer-cache-by-branch
116+
- run:
117+
name: Run PHPStan
118+
command: |-
119+
export PATH="$PATH:$HOME/.composer/vendor/bin"
120+
phpstan analyse -c phpstan.neon -l5 --ansi src tests
121+
122+
phpunit-coverage:
59123
docker:
60124
- image: circleci/php:7.2-node-browsers
61125
environment:
@@ -98,7 +162,7 @@ jobs:
98162
- *save-npm-cache-by-revision
99163
- *save-npm-cache-by-branch
100164

101-
behat-php-7.2-coverage:
165+
behat-coverage:
102166
docker:
103167
- image: circleci/php:7.2-node-browsers
104168
environment:
@@ -181,11 +245,15 @@ jobs:
181245

182246
workflows:
183247
version: 2
248+
lint:
249+
jobs:
250+
- php-cs-fixer
251+
- phpstan
184252
test-with-coverage:
185253
jobs:
186-
- phpunit-php-7.2-coverage
187-
- behat-php-7.2-coverage
254+
- phpunit-coverage
255+
- behat-coverage
188256
- merge-and-upload-coverage:
189257
requires:
190-
- phpunit-php-7.2-coverage
191-
- behat-php-7.2-coverage
258+
- phpunit-coverage
259+
- behat-coverage

.php_cs.dist

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,23 @@ return PhpCsFixer\Config::create()
4242
'location' => 'after_open',
4343
],
4444
'modernize_types_casting' => true,
45-
'no_extra_consecutive_blank_lines' => [
46-
'break',
47-
'continue',
48-
'curly_brace_block',
49-
'extra',
50-
'parenthesis_brace_block',
51-
'return',
52-
'square_brace_block',
53-
'throw',
54-
'use',
45+
'native_function_invocation' => [
46+
'include' => [
47+
'@compiler_optimized',
48+
],
49+
],
50+
'no_extra_blank_lines' => [
51+
'tokens' => [
52+
'break',
53+
'continue',
54+
'curly_brace_block',
55+
'extra',
56+
'parenthesis_brace_block',
57+
'return',
58+
'square_brace_block',
59+
'throw',
60+
'use',
61+
],
5562
],
5663
'no_useless_else' => true,
5764
'no_useless_return' => true,

.travis.yml

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ matrix:
1515
include:
1616
- php: '7.1'
1717
- php: '7.2'
18-
- php: '7.2'
19-
env: lint=1
2018
- php: '7.2'
2119
env: deps=low
2220
- php: '7.2'
@@ -39,12 +37,6 @@ matrix:
3937
before_install:
4038
- phpenv config-rm xdebug.ini || echo "xdebug not available"
4139
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
42-
- if [[ $lint = 1 ]]; then
43-
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.12.0/php-cs-fixer.phar;
44-
fi
45-
- if [[ $lint = 1 ]]; then
46-
composer global require --dev 'phpstan/phpstan:^0.8';
47-
fi
4840
- export PATH="$PATH:$HOME/.composer/vendor/bin"
4941

5042
install:
@@ -55,29 +47,13 @@ install:
5547
fi
5648

5749
script:
58-
- if [[ $lint != 1 ]]; then
59-
tests/Fixtures/app/console cache:clear;
60-
fi
61-
- if [[ $lint != 1 ]]; then
62-
vendor/bin/phpunit;
63-
fi
64-
- if [[ $lint != 1 ]]; then
65-
tests/Fixtures/app/console cache:clear;
66-
fi
50+
- tests/Fixtures/app/console cache:clear
51+
- vendor/bin/phpunit
52+
- tests/Fixtures/app/console cache:clear
6753
- if [[ $APP_ENV = 'postgres' ]]; then
6854
vendor/bin/behat --suite=postgres --format=progress;
69-
elif [[ $lint != 1 ]]; then
55+
else
7056
vendor/bin/behat --suite=default --format=progress;
7157
fi
72-
- if [[ $lint != 1 ]]; then
73-
tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json;
74-
fi
75-
- if [[ $lint != 1 ]]; then
76-
tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && npx swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml;
77-
fi
78-
- if [[ $lint = 1 ]]; then
79-
php php-cs-fixer.phar fix --dry-run --diff --no-ansi;
80-
fi
81-
- if [[ $lint = 1 ]]; then
82-
phpstan analyse -c phpstan.neon -l5 --ansi src tests;
83-
fi
58+
- tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json
59+
- tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && npx swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml

features/bootstrap/FeatureContext.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ public function thereAreDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string
380380
{
381381
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
382382

383-
if (in_array($bool, ['true', '1', 1], true)) {
383+
if (\in_array($bool, ['true', '1', 1], true)) {
384384
$bool = true;
385-
} elseif (in_array($bool, ['false', '0', 0], true)) {
385+
} elseif (\in_array($bool, ['false', '0', 0], true)) {
386386
$bool = false;
387387
} else {
388388
$expected = ['true', 'false', '1', '0'];
@@ -490,9 +490,9 @@ public function thereAreDummyObjectsWithDummyPrice(int $nb)
490490
*/
491491
public function thereAreDummyObjectsWithDummyBoolean(int $nb, string $bool)
492492
{
493-
if (in_array($bool, ['true', '1', 1], true)) {
493+
if (\in_array($bool, ['true', '1', 1], true)) {
494494
$bool = true;
495-
} elseif (in_array($bool, ['false', '0', 0], true)) {
495+
} elseif (\in_array($bool, ['false', '0', 0], true)) {
496496
$bool = false;
497497
} else {
498498
$expected = ['true', 'false', '1', '0'];
@@ -518,9 +518,9 @@ public function thereAreDummyObjectsWithDummyBoolean(int $nb, string $bool)
518518
*/
519519
public function thereAreDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bool)
520520
{
521-
if (in_array($bool, ['true', '1', 1], true)) {
521+
if (\in_array($bool, ['true', '1', 1], true)) {
522522
$bool = true;
523-
} elseif (in_array($bool, ['false', '0', 0], true)) {
523+
} elseif (\in_array($bool, ['false', '0', 0], true)) {
524524
$bool = false;
525525
} else {
526526
$expected = ['true', 'false', '1', '0'];
@@ -545,9 +545,9 @@ public function thereAreDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bo
545545
*/
546546
public function thereAreDummyObjectsWithRelationEmbeddedDummyBoolean(int $nb, string $bool)
547547
{
548-
if (in_array($bool, ['true', '1', 1], true)) {
548+
if (\in_array($bool, ['true', '1', 1], true)) {
549549
$bool = true;
550-
} elseif (in_array($bool, ['false', '0', 0], true)) {
550+
} elseif (\in_array($bool, ['false', '0', 0], true)) {
551551
$bool = false;
552552
} else {
553553
$expected = ['true', 'false', '1', '0'];

features/bootstrap/HydraContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ public function assertOperationNodeValueContains(string $nodeName, string $opera
142142
*/
143143
public function assertNbOperationsExist(int $nb, string $className)
144144
{
145-
Assert::assertEquals($nb, count($this->getOperations($className)));
145+
Assert::assertEquals($nb, \count($this->getOperations($className)));
146146
}
147147

148148
/**
149149
* @Then :nb properties are available for Hydra class :class
150150
*/
151151
public function assertNbPropertiesExist(int $nb, string $className)
152152
{
153-
Assert::assertEquals($nb, count($this->getProperties($className)));
153+
Assert::assertEquals($nb, \count($this->getProperties($className)));
154154
}
155155

156156
/**

features/bootstrap/JsonContext.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public function __construct(HttpCallResultPool $httpCallResultPool)
2626

2727
private function sortArrays($obj)
2828
{
29-
$isObject = is_object($obj);
29+
$isObject = \is_object($obj);
3030

3131
foreach ($obj as $key => $value) {
3232
if (null === $value || is_scalar($value)) {
3333
continue;
3434
}
3535

36-
if (is_array($value)) {
36+
if (\is_array($value)) {
3737
sort($value);
3838
}
3939

features/bootstrap/SwaggerContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function assertPropertyExist(string $propertyName, string $className)
9090
*/
9191
public function assertPropertyIsRequired(string $propertyName, string $className)
9292
{
93-
if (!in_array($propertyName, $this->getClassInfo($className)->required, true)) {
93+
if (!\in_array($propertyName, $this->getClassInfo($className)->required, true)) {
9494
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" should be required', $propertyName, $className));
9595
}
9696
}

tests/Bridge/Doctrine/Orm/Extension/PaginationExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ private function getPaginationExtensionResult(bool $partial = false, bool $legac
471471
$queryBuilderProphecy->getRootEntities()->willReturn([])->shouldBeCalled();
472472
$queryBuilderProphecy->getQuery()->willReturn($query)->shouldBeCalled();
473473
$queryBuilderProphecy->getDQLPart(Argument::that(function ($arg) {
474-
return in_array($arg, ['having', 'orderBy', 'join'], true);
474+
return \in_array($arg, ['having', 'orderBy', 'join'], true);
475475
}))->willReturn('')->shouldBeCalled();
476476
$queryBuilderProphecy->getMaxResults()->willReturn(42)->shouldBeCalled();
477477

tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function testAddResourceClassDirectories()
304304
return $arg;
305305
}
306306

307-
if (!in_array('foobar', $arg, true)) {
307+
if (!\in_array('foobar', $arg, true)) {
308308
throw new \Exception('"foobar" should be in "resource_class_directories"');
309309
}
310310

tests/DataProvider/ChainCollectionDataProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testGetCollectionNotSupported()
6969

7070
$collection = (new ChainCollectionDataProvider([$firstDataProvider->reveal()]))->getCollection('notfound', 'op');
7171

72-
$this->assertTrue(is_array($collection) || $collection instanceof \Traversable);
72+
$this->assertTrue(\is_array($collection) || $collection instanceof \Traversable);
7373
$this->assertEmpty($collection);
7474
}
7575

0 commit comments

Comments
 (0)