Skip to content
Merged

Fixes #2169

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rector\\Contract\\PhpParser\\Node\\CommanderInterface\>"\. Please fix the @param annotation#'
- '#PHPDoc tag @param for parameter \$symfonyStyle with type array<Rector\\Contract\\PhpParser\\Node\\CommanderInterface\> 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#'
4 changes: 4 additions & 0 deletions src/Autoloading/AdditionalAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down