Skip to content

Commit e885b67

Browse files
committed
Update PhpCS rules
1 parent 5356de0 commit e885b67

38 files changed

+70
-147
lines changed

.php_cs.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ return PhpCsFixer\Config::create()
1010
->setRules(
1111
[
1212
'@Symfony' => true,
13+
'@PHP71Migration' => true,
14+
'@PHP74Migration:risky' => true,
1315
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
1416
'general_phpdoc_annotation_remove' => ['author', 'category', 'copyright', 'created', 'license', 'package', 'since', 'subpackage', 'version'],
1517
'fully_qualified_strict_types' => true,
@@ -19,7 +21,9 @@ return PhpCsFixer\Config::create()
1921
'global_namespace_import' => ['import_functions' => true, 'import_classes' => true, 'import_constants' => true],
2022
'phpdoc_summary' => false,
2123
'hash_to_slash_comment' => false,
22-
'single_line_comment_style' => false
24+
'single_line_comment_style' => false,
25+
'phpdoc_no_alias_tag' => ['type' => 'var'],
26+
'no_mixed_echo_print' => ['use' => 'echo'],
2327
]
2428
)
2529
->setFinder($finder)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"test -f phpbench.phar || wget https://github.com/phpbench/phpbench/releases/download/1.0.0-alpha7/phpbench.phar -O phpbench.phar",
8181
"@php phpbench.phar run -l dots --ansi -vvv --report='generator: \"table\", cols: [\"benchmark\", \"subject\", \"params\", \"best\", \"mean\", \"mode\", \"worst\", \"diff\"], break: [\"benchmark\"], sort: {mean: \"asc\"}'"
8282
],
83-
"install-cs": "test -f php-cs-fixer.phar || wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -O php-cs-fixer.phar",
83+
"install-cs": "test -f php-cs-fixer.phar || wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.18.7/php-cs-fixer.phar -O php-cs-fixer.phar",
8484
"fix-cs": [
8585
"@install-cs",
8686
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi"

src/Config/ObjectTypeDefinition.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public function getDefinition(): ArrayNodeDefinition
5050
private function treatFieldsDefaultAccess(ArrayNodeDefinition $node): void
5151
{
5252
$node->validate()
53-
->ifTrue(function ($v) {
54-
return array_key_exists('fieldsDefaultAccess', $v) && null !== $v['fieldsDefaultAccess'];
55-
})
53+
->ifTrue(fn ($v) => array_key_exists('fieldsDefaultAccess', $v) && null !== $v['fieldsDefaultAccess'])
5654
->then(function ($v) {
5755
foreach ($v['fields'] as &$field) {
5856
if (array_key_exists('access', $field) && null !== $field['access']) {

src/Config/Parser/AnnotationParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class AnnotationParser extends MetadataParser
1717
{
18-
const METADATA_FORMAT = '@%s';
18+
public const METADATA_FORMAT = '@%s';
1919

2020
protected static ?AnnotationReader $annotationReader = null;
2121

src/Config/Parser/AttributeParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class AttributeParser extends MetadataParser
1616
{
17-
const METADATA_FORMAT = '#[%s]';
17+
public const METADATA_FORMAT = '#[%s]';
1818

1919
public static function getMetadatas(Reflector $reflector): array
2020
{

src/Config/Parser/MetadataParser/MetadataParser.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444

4545
abstract class MetadataParser implements PreParserInterface
4646
{
47-
const ANNOTATION_NAMESPACE = 'Overblog\GraphQLBundle\Annotation\\';
48-
const METADATA_FORMAT = '%s';
47+
public const ANNOTATION_NAMESPACE = 'Overblog\GraphQLBundle\Annotation\\';
48+
public const METADATA_FORMAT = '%s';
4949

5050
private static ClassesTypesMap $map;
5151
private static array $typeGuessers = [];
@@ -233,7 +233,7 @@ private static function classMetadatasToGQLConfiguration(
233233

234234
if (null !== $gqlType) {
235235
if (!$gqlName) {
236-
$gqlName = isset($classMetadata->name) ? $classMetadata->name : $reflectionClass->getShortName();
236+
$gqlName = !empty($classMetadata->name) ? $classMetadata->name : $reflectionClass->getShortName();
237237
}
238238

239239
if ($preProcess) {
@@ -346,9 +346,7 @@ private static function graphQLTypeConfigFromAnnotation(ReflectionClass $reflect
346346

347347
$buildersAnnotations = array_merge(self::getMetadataMatching($metadatas, Metadata\FieldsBuilder::class), $typeAnnotation->builders);
348348
if (!empty($buildersAnnotations)) {
349-
$typeConfiguration['builders'] = array_map(function ($fieldsBuilderAnnotation) {
350-
return ['builder' => $fieldsBuilderAnnotation->name, 'builderConfig' => $fieldsBuilderAnnotation->config];
351-
}, $buildersAnnotations);
349+
$typeConfiguration['builders'] = array_map(fn ($fieldsBuilderAnnotation) => ['builder' => $fieldsBuilderAnnotation->name, 'builderConfig' => $fieldsBuilderAnnotation->config], $buildersAnnotations);
352350
}
353351

354352
if (isset($typeAnnotation->isTypeOf)) {
@@ -593,7 +591,7 @@ private static function getTypeFieldConfigurationFromReflector(ReflectionClass $
593591
if (is_string($fieldMetadata->argsBuilder)) {
594592
$fieldConfiguration['argsBuilder'] = ['builder' => $fieldMetadata->argsBuilder, 'config' => []];
595593
} elseif (is_array($fieldMetadata->argsBuilder)) {
596-
list($builder, $builderConfig) = $fieldMetadata->argsBuilder;
594+
[$builder, $builderConfig] = $fieldMetadata->argsBuilder;
597595
$fieldConfiguration['argsBuilder'] = ['builder' => $builder, 'config' => $builderConfig];
598596
} else {
599597
throw new InvalidArgumentException(sprintf('The attribute "argsBuilder" on metadata %s defined on "%s" must be a string or an array where first index is the builder name and the second is the config.', static::formatMetadata($fieldMetadataName), $reflector->getName()));
@@ -608,7 +606,7 @@ private static function getTypeFieldConfigurationFromReflector(ReflectionClass $
608606
$fieldConfiguration['builder'] = $fieldMetadata->fieldBuilder;
609607
$fieldConfiguration['builderConfig'] = [];
610608
} elseif (is_array($fieldMetadata->fieldBuilder)) {
611-
list($builder, $builderConfig) = $fieldMetadata->fieldBuilder;
609+
[$builder, $builderConfig] = $fieldMetadata->fieldBuilder;
612610
$fieldConfiguration['builder'] = $builder;
613611
$fieldConfiguration['builderConfig'] = $builderConfig ?: [];
614612
} else {
@@ -929,7 +927,7 @@ private static function guessType(ReflectionClass $reflectionClass, Reflector $r
929927
}
930928
}
931929

932-
throw new TypeGuessingException(join("\n", $errors));
930+
throw new TypeGuessingException(implode("\n", $errors));
933931
}
934932

935933
/**

src/Config/Processor/InheritanceProcessor.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ public static function process(array $configs): array
3939

4040
private static function removedDecorators(array $configs): array
4141
{
42-
return array_filter($configs, function ($config) {
43-
return !isset($config['decorator']) || true !== $config['decorator'];
44-
});
42+
return array_filter($configs, fn ($config) => !isset($config['decorator']) || true !== $config['decorator']);
4543
}
4644

4745
private static function processConfigsHeirs(array $configs): array

src/Definition/Type/CustomScalarType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(array $config = [])
1919
$config['name'] = $config['name'] ?? uniqid('CustomScalar');
2020
parent::__construct($config);
2121

22-
$this->config['scalarType'] = isset($this->config['scalarType']) ? $this->config['scalarType'] : null;
22+
$this->config['scalarType'] = $this->config['scalarType'] ?? null;
2323
}
2424

2525
/**

src/DependencyInjection/Compiler/ConfigParserPass.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ private function parseTypeConfigFiles(string $type, iterable $files, ContainerBu
156156
private function checkTypesDuplication(array $typeConfigs): void
157157
{
158158
$types = array_merge(...array_map('array_keys', $typeConfigs));
159-
$duplications = array_keys(array_filter(array_count_values($types), function ($count) {
160-
return $count > 1;
161-
}));
159+
$duplications = array_keys(array_filter(array_count_values($types), fn ($count) => $count > 1));
162160
if (!empty($duplications)) {
163161
throw new ForbiddenOverwriteException(sprintf(
164162
'Types (%s) cannot be overwritten. See inheritance doc section for more details.',

src/DependencyInjection/Compiler/TaggedServiceMappingPass.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ private static function resolveAttributes(array $attributes, string $id, bool $w
9696
private function autowireSolutionImplementingContainerAwareInterface(Definition $solutionDefinition, bool $isGenerated): void
9797
{
9898
$methods = array_map(
99-
function ($methodCall) {
100-
return $methodCall[0];
101-
},
99+
fn ($methodCall) => $methodCall[0],
102100
$solutionDefinition->getMethodCalls()
103101
);
104102
if (

0 commit comments

Comments
 (0)