Skip to content

Commit bedb7fa

Browse files
committed
run rector with deadCode to true
1 parent f6d9764 commit bedb7fa

File tree

111 files changed

+151
-321
lines changed

Some content is hidden

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

111 files changed

+151
-321
lines changed

phpstan.neon.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ parameters:
7676
paths:
7777
- tests/Fixtures/TestBundle/Document/
7878
- src/Metadata/Tests/Fixtures/ApiResource/
79+
- tests/Fixtures/TestBundle/Entity/FooEmbeddable.php
7980
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy<(\\?[a-zA-Z0-9_]+)+>::\$[a-zA-Z0-9_]+#'
8081
# https://github.com/phpstan/phpstan-symfony/issues/76
8182
-
8283
message: '#Service "test" is not registered in the container\.#'
8384
path: src/GraphQl/Tests/Type/TypesContainerTest.php
84-
85+
-
86+
message: '#Constant.*is unused\.#'
87+
path: src/HttpCache/SouinPurger.php
8588
# Expected, due to backward compatibility
8689
- '#Method GraphQL\\Type\\Definition\\WrappingType::getWrappedType\(\) invoked with 1 parameter, 0 required\.#'
8790
- '#Access to an undefined property GraphQL\\Type\\Definition\\NamedType&GraphQL\\Type\\Definition\\Type::\$name\.#'

rector.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
declare(strict_types=1);
1313

1414
use Rector\Config\RectorConfig;
15+
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
16+
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPublicMethodParameterRector;
1517

1618
return RectorConfig::configure()
1719
->withPaths([
@@ -30,11 +32,18 @@
3032
__DIR__.'/tests/Fixtures/app/config/reference.php',
3133
__DIR__.'/src/Symfony/Bundle/DependencyInjection/Configuration.php',
3234
__DIR__.'/tests/Fixer/SymfonyServiceClassConstantFixer.php',
35+
RemoveUnusedPromotedPropertyRector::class => [
36+
__DIR__.'/tests/Fixtures/TestBundle/Filter/SearchTextAndDateFilter.php',
37+
__DIR__.'/tests/Fixtures/TestBundle/Filter/ODMSearchTextAndDateFilter.php',
38+
],
39+
RemoveUnusedPublicMethodParameterRector::class => [
40+
__DIR__.'/src/GraphQl/Action/GraphiQlAction.php',
41+
],
3342
])
3443
// uncomment to reach your current PHP version
3544
// ->withPhpSets()
3645
->withPreparedSets(
3746
typeDeclarations: true,
47+
deadCode: true,
3848
)
39-
->withDeadCodeLevel(0)
4049
->withCodeQualityLevel(0);

