Skip to content

Commit 020dbf2

Browse files
committed
Merge branch '2.0'
2 parents 219da4f + 502748a commit 020dbf2

File tree

324 files changed

+1853
-322
lines changed

Some content is hidden

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

324 files changed

+1853
-322
lines changed

.php_cs.dist

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,43 @@ $finder = PhpCsFixer\Finder::create()
66
;
77

88
return PhpCsFixer\Config::create()
9+
->setRiskyAllowed(true)
910
->setRules([
1011
'@Symfony' => true,
12+
'@Symfony:risky' => true,
13+
'array_syntax' => [
14+
'syntax' => 'short',
15+
],
16+
'braces' => [
17+
'allow_single_line_closure' => true,
18+
],
19+
'declare_strict_types' => true,
20+
'modernize_types_casting' => true,
21+
// 'native_function_invocation' => true,
22+
'no_extra_consecutive_blank_lines' => [
23+
'break',
24+
'continue',
25+
'curly_brace_block',
26+
'extra',
27+
'parenthesis_brace_block',
28+
'return',
29+
'square_brace_block',
30+
'throw',
31+
'use',
32+
],
33+
'no_unreachable_default_argument_value' => true,
34+
'no_useless_else' => true,
35+
'no_useless_return' => true,
1136
'ordered_imports' => true,
37+
// 'phpdoc_add_missing_param_annotation' => [
38+
// 'only_untyped' => false,
39+
// ],
1240
'phpdoc_order' => true,
13-
'array_syntax' => array('syntax' => 'short'),
41+
'psr4' => true,
42+
'semicolon_after_instruction' => true,
43+
'strict_comparison' => true,
44+
'strict_param' => true,
45+
'ternary_to_null_coalescing' => true,
1446
])
1547
->setFinder($finder)
1648
;

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_install:
2222
- if [[ $coverage = 1 ]]; then mkdir -p build/logs build/cov; fi
2323
- if [[ $coverage = 1 ]]; then wget https://phar.phpunit.de/phpcov.phar; fi
2424
- if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi
25-
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.0.0/php-cs-fixer.phar; fi
25+
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.1.2/php-cs-fixer.phar; fi
2626
- export PATH="$PATH:$HOME/.composer/vendor/bin"
2727
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
2828

@@ -32,11 +32,11 @@ install:
3232
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi
3333

