Skip to content

Commit 0ad3439

Browse files
vincentchalamonalanpoulain
authored andcommitted
fix: rector
1 parent d1ca5cb commit 0ad3439

File tree

233 files changed

+1332
-1304
lines changed

Some content is hidden

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

233 files changed

+1332
-1304
lines changed

phpstan.neon.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ parameters:
5353
message: '#is never written, only read.#'
5454
paths:
5555
- tests/Fixtures/TestBundle/Document/
56+
-
57+
message: '#Parameter \#1 \$constraint of method#'
58+
paths:
59+
- tests/Symfony/Validator/Metadata/Property/Restriction/
60+
-
61+
message: '#expects ApiPlatform\\Metadata\\GraphQl\\Operation\|null, ApiPlatform\\Metadata\\Operation given#'
62+
paths:
63+
- tests/GraphQl/Resolver/Factory/
5664
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy<(\\?[a-zA-Z0-9_]+)+>::\$[a-zA-Z0-9_]+#'
5765
# https://github.com/willdurand/Negotiation/issues/89#issuecomment-513283286
5866
-

rector.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,38 @@
1313

1414
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
1515
use Rector\Config\RectorConfig;
16+
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
17+
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
18+
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
19+
use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
20+
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector;
1621
use Rector\PHPUnit\Set\PHPUnitSetList;
22+
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
1723
use Rector\Set\ValueObject\LevelSetList;
1824
use Rector\Set\ValueObject\SetList;
25+
use Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector;
1926

2027
return static function (RectorConfig $rectorConfig): void {
2128
$rectorConfig->paths([
2229
__DIR__.'/src',
2330
__DIR__.'/tests',
2431
]);
2532
$rectorConfig->skip([
26-
// "Class PHPUnit\Framework\* not found."
27-
__DIR__.'/src/Symfony/Bundle/Test',
2833
__DIR__.'/tests/Fixtures/app/var',
29-
__DIR__.'/tests/ProphecyTrait.php',
34+
AddSeeTestAnnotationRector::class,
35+
ArrayShapeFromConstantArrayReturnRector::class,
36+
NullToStrictStringFuncCallArgRector::class,
37+
ReadOnlyPropertyRector::class => [
38+
__DIR__.'/tests/Fixtures/TestBundle/Document',
39+
__DIR__.'/tests/Fixtures/TestBundle/Entity',
40+
],
41+
RemoveParentCallWithoutParentRector::class => [
42+
__DIR__.'/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestrictionTest.php',
43+
],
44+
RenameMethodRector::class => [
45+
__DIR__.'/tests/Symfony/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestrictionTest.php',
46+
],
47+
AssertEqualsToSameRector::class,
3048
]);
3149
$rectorConfig->phpstanConfig(__DIR__.'/phpstan.neon.dist');
3250
$rectorConfig->importNames();

src/Doctrine/Odm/Filter/AbstractFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function denormalizePropertyName($property): string
9393
return $property;
9494
}
9595

96-
return implode('.', array_map([$this->nameConverter, 'denormalize'], explode('.', (string) $property)));
96+
return implode('.', array_map($this->nameConverter->denormalize(...), explode('.', (string) $property)));
9797
}
9898

9999
protected function normalizePropertyName($property): string
@@ -102,6 +102,6 @@ protected function normalizePropertyName($property): string
102102
return $property;
103103
}
104104

105-
return implode('.', array_map([$this->nameConverter, 'normalize'], explode('.', (string) $property)));
105+
return implode('.', array_map($this->nameConverter->normalize(...), explode('.', (string) $property)));
106106
}
107107
}

src/Doctrine/Odm/Filter/SearchFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function filterProperty(string $property, $value, Builder $aggregation
102102

103103
if ($metadata->hasField($field) && !$metadata->hasAssociation($field)) {
104104
if ('id' === $field) {
105-
$values = array_map([$this, 'getIdFromValue'], $values);
105+
$values = array_map($this->getIdFromValue(...), $values);
106106
}
107107

108108
if (!$this->hasValidValues($values, $this->getDoctrineFieldType($property, $resourceClass))) {
@@ -123,7 +123,7 @@ protected function filterProperty(string $property, $value, Builder $aggregation
123123
return;
124124
}
125125

126-
$values = array_map([$this, 'getIdFromValue'], $values);
126+
$values = array_map($this->getIdFromValue(...), $values);
127127

128128
$associationResourceClass = $metadata->getAssociationTargetClass($field);
129129
$associationFieldIdentifier = $metadata->getIdentifierFieldNames()[0];

src/Doctrine/Orm/Filter/AbstractFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function denormalizePropertyName($property): string
8585
return $property;
8686
}
8787

88-
return implode('.', array_map([$this->nameConverter, 'denormalize'], explode('.', (string) $property)));
88+
return implode('.', array_map($this->nameConverter->denormalize(...), explode('.', (string) $property)));
8989
}
9090

9191
protected function normalizePropertyName($property): string
@@ -94,6 +94,6 @@ protected function normalizePropertyName($property): string
9494
return $property;
9595
}
9696

