Skip to content

Commit

Permalink
Uncover everything behind the bleedingEdge flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 24, 2024
1 parent d198a78 commit d45a640
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 32 deletions.
16 changes: 2 additions & 14 deletions rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ parametersSchema:
rules:
- PHPStan\Rules\Doctrine\ORM\DqlRule
- PHPStan\Rules\Doctrine\ORM\RepositoryMethodCallRule
- PHPStan\Rules\Doctrine\ORM\EntityConstructorNotFinalRule
- PHPStan\Rules\Doctrine\ORM\EntityMappingExceptionRule
- PHPStan\Rules\Doctrine\ORM\EntityNotFinalRule

conditionalTags:
PHPStan\Rules\Doctrine\ORM\EntityMappingExceptionRule:
phpstan.rules.rule: %featureToggles.bleedingEdge%
PHPStan\Rules\Doctrine\ORM\EntityConstructorNotFinalRule:
phpstan.rules.rule: %featureToggles.bleedingEdge%

services:
-
class: PHPStan\Rules\Doctrine\ORM\QueryBuilderDqlRule
Expand All @@ -43,23 +39,15 @@ services:
arguments:
reportUnknownTypes: %doctrine.reportUnknownTypes%
allowNullablePropertyForRequiredField: %doctrine.allowNullablePropertyForRequiredField%
bleedingEdge: %featureToggles.bleedingEdge%
descriptorRegistry: @doctrineTypeDescriptorRegistry
tags:
- phpstan.rules.rule
-
class: PHPStan\Rules\Doctrine\ORM\EntityMappingExceptionRule
-
class: PHPStan\Rules\Doctrine\ORM\EntityNotFinalRule
-
class: PHPStan\Rules\Doctrine\ORM\EntityRelationRule
arguments:
allowNullablePropertyForRequiredField: %doctrine.allowNullablePropertyForRequiredField%
bleedingEdge: %featureToggles.bleedingEdge%
tags:
- phpstan.rules.rule
-
class: PHPStan\Rules\Doctrine\ORM\EntityConstructorNotFinalRule
-
class: PHPStan\Classes\DoctrineProxyForbiddenClassNamesExtension
tags:
Expand Down
7 changes: 0 additions & 7 deletions src/Rules/Doctrine/ORM/EntityColumnRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,19 @@ class EntityColumnRule implements Rule

private bool $allowNullablePropertyForRequiredField;

private bool $bleedingEdge;

public function __construct(
ObjectMetadataResolver $objectMetadataResolver,
DescriptorRegistry $descriptorRegistry,
ReflectionProvider $reflectionProvider,
bool $reportUnknownTypes,
bool $allowNullablePropertyForRequiredField,
bool $bleedingEdge
)
{
$this->objectMetadataResolver = $objectMetadataResolver;
$this->descriptorRegistry = $descriptorRegistry;
$this->reflectionProvider = $reflectionProvider;
$this->reportUnknownTypes = $reportUnknownTypes;
$this->allowNullablePropertyForRequiredField = $allowNullablePropertyForRequiredField;
$this->bleedingEdge = $bleedingEdge;
}

public function getNodeType(): string
Expand All @@ -70,9 +66,6 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
if (!$this->bleedingEdge && !$this->objectMetadataResolver->hasObjectManagerLoader()) {
return [];
}
$class = $scope->getClassReflection();
if ($class === null) {
return [];
Expand Down
10 changes: 1 addition & 9 deletions src/Rules/Doctrine/ORM/EntityRelationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ class EntityRelationRule implements Rule

private bool $allowNullablePropertyForRequiredField;

private bool $bleedingEdge;

public function __construct(
ObjectMetadataResolver $objectMetadataResolver,
bool $allowNullablePropertyForRequiredField,
bool $bleedingEdge
bool $allowNullablePropertyForRequiredField
)
{
$this->objectMetadataResolver = $objectMetadataResolver;
$this->allowNullablePropertyForRequiredField = $allowNullablePropertyForRequiredField;
$this->bleedingEdge = $bleedingEdge;
}

public function getNodeType(): string
Expand All @@ -52,10 +48,6 @@ public function getNodeType(): string

public function processNode(Node $node, Scope $scope): array
{
if (!$this->bleedingEdge && !$this->objectMetadataResolver->hasObjectManagerLoader()) {
return [];
}

$class = $scope->getClassReflection();
if ($class === null) {
return [];
Expand Down
1 change: 0 additions & 1 deletion tests/Rules/Doctrine/ORM/EntityColumnRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected function getRule(): Rule
$this->createReflectionProvider(),
true,
$this->allowNullablePropertyForRequiredField,
true,
);
}

Expand Down
1 change: 0 additions & 1 deletion tests/Rules/Doctrine/ORM/EntityRelationRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ protected function getRule(): Rule
return new EntityRelationRule(
new ObjectMetadataResolver($this->objectManagerLoader, __DIR__ . '/../../../../tmp'),
$this->allowNullablePropertyForRequiredField,
true,
);
}

Expand Down

0 comments on commit d45a640

Please sign in to comment.