Skip to content

Commit 8c0664a

Browse files
teohhanhuidunglas
authored andcommitted
Make the CS stricter; fix some bugs / issues (#1007)
1 parent 1c78361 commit 8c0664a

File tree

313 files changed

+702
-72
lines changed

Some content is hidden

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

313 files changed

+702
-72
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: 1 addition & 1 deletion
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

2828
install:

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:

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
}

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;

0 commit comments

Comments
 (0)