src/Doctrine/Common/Messenger/DispatchTrait.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ trait DispatchTrait
2424
{
2525
private ?MessageBusInterface $messageBus;
2626

27-
/**
28-
* @param object|Envelope $message
29-
*/
3027
private function dispatch(object $message): Envelope
3128
{
3229
if (!$this->messageBus instanceof MessageBusInterface) {

src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/EmbeddableDummy.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ public static function staticMethod(): void
6060
{
6161
}
6262

63-
public function __construct()
64-
{
65-
}
66-
6763
public function getDummyName(): ?string
6864
{
6965
return $this->dummyName;

src/Doctrine/Odm/Extension/PaginationExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
4747
return;
4848
}
4949

50-
if (($context['graphql_operation_name'] ?? false) && !$this->pagination->isGraphQlEnabled($operation, $context)) {
50+
if (($context['graphql_operation_name'] ?? false) && !$this->pagination->isGraphQlEnabled($operation)) {
5151
return;
5252
}
5353

@@ -95,7 +95,7 @@ public function applyToCollection(Builder $aggregationBuilder, string $resourceC
9595
public function supportsResult(string $resourceClass, ?Operation $operation = null, array $context = []): bool
9696
{
9797
if ($context['graphql_operation_name'] ?? false) {
98-
return $this->pagination->isGraphQlEnabled($operation, $context);
98+
return $this->pagination->isGraphQlEnabled($operation);
9999
}
100100

101101
return $this->pagination->isEnabled($operation, $context);

src/Doctrine/Odm/Metadata/Resource/DoctrineMongoDbOdmParameterResourceMetadataCollectionFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
4848

4949
if ($operations) {
5050
foreach ($operations as $operationName => $operation) {
51-
$operation = $this->enrichOperation($operation, $resourceClass);
51+
$operation = $this->enrichOperation($operation);
5252
$operations->add($operationName, $operation);
5353
}
5454

@@ -59,7 +59,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
5959

6060
if ($graphQlOperations) {
6161
foreach ($graphQlOperations as $operationName => $graphQlOperation) {
62-
$graphQlOperation = $this->enrichOperation($graphQlOperation, $resourceClass);
62+
$graphQlOperation = $this->enrichOperation($graphQlOperation);
6363
$graphQlOperations[$operationName] = $graphQlOperation;
6464
}
6565

@@ -72,7 +72,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
7272
return $resourceMetadataCollection;
7373
}
7474

75-
private function enrichOperation(Operation $operation, string $resourceClass): Operation
75+
private function enrichOperation(Operation $operation): Operation
7676
{
7777
$parameters = $operation->getParameters();
7878
if (!$parameters) {

src/Doctrine/Odm/Tests/Fixtures/Document/EmbeddableDummy.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ public static function staticMethod(): void
5656
{
5757
}
5858

59-
public function __construct()
60-
{
61-
}
62-
6359
public function getDummyName(): ?string
6460
{
6561
return $this->dummyName;

src/Doctrine/Orm/Extension/PaginationExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
6262
public function supportsResult(string $resourceClass, ?Operation $operation = null, array $context = []): bool
6363
{
6464
if ($context['graphql_operation_name'] ?? false) {
65-
return $this->pagination->isGraphQlEnabled($operation, $context);
65+
return $this->pagination->isGraphQlEnabled($operation);
6666
}
6767

6868
return $this->pagination->isEnabled($operation, $context);
@@ -98,7 +98,7 @@ public function getResult(QueryBuilder $queryBuilder, ?string $resourceClass = n
9898
*/
9999
private function getPagination(QueryBuilder $queryBuilder, ?Operation $operation, array $context): ?array
100100
{
101-
$enabled = isset($context['graphql_operation_name']) ? $this->pagination->isGraphQlEnabled($operation, $context) : $this->pagination->isEnabled($operation, $context);
101+
$enabled = isset($context['graphql_operation_name']) ? $this->pagination->isGraphQlEnabled($operation) : $this->pagination->isEnabled($operation, $context);
102102

103103
if (!$enabled) {
104104
return null;

src/Doctrine/Orm/Filter/AbstractUuidFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q
7979
throw new InvalidArgumentException(\sprintf('The filter parameter with key "%s" must specify a property. Please provide the property explicitly.', $parameter->getKey()));
8080
}
8181

82-
$this->filterProperty($parameter, $queryBuilder, $queryNameGenerator, $resourceClass, $operation, $context);
82+
$this->filterProperty($parameter, $queryBuilder, $queryNameGenerator, $resourceClass, $context);
8383
}
8484

85-
private function filterProperty(Parameter $parameter, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
85+
private function filterProperty(Parameter $parameter, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $context = []): void
8686
{
8787
$property = $parameter->getProperty();
8888
$value = $parameter->getValue();

src/Doctrine/Orm/Metadata/Resource/DoctrineOrmParameterResourceMetadataCollectionFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
4646

4747
if ($operations) {
4848
foreach ($operations as $operationName => $operation) {
49-
$operation = $this->enrichOperation($operation, $resourceClass);
49+
$operation = $this->enrichOperation($operation);
5050
$operations->add($operationName, $operation);
5151
}
5252

@@ -57,7 +57,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
5757

5858
if ($graphQlOperations) {
5959
foreach ($graphQlOperations as $operationName => $graphQlOperation) {
60-
$graphQlOperation = $this->enrichOperation($graphQlOperation, $resourceClass);
60+
$graphQlOperation = $this->enrichOperation($graphQlOperation);
6161
$graphQlOperations[$operationName] = $graphQlOperation;
6262
}
6363

@@ -70,7 +70,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
7070
return $resourceMetadataCollection;
7171
}
7272

73-
private function enrichOperation(Operation $operation, string $resourceClass): Operation
73+
private function enrichOperation(Operation $operation): Operation
7474
{
7575
$parameters = $operation->getParameters();
7676
if (!$parameters) {

0 commit comments

Comments
 (0)