97-
return implode('.', array_map([$this->nameConverter, 'normalize'], explode('.', (string) $property)));
97+
return implode('.', array_map($this->nameConverter->normalize(...), explode('.', (string) $property)));
9898
}
9999
}

src/Doctrine/Orm/Filter/SearchFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
9999

100100
if ($metadata->hasField($field)) {
101101
if ('id' === $field) {
102-
$values = array_map([$this, 'getIdFromValue'], $values);
102+
$values = array_map($this->getIdFromValue(...), $values);
103103
}
104104

105105
if (!$this->hasValidValues($values, $this->getDoctrineFieldType($property, $resourceClass))) {
@@ -120,7 +120,7 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
120120
return;
121121
}
122122

123-
$values = array_map([$this, 'getIdFromValue'], $values);
123+
$values = array_map($this->getIdFromValue(...), $values);
124124

125125
$associationResourceClass = $metadata->getAssociationTargetClass($field);
126126
$associationFieldIdentifier = $metadata->getIdentifierFieldNames()[0];
@@ -209,7 +209,7 @@ protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuild
209209
}
210210

211211
$queryBuilder->andWhere($queryBuilder->expr()->orX(...$ors));
212-
array_walk($parameters, [$queryBuilder, 'setParameter']);
212+
array_walk($parameters, $queryBuilder->setParameter(...));
213213
}
214214

215215
/**

src/Elasticsearch/Filter/AbstractSearchFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function apply(array $clauseBody, string $resourceClass, ?Operation $oper
5858
}
5959

6060
if ($hasAssociation || $this->isIdentifier($nestedResourceClass, $nestedProperty, $operation)) {
61-
$values = array_map([$this, 'getIdentifierValue'], $values, array_fill(0, \count($values), $nestedProperty));
61+
$values = array_map($this->getIdentifierValue(...), $values, array_fill(0, \count($values), $nestedProperty));
6262
}
6363

6464
if (!$this->hasValidValues($values, $type)) {

src/Elasticsearch/Filter/OrderFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class OrderFilter extends AbstractFilter implements SortFilterInterface
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceClassResolverInterface $resourceClassResolver, ?NameConverterInterface $nameConverter = null, private string $orderParameterName = 'order', ?array $properties = null)
36+
public function __construct(PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, ResourceClassResolverInterface $resourceClassResolver, ?NameConverterInterface $nameConverter = null, private readonly string $orderParameterName = 'order', ?array $properties = null)
3737
{
3838
parent::__construct($propertyNameCollectionFactory, $propertyMetadataFactory, $resourceClassResolver, $nameConverter, $properties);
3939
}

src/GraphQl/Action/EntrypointAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function __invoke(Request $request): Response
6565
$executionResult = $this->executor
6666
->executeQuery($this->schemaBuilder->getSchema(), $query, null, null, $variables, $operationName)
6767
->setErrorsHandler($this->errorHandler)
68-
->setErrorFormatter([$this->normalizer, 'normalize']);
68+
->setErrorFormatter($this->normalizer->normalize(...));
6969
} catch (\Exception $exception) {
7070
$executionResult = (new ExecutionResult(null, [new Error($exception->getMessage(), null, null, [], null, $exception)]))
7171
->setErrorsHandler($this->errorHandler)
72-
->setErrorFormatter([$this->normalizer, 'normalize']);
72+
->setErrorFormatter($this->normalizer->normalize(...));
7373
}
7474

7575
return new JsonResponse($executionResult->toArray($this->debug));

src/GraphQl/Serializer/ItemNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function supportsDenormalization(mixed $data, string $type, string $forma
113113
/**
114114
* {@inheritdoc}
115115
*/
116-
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false): array|bool
116+
protected function getAllowedAttributes(string|object $classOrObject, array $context, bool $attributesAsString = false): array|bool
117117
{
118118
$allowedAttributes = parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
119119

0 commit comments

Comments
 (0)