diff --git a/packages/BetterPhpDocParser/src/AnnotationReader/NodeAnnotationReader.php b/packages/BetterPhpDocParser/src/AnnotationReader/NodeAnnotationReader.php index a653d8155c85..25321c553476 100644 --- a/packages/BetterPhpDocParser/src/AnnotationReader/NodeAnnotationReader.php +++ b/packages/BetterPhpDocParser/src/AnnotationReader/NodeAnnotationReader.php @@ -13,7 +13,6 @@ use Rector\NodeTypeResolver\ClassExistenceStaticHelper; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PhpParser\Node\Resolver\NameResolver; -use Rector\Testing\PHPUnit\PHPUnitEnvironment; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -104,11 +103,8 @@ private function createPropertyReflectionFromPropertyNode(Property $property): ? try { return new ReflectionProperty($className, $propertyName); } catch (Throwable $throwable) { - if (PHPUnitEnvironment::isPHPUnitRun()) { - return null; - } - - throw new $throwable(); + // in case of PHPUnit property or just-added property + return null; } } diff --git a/phpstan.neon b/phpstan.neon index 9e59ab7294b8..54f39eb175d5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -207,3 +207,5 @@ parameters: - '#PHPDoc tag @param references unknown parameter\: \$commanders#' - '#In method "Rector\\Rector\\AbstractRector\:\:autowireAbstractRectorDependencies", parameter \$symfonyStyle type is type\-hinted to "Symfony\\Component\\Console\\Style\\SymfonyStyle" but the @param annotation says it is a "array"\. Please fix the @param annotation#' - '#PHPDoc tag @param for parameter \$symfonyStyle with type array is incompatible with native type Symfony\\Component\\Console\\Style\\SymfonyStyle#' + + - '#In method "Rector\\BetterPhpDocParser\\AnnotationReader\\NodeAnnotationReader\:\:createPropertyReflectionFromPropertyNode", caught "Throwable" must be rethrown\. Either catch a more specific exception or add a "throw" clause in the "catch" block to propagate the exception\. More info\: http\://bit\.ly/failloud#' diff --git a/src/Autoloading/AdditionalAutoloader.php b/src/Autoloading/AdditionalAutoloader.php index 47333afee73d..0352e006217c 100644 --- a/src/Autoloading/AdditionalAutoloader.php +++ b/src/Autoloading/AdditionalAutoloader.php @@ -76,6 +76,10 @@ public function autoloadWithInputAndSource(InputInterface $input, array $source) private function autoloadFileFromInput(InputInterface $input): void { + if (! $input->hasOption(Option::OPTION_AUTOLOAD_FILE)) { + return; + } + /** @var string|null $autoloadFile */ $autoloadFile = $input->getOption(Option::OPTION_AUTOLOAD_FILE); if ($autoloadFile === null) { diff --git a/utils/DocumentationGenerator/src/Command/DumpNodesCommand.php b/utils/DocumentationGenerator/src/Command/DumpNodesCommand.php index b70b49710099..76c0fe199afa 100644 --- a/utils/DocumentationGenerator/src/Command/DumpNodesCommand.php +++ b/utils/DocumentationGenerator/src/Command/DumpNodesCommand.php @@ -49,6 +49,7 @@ use PhpParser\Node\Expr\YieldFrom; use PhpParser\Node\Identifier; use PhpParser\Node\Name; +use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\NullableType; use PhpParser\Node\Param; use PhpParser\Node\Scalar\DNumber; @@ -298,7 +299,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } elseif ($nodeClass === Alias::class) { $node = new Alias(new Name('SomeTrait'), 'method', Class_::MODIFIER_PUBLIC, 'aliasedMethod'); } elseif ($nodeClass === Throw_::class) { - $node = new Throw_(new New_(new Variable('someException'))); + $node = new Throw_(new New_(new FullyQualified('SomeException'))); } elseif ($nodeClass === TryCatch::class) { $node = new TryCatch([new Function_('someFunction')], [new Function_('logException')]); } elseif ($nodeClass === Interface_::class) {