Skip to content

Commit 79bfe04

Browse files
authored
Merge pull request #2003 from soyuka/merge-2.2
Merge 2.2
2 parents d2250c1 + 5cb8cb3 commit 79bfe04

File tree

71 files changed

+579
-568
lines changed

Some content is hidden

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

71 files changed

+579
-568
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: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$header = <<<'HEADER'
46
This file is part of the API Platform project.
57
@@ -18,13 +20,7 @@ return PhpCsFixer\Config::create()
1820
->setRiskyAllowed(true)
1921
->setRules([
2022
'@DoctrineAnnotation' => true,
21-
'doctrine_annotation_array_assignment' => [
22-
'operator' => '=',
23-
],
24-
'doctrine_annotation_spaces' => [
25-
'after_array_assignments_equals' => false,
26-
'before_array_assignments_equals' => false,
27-
],
23+
'@PHPUnit60Migration:risky' => true,
2824
'@Symfony' => true,
2925
'@Symfony:risky' => true,
3026
'array_syntax' => [
@@ -34,29 +30,39 @@ return PhpCsFixer\Config::create()
3430
'allow_single_line_closure' => true,
3531
],
3632
'declare_strict_types' => true,
33+
'doctrine_annotation_array_assignment' => [
34+
'operator' => '=',
35+
],
36+
'doctrine_annotation_spaces' => [
37+
'after_array_assignments_equals' => false,
38+
'before_array_assignments_equals' => false,
39+
],
3740
'header_comment' => [
3841
'header' => $header,
3942
'location' => 'after_open',
4043
],
4144
'modernize_types_casting' => true,
42-
// 'native_function_invocation' => true,
43-
'no_extra_consecutive_blank_lines' => [
44-
'break',
45-
'continue',
46-
'curly_brace_block',
47-
'extra',
48-
'parenthesis_brace_block',
49-
'return',
50-
'square_brace_block',
51-
'throw',
52-
'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+
],
5362
],
5463
'no_useless_else' => true,
5564
'no_useless_return' => true,
5665
'ordered_imports' => true,
57-
// 'phpdoc_add_missing_param_annotation' => [
58-
// 'only_untyped' => false,
59-
// ],
6066
'phpdoc_order' => true,
6167
'psr4' => true,
6268
'semicolon_after_instruction' => 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.8.4/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
}

features/main/circular_reference.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ Feature: Circular references handling
6060
"@type": "CircularReference",
6161
"parent": "/circular_references/1",
6262
"children": [
63-
"/circular_references/1"
63+
"/circular_references/1",
64+
"/circular_references/2"
6465
]
6566
},
6667
"children": []

src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ private function apply(bool $collection, QueryBuilder $queryBuilder, QueryNameGe
107107
$context += $this->getNormalizationContext($context['resource_class'] ?? $resourceClass, $contextType, $options);
108108
}
109109

110+
if (empty($context[AbstractNormalizer::GROUPS]) && !isset($context[AbstractNormalizer::ATTRIBUTES])) {
111+
return;
112+
}
113+
110114
$this->joinRelations($queryBuilder, $queryNameGenerator, $resourceClass, $forceEager, $fetchPartial, $queryBuilder->getRootAliases()[0], $options, $context);
111115
}
112116

src/Bridge/Symfony/Bundle/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function collect(Request $request, Response $response, \Exception $except
4646
$filters = [];
4747
foreach ($resourceMetadata ? $resourceMetadata->getAttribute('filters', []) : [] as $id) {
4848
if ($this->filterLocator->has($id)) {
49-
$filters[$id] = get_class($this->filterLocator->get($id));
49+
$filters[$id] = \get_class($this->filterLocator->get($id));
5050
continue;
5151
}
5252

0 commit comments

Comments
 (0)