3434
script:
35-
- if [[ $coverage = 1 ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov; else vendor/bin/phpunit; fi
36-
- if [[ $coverage = 1 ]]; then for feature in $(ls -d features/*/ | cut -f2 -d'/' | grep -v bootstrap); do FEATURE=$feature phpdbg -qrr vendor/bin/behat --profile coverage features/$feature; done; else vendor/bin/behat; fi
35+
- if [[ $coverage = 1 ]]; then phpdbg -qrr vendor/bin/phpunit --colors=never --coverage-php build/cov/coverage-phpunit.cov; else vendor/bin/phpunit --colors=never; fi
36+
- if [[ $coverage = 1 ]]; then for feature in $(ls -d features/*/ | cut -f2 -d'/' | grep -v bootstrap); do FEATURE=$feature phpdbg -qrr vendor/bin/behat --profile coverage features/$feature --no-colors; done; else vendor/bin/behat --no-colors; fi
3737
- if [[ $coverage = 1 ]]; then phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov; fi
3838
- tests/Fixtures/app/console api:swagger:export > swagger.json && swagger validate swagger.json && rm swagger.json
39-
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff; fi
39+
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff --no-ansi; fi
4040

4141
after_success:
4242
- if [[ $coverage = 1 ]]; then travis_retry php coveralls.phar; fi

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 2.0.7
4+
5+
* [security] Hide error's message in prod mode when a 500 error occurs (Api Problem format)
6+
* Fix sorting when eager loading is used
7+
* Allow eager loading when using composite identifiers
8+
* Don't use automatic eager loading when disabled in the config
9+
* Use `declare(strict_types=1)` and improve coding standards
10+
* Automatically refresh routes in dev mode when a resource is created or deleted
11+
312
## 2.0.6
413

514
* Correct the XML Schema type generated for floats in the Hydra documentation

behat.yml renamed to behat.yml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ default:
2020
sessions:
2121
default:
2222
symfony2: ~
23-
'Sanpi\Behatch\Extension': ~
23+
'Behatch\Extension': ~
2424

2525
coverage:
2626
suites:

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"psr/cache": "^1.0",
2020
"symfony/http-foundation": "^2.7 || ^3.0",
2121
"symfony/http-kernel": "^2.7 || ^3.0",
22+
"symfony/property-access": "^2.7 || ^3.0",
2223
"symfony/property-info": "^3.1",
2324
"symfony/serializer": "^3.1",
2425
"willdurand/negotiation": "^2.0.3"
@@ -33,7 +34,7 @@
3334
"doctrine/doctrine-bundle": "^1.6.3",
3435
"doctrine/orm": "^2.5",
3536
"doctrine/annotations": "^1.2",
36-
"friendsofsymfony/user-bundle": "^2.0@dev",
37+
"friendsofsymfony/user-bundle": "^2.0",
3738
"nelmio/api-doc-bundle": "^2.11.2",
3839
"php-mock/php-mock-phpunit": "^1.1",
3940
"phpdocumentor/reflection-docblock": "^3.0",
@@ -47,13 +48,12 @@
4748
"symfony/dependency-injection": "^2.7 || ^3.0",
4849
"symfony/doctrine-bridge": "^2.8 || ^3.0",
4950
"symfony/expression-language": "^2.8 || ^3.0",
50-
"symfony/phpunit-bridge": "^2.7 || ^3.0",
51-
"symfony/security": "^2.7 || ^3.0",
52-
"symfony/templating": "^2.7 || ^3.0",
53-
"symfony/validator": "^2.7 || ^3.0",
5451
"symfony/finder": "^2.7 || ^3.0",
5552
"symfony/framework-bundle": "^3.1",
56-
"symfony/twig-bundle": "^2.8 || ^3.1"
53+
"symfony/phpunit-bridge": "^2.7 || ^3.0",
54+
"symfony/security": "^2.7 || ^3.0",
55+
"symfony/twig-bundle": "^2.8 || ^3.1",
56+
"symfony/validator": "^2.7 || ^3.0"
5757
},
5858
"suggest": {
5959
"friendsofsymfony/user-bundle": "To use the FOSUserBundle bridge.",

features/bootstrap/CoverageContext.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
use Behat\Behat\Context\Context;
1315
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
1416
use SebastianBergmann\CodeCoverage\CodeCoverage;

features/bootstrap/FeatureContext.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeItem;
1315
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeLabel;
1416
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\CompositeRelation;

features/bootstrap/HydraContext.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
use Behat\Behat\Context\Context;
1315
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
1416
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
@@ -235,7 +237,7 @@ private function getOperations($className)
235237
{
236238
$classInfos = $this->getClassInfos($className);
237239

238-
return isset($classInfos->{'hydra:supportedOperation'}) ? $classInfos->{'hydra:supportedOperation'} : [];
240+
return $classInfos->{'hydra:supportedOperation'} ?? [];
239241
}
240242

241243
/**
@@ -251,7 +253,7 @@ private function getProperties($className)
251253
{
252254
$classInfos = $this->getClassInfos($className);
253255

254-
return isset($classInfos->{'hydra:supportedProperty'}) ? $classInfos->{'hydra:supportedProperty'} : [];
256+
return $classInfos->{'hydra:supportedProperty'} ?? [];
255257
}
256258

257259
/**

features/bootstrap/SwaggerContext.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
use Behat\Behat\Context\Context;
1315
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
1416
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
@@ -132,7 +134,7 @@ public function assertPropertyExist($propertyName, $className)
132134
public function assertPropertyIsRequired(string $propertyName, string $className)
133135
{
134136
$classInfo = $this->getClassInfos($className);
135-
if (!in_array($propertyName, $classInfo->required)) {
137+
if (!in_array($propertyName, $classInfo->required, true)) {
136138
throw new \Exception(sprintf('Property "%s" of class "%s" should be required', $propertyName, $className));
137139
}
138140
}

features/hal/problem.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Feature: Error handling valid according to RFC 7807 (application/problem+json)
33
As a client software developer
44
I need to retrieve an RFC 7807 compliant serialization of errors
55

6+
@createSchema
67
Scenario: Get an error
78
When I add "Content-Type" header equal to "application/json"
89
And I add "Accept" header equal to "application/json"
@@ -28,6 +29,7 @@ Feature: Error handling valid according to RFC 7807 (application/problem+json)
2829
}
2930
"""
3031

32+
@dropSchema
3133
Scenario: Get an error during deserialization of simple relation
3234
When I add "Content-Type" header equal to "application/json"
3335
And I add "Accept" header equal to "application/json"

phpunit.xml.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.6/phpunit.xsd"
66
backupGlobals="false"
77
bootstrap="tests/Fixtures/app/bootstrap.php"
8-
colors="true">
8+
colors="true"
9+
>
910
<php>
11+
<ini name="error_reporting" value="-1" />
12+
<ini name="memory_limit" value="-1" />
1013
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
1114
</php>
1215

src/Action/EntrypointAction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Action;
1315

1416
use ApiPlatform\Core\Api\Entrypoint;

src/Action/ExceptionAction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Action;
1315

1416
use ApiPlatform\Core\Util\ErrorFormatGuesser;

src/Action/PlaceholderAction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Action;
1315

1416
/**

src/Annotation/ApiProperty.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Annotation;
1315

1416
/**

src/Annotation/ApiResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Annotation;
1315

1416
/**

src/Api/Entrypoint.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;

src/Api/FilterCollection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
/**

src/Api/FilterInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
/**

src/Api/IriConverterInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
use ApiPlatform\Core\Exception\InvalidArgumentException;

src/Api/OperationMethodResolverInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
use ApiPlatform\Core\Exception\RuntimeException;

src/Api/ResourceClassResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
use ApiPlatform\Core\DataProvider\PaginatorInterface;

src/Api/ResourceClassResolverInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
use ApiPlatform\Core\Exception\InvalidArgumentException;

src/Api/UrlGeneratorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Api;
1315

1416
/**

src/Bridge/Doctrine/EventListener/WriteListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Bridge\Doctrine\EventListener;
1315

1416
use Doctrine\Common\Persistence\ManagerRegistry;
@@ -58,7 +60,6 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5860
case Request::METHOD_POST:
5961
$objectManager->persist($controllerResult);
6062
break;
61-
6263
case Request::METHOD_DELETE:
6364
$objectManager->remove($controllerResult);
6465
$event->setControllerResult(null);

src/Bridge/Doctrine/Orm/CollectionDataProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12+
declare(strict_types=1);
13+
1214
namespace ApiPlatform\Core\Bridge\Doctrine\Orm;
1315

1416
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;

0 commit comments

Comments
 (0)