diff --git a/.github/workflows/test_with_doctrine.yaml b/.github/workflows/test_with_doctrine.yaml index 34b2200de67..b512584a173 100644 --- a/.github/workflows/test_with_doctrine.yaml +++ b/.github/workflows/test_with_doctrine.yaml @@ -32,4 +32,4 @@ jobs: # do not intall doctrine/orm phpstan, it conflicts with Retor's one composer install -d orm --no-dev - - run: bin/rector process orm/lib --set dead-code --autoload-file orm/vendor/autoload.php + - run: bin/rector process orm/lib --config ci/config/rector-doctrine.yaml --autoload-file orm/vendor/autoload.php --debug diff --git a/ci/config/rector-doctrine.yaml b/ci/config/rector-doctrine.yaml new file mode 100644 index 00000000000..641c853a130 --- /dev/null +++ b/ci/config/rector-doctrine.yaml @@ -0,0 +1,4 @@ +parameters: + auto_import_names: false + sets: + - "dead-code" diff --git a/rules/phpstan/src/Rector/Node/RemoveNonExistingVarAnnotationRector.php b/rules/phpstan/src/Rector/Node/RemoveNonExistingVarAnnotationRector.php index 3be84e3d17c..7c6c9821736 100644 --- a/rules/phpstan/src/Rector/Node/RemoveNonExistingVarAnnotationRector.php +++ b/rules/phpstan/src/Rector/Node/RemoveNonExistingVarAnnotationRector.php @@ -92,8 +92,11 @@ PHP return null; } - /** @var PhpDocInfo $phpDocInfo */ + /** @var PhpDocInfo|null $phpDocInfo */ $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); + if ($phpDocInfo === null) { + return null; + } $varTagValue = $phpDocInfo->getVarTagValue(); if ($varTagValue === null) { diff --git a/src/PhpParser/Node/Manipulator/PropertyManipulator.php b/src/PhpParser/Node/Manipulator/PropertyManipulator.php index f36964c14e5..f7475647c58 100644 --- a/src/PhpParser/Node/Manipulator/PropertyManipulator.php +++ b/src/PhpParser/Node/Manipulator/PropertyManipulator.php @@ -125,9 +125,9 @@ final class PropertyManipulator return true; } - /** @var PhpDocInfo $phpDocInfo */ + /** @var PhpDocInfo|null $phpDocInfo */ $phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO); - if ($phpDocInfo->hasByType(SerializerTypeTagValueNode::class)) { + if ($phpDocInfo !== null && $phpDocInfo->hasByType(SerializerTypeTagValueNode::class)) { return true; }