diff --git a/packages/node-type-resolver/src/NodeVisitor/FunctionMethodAndClassNodeVisitor.php b/packages/node-type-resolver/src/NodeVisitor/FunctionMethodAndClassNodeVisitor.php index e1876ad421ad..fdfaa5bea908 100644 --- a/packages/node-type-resolver/src/NodeVisitor/FunctionMethodAndClassNodeVisitor.php +++ b/packages/node-type-resolver/src/NodeVisitor/FunctionMethodAndClassNodeVisitor.php @@ -44,12 +44,12 @@ final class FunctionMethodAndClassNodeVisitor extends NodeVisitorAbstract /** * @var ClassLike|null */ - private $classNode; + private $classLike; /** * @var ClassMethod|null */ - private $methodNode; + private $classMethod; /** * @var Function_|null @@ -72,10 +72,10 @@ public function __construct(ClassNaming $classNaming) */ public function beforeTraverse(array $nodes): ?array { - $this->classNode = null; + $this->classLike = null; $this->className = null; $this->methodName = null; - $this->methodNode = null; + $this->classMethod = null; $this->functionNode = null; return null; @@ -99,7 +99,7 @@ public function leaveNode(Node $node) $this->setClassNodeAndName(array_pop($this->classStack)); } if ($node instanceof ClassMethod) { - $this->methodNode = array_pop($this->methodStack); + $this->classMethod = array_pop($this->methodStack); $this->methodName = (string) $this->methodName; } return null; @@ -108,30 +108,30 @@ public function leaveNode(Node $node) private function processClass(Node $node): void { if ($node instanceof ClassLike) { - $this->classStack[] = $this->classNode; + $this->classStack[] = $this->classLike; $this->setClassNodeAndName($node); } - $node->setAttribute(AttributeKey::CLASS_NODE, $this->classNode); + $node->setAttribute(AttributeKey::CLASS_NODE, $this->classLike); $node->setAttribute(AttributeKey::CLASS_NAME, $this->className); $node->setAttribute(AttributeKey::CLASS_SHORT_NAME, $this->classShortName); - if ($this->classNode instanceof Class_) { - $this->setParentClassName($this->classNode, $node); + if ($this->classLike instanceof Class_) { + $this->setParentClassName($this->classLike, $node); } } private function processMethod(Node $node): void { if ($node instanceof ClassMethod) { - $this->methodStack[] = $this->methodNode; + $this->methodStack[] = $this->classMethod; - $this->methodNode = $node; + $this->classMethod = $node; $this->methodName = (string) $node->name; } $node->setAttribute(AttributeKey::METHOD_NAME, $this->methodName); - $node->setAttribute(AttributeKey::METHOD_NODE, $this->methodNode); + $node->setAttribute(AttributeKey::METHOD_NODE, $this->classMethod); } private function processFunction(Node $node): void @@ -145,7 +145,7 @@ private function processFunction(Node $node): void private function setClassNodeAndName(?ClassLike $classLike): void { - $this->classNode = $classLike; + $this->classLike = $classLike; if ($classLike === null || $classLike->name === null) { $this->className = null; } elseif (isset($classLike->namespacedName)) { diff --git a/packages/node-type-resolver/src/NodeVisitor/ParentAndNextNodeVisitor.php b/packages/node-type-resolver/src/NodeVisitor/ParentAndNextNodeVisitor.php index 7382b8d5da7e..44dd4509aa2f 100644 --- a/packages/node-type-resolver/src/NodeVisitor/ParentAndNextNodeVisitor.php +++ b/packages/node-type-resolver/src/NodeVisitor/ParentAndNextNodeVisitor.php @@ -21,7 +21,7 @@ final class ParentAndNextNodeVisitor extends NodeVisitorAbstract /** * @var Node|null */ - private $prev; + private $previousNode; /** * @param Node[] $nodes @@ -30,7 +30,7 @@ final class ParentAndNextNodeVisitor extends NodeVisitorAbstract public function afterTraverse(array $nodes): ?array { $this->stack = []; - $this->prev = null; + $this->previousNode = null; return null; } @@ -44,11 +44,13 @@ public function enterNode(Node $node) $node->setAttribute(AttributeKey::PARENT_NODE, $this->stack[count($this->stack) - 1]); } - if ($this->prev && - $this->prev->getAttribute(AttributeKey::PARENT_NODE) === $node->getAttribute(AttributeKey::PARENT_NODE) + if ($this->previousNode && + $this->previousNode->getAttribute(AttributeKey::PARENT_NODE) === $node->getAttribute( + AttributeKey::PARENT_NODE + ) ) { - $node->setAttribute(AttributeKey::PREVIOUS_NODE, $this->prev); - $this->prev->setAttribute(AttributeKey::NEXT_NODE, $node); + $node->setAttribute(AttributeKey::PREVIOUS_NODE, $this->previousNode); + $this->previousNode->setAttribute(AttributeKey::NEXT_NODE, $node); } $this->stack[] = $node; @@ -61,7 +63,7 @@ public function enterNode(Node $node) */ public function leaveNode(Node $node) { - $this->prev = $node; + $this->previousNode = $node; array_pop($this->stack); return null; diff --git a/packages/node-type-resolver/src/NodeVisitor/StatementNodeVisitor.php b/packages/node-type-resolver/src/NodeVisitor/StatementNodeVisitor.php index 5923b7177254..24726f859776 100644 --- a/packages/node-type-resolver/src/NodeVisitor/StatementNodeVisitor.php +++ b/packages/node-type-resolver/src/NodeVisitor/StatementNodeVisitor.php @@ -15,7 +15,7 @@ final class StatementNodeVisitor extends NodeVisitorAbstract /** * @var Stmt|null */ - private $previousStatement; + private $previousStmt; /** * @param Node[] $nodes @@ -23,7 +23,7 @@ final class StatementNodeVisitor extends NodeVisitorAbstract */ public function beforeTraverse(array $nodes): ?array { - $this->previousStatement = null; + $this->previousStmt = null; return null; } @@ -39,9 +39,9 @@ public function enterNode(Node $node) throw new ShouldNotHappenException('Only statement can appear at top level'); } - $node->setAttribute(AttributeKey::PREVIOUS_STATEMENT, $this->previousStatement); + $node->setAttribute(AttributeKey::PREVIOUS_STATEMENT, $this->previousStmt); $node->setAttribute(AttributeKey::CURRENT_STATEMENT, $node); - $this->previousStatement = $node; + $this->previousStmt = $node; } if (isset($node->stmts)) { diff --git a/packages/node-type-resolver/src/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php b/packages/node-type-resolver/src/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php index 927ecd7b2fe9..29396e3143f7 100644 --- a/packages/node-type-resolver/src/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php +++ b/packages/node-type-resolver/src/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php @@ -30,7 +30,7 @@ final class RemoveDeepChainMethodCallNodeVisitor extends NodeVisitorAbstract /** * @var Expression|null */ - private $nodeToRemove; + private $removingExpression; public function __construct(BetterNodeFinder $betterNodeFinder, int $nestedChainMethodCallLimit) { @@ -50,7 +50,7 @@ public function enterNode(Node $node) if ($node->expr instanceof MethodCall && $node->expr->var instanceof MethodCall) { $nestedChainMethodCalls = $this->betterNodeFinder->findInstanceOf([$node->expr], MethodCall::class); if (count($nestedChainMethodCalls) > $this->nestedChainMethodCallLimit) { - $this->nodeToRemove = $node; + $this->removingExpression = $node; return NodeTraverser::DONT_TRAVERSE_CHILDREN; } @@ -64,7 +64,7 @@ public function enterNode(Node $node) */ public function leaveNode(Node $node) { - if ($node === $this->nodeToRemove) { + if ($node === $this->removingExpression) { // keep any node, so we don't remove it permanently $nopNode = new Nop(); $nopNode->setAttributes($node->getAttributes()); diff --git a/packages/static-type-mapper/src/PhpParser/FullyQualifiedNodeMapper.php b/packages/static-type-mapper/src/PhpParser/FullyQualifiedNodeMapper.php index 5614beabc215..832c7295af54 100644 --- a/packages/static-type-mapper/src/PhpParser/FullyQualifiedNodeMapper.php +++ b/packages/static-type-mapper/src/PhpParser/FullyQualifiedNodeMapper.php @@ -4,9 +4,11 @@ namespace Rector\StaticTypeMapper\PhpParser; +use Nette\Utils\Strings; use PhpParser\Node; use PhpParser\Node\Name\FullyQualified; use PHPStan\Type\Type; +use Rector\PHPStan\Type\AliasedObjectType; use Rector\PHPStan\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface; @@ -22,6 +24,14 @@ public function getNodeType(): string */ public function mapToPHPStan(Node $node): Type { + $originalName = (string) $node->getAttribute('originalName'); + $fullyQualifiedName = $node->toString(); + + // is aliased? + if ($originalName !== $fullyQualifiedName && ! Strings::endsWith($fullyQualifiedName, '\\' . $originalName)) { + return new AliasedObjectType($originalName, $fullyQualifiedName); + } + return new FullyQualifiedObjectType($node->toString()); } } diff --git a/rector-ci.yaml b/rector-ci.yaml index fb38fc69f5df..653ac979b00e 100644 --- a/rector-ci.yaml +++ b/rector-ci.yaml @@ -6,6 +6,7 @@ parameters: - 'nette-utils-code-quality' - 'solid' - 'privatization' + - 'naming' paths: - 'src' diff --git a/rector.yaml b/rector.yaml index 45b7040497b4..6b5f1742c398 100644 --- a/rector.yaml +++ b/rector.yaml @@ -25,8 +25,6 @@ parameters: - "/*Source/" - "/Fixture/" - "/Expected/" - - "packages/Symfony/src/Bridge/DefaultAnalyzedSymfonyApplicationContainer.php" - - "packages/Php/tests/Rector/Name/ReservedObjectRector/*" # autoload-buggy cases - "*.php.inc" diff --git a/rules/code-quality/src/Rector/FuncCall/SimplifyRegexPatternRector.php b/rules/code-quality/src/Rector/FuncCall/SimplifyRegexPatternRector.php index 9c252289693d..22c9a7a99914 100644 --- a/rules/code-quality/src/Rector/FuncCall/SimplifyRegexPatternRector.php +++ b/rules/code-quality/src/Rector/FuncCall/SimplifyRegexPatternRector.php @@ -83,6 +83,9 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { $patterns = $this->regexPatternArgumentManipulator->matchCallArgumentWithRegexPattern($node); + if ($patterns === []) { + return null; + } foreach ($patterns as $pattern) { foreach (self::COMPLEX_PATTERN_TO_SIMPLE as $complexPattern => $simple) { diff --git a/rules/coding-style/src/Node/NameImporter.php b/rules/coding-style/src/Node/NameImporter.php index 658de3d591b6..8a98a3c935fd 100644 --- a/rules/coding-style/src/Node/NameImporter.php +++ b/rules/coding-style/src/Node/NameImporter.php @@ -16,6 +16,7 @@ use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\ClassExistenceStaticHelper; use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\PHPStan\Type\AliasedObjectType; use Rector\PHPStan\Type\FullyQualifiedObjectType; use Rector\PostRector\Collector\UseNodesToAddCollector; use Rector\StaticTypeMapper\StaticTypeMapper; @@ -81,6 +82,12 @@ public function importName(Name $name): ?Name } $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($name); + + // propagate to fqn, that's what we need here + if ($staticType instanceof AliasedObjectType) { + $staticType = new FullyQualifiedObjectType($staticType->getFullyQualifiedClass()); + } + if (! $staticType instanceof FullyQualifiedObjectType) { return null; } diff --git a/rules/coding-style/src/Rector/FuncCall/ConsistentPregDelimiterRector.php b/rules/coding-style/src/Rector/FuncCall/ConsistentPregDelimiterRector.php index ebbec273ea25..a5e0ffc39d78 100644 --- a/rules/coding-style/src/Rector/FuncCall/ConsistentPregDelimiterRector.php +++ b/rules/coding-style/src/Rector/FuncCall/ConsistentPregDelimiterRector.php @@ -128,7 +128,7 @@ public function refactor(Node $node): ?Node return null; } - private function refactorFuncCall(FuncCall $funcCall): FuncCall + private function refactorFuncCall(FuncCall $funcCall): ?FuncCall { foreach (self::FUNCTIONS_WITH_REGEX_PATTERN as $function => $position) { if (! $this->isName($funcCall, $function)) { @@ -136,9 +136,11 @@ private function refactorFuncCall(FuncCall $funcCall): FuncCall } $this->refactorArgument($funcCall->args[$position]); + + return $funcCall; } - return $funcCall; + return null; } private function refactorArgument(Arg $arg): void diff --git a/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php b/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php index 6890967f67eb..74962abda5f9 100644 --- a/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php +++ b/rules/dead-code/src/Rector/MethodCall/RemoveDefaultArgumentValueRector.php @@ -92,6 +92,10 @@ public function refactor(Node $node): ?Node $defaultValues = $this->resolveDefaultValuesFromCall($node); $keysToRemove = $this->resolveKeysToRemove($node, $defaultValues); + if ($keysToRemove === []) { + return null; + } + foreach ($keysToRemove as $keyToRemove) { $this->removeArg($node, $keyToRemove); } diff --git a/rules/naming/src/Naming/ConflictingNameResolver.php b/rules/naming/src/Naming/ConflictingNameResolver.php index ddf873c1e6c0..e513c591bf74 100644 --- a/rules/naming/src/Naming/ConflictingNameResolver.php +++ b/rules/naming/src/Naming/ConflictingNameResolver.php @@ -6,6 +6,7 @@ use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassMethod; +use Rector\NodeNameResolver\NodeNameResolver; final class ConflictingNameResolver { @@ -14,9 +15,15 @@ final class ConflictingNameResolver */ private $expectedNameResolver; - public function __construct(ExpectedNameResolver $expectedNameResolver) + /** + * @var NodeNameResolver + */ + private $nodeNameResolver; + + public function __construct(ExpectedNameResolver $expectedNameResolver, NodeNameResolver $nodeNameResolver) { $this->expectedNameResolver = $expectedNameResolver; + $this->nodeNameResolver = $nodeNameResolver; } /** @@ -28,7 +35,8 @@ public function resolveConflictingPropertyNames(ClassLike $classLike): array foreach ($classLike->getProperties() as $property) { $expectedName = $this->expectedNameResolver->resolveForProperty($property); if ($expectedName === null) { - continue; + /** @var string $expectedName */ + $expectedName = $this->nodeNameResolver->getName($property); } $expectedNames[] = $expectedName; diff --git a/rules/naming/src/Naming/ExpectedNameResolver.php b/rules/naming/src/Naming/ExpectedNameResolver.php index 094ffe295822..0eb1ce3ca3c2 100644 --- a/rules/naming/src/Naming/ExpectedNameResolver.php +++ b/rules/naming/src/Naming/ExpectedNameResolver.php @@ -39,30 +39,29 @@ public function __construct( $this->staticTypeMapper = $staticTypeMapper; } - public function resolveForProperty(Property $property): ?string + public function resolveForPropertyIfNotYet(Property $property): ?string { - $currentName = $this->nodeNameResolver->getName($property); + $expectedName = $this->resolveForProperty($property); + if ($expectedName === null) { + return null; + } - /** @var PhpDocInfo|null $phpDocInfo */ - $phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO); - $expectedName = $this->propertyNaming->getExpectedNameFromType($phpDocInfo->getVarType()); + /** @var string $propertyName */ + $propertyName = $this->nodeNameResolver->getName($property); + if ($this->endsWith($propertyName, $expectedName)) { + return null; + } - if ($expectedName === $currentName) { + if ($this->nodeNameResolver->isName($property, $expectedName)) { return null; } return $expectedName; } - public function resolveForParam(Param $param): ?string + public function resolveForParamIfNotYet(Param $param): ?string { - // nothing to verify - if ($param->type === null) { - return null; - } - - $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); - $expectedName = $this->propertyNaming->getExpectedNameFromType($staticType); + $expectedName = $this->resolveForParam($param); if ($expectedName === null) { return null; } @@ -80,12 +79,35 @@ public function resolveForParam(Param $param): ?string return $expectedName; } + public function resolveForParam(Param $param): ?string + { + // nothing to verify + if ($param->type === null) { + return null; + } + + $staticType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type); + return $this->propertyNaming->getExpectedNameFromType($staticType); + } + + public function resolveForProperty(Property $property): ?string + { + /** @var PhpDocInfo|null $phpDocInfo */ + $phpDocInfo = $property->getAttribute(AttributeKey::PHP_DOC_INFO); + if ($phpDocInfo === null) { + return null; + } + + return $this->propertyNaming->getExpectedNameFromType($phpDocInfo->getVarType()); + } + /** * Ends with ucname * Starts with adjective, e.g. (Post $firstPost, Post $secondPost) */ private function endsWith(string $currentName, string $expectedName): bool { - return (bool) Strings::match($currentName, '#\w+' . lcfirst($expectedName) . '#'); + $suffixNamePattern = '#\w+' . ucfirst($expectedName) . '#'; + return (bool) Strings::match($currentName, $suffixNamePattern); } } diff --git a/rules/naming/src/Naming/PropertyNaming.php b/rules/naming/src/Naming/PropertyNaming.php index 43594721dcdd..6c7e74dda3e8 100644 --- a/rules/naming/src/Naming/PropertyNaming.php +++ b/rules/naming/src/Naming/PropertyNaming.php @@ -5,9 +5,11 @@ namespace Rector\Naming\Naming; use Nette\Utils\Strings; +use PHPStan\Type\NullType; use PHPStan\Type\StaticType; use PHPStan\Type\Type; use PHPStan\Type\TypeWithClassName; +use PHPStan\Type\UnionType; use Rector\PHPStan\Type\SelfObjectType; use Rector\PHPStan\Type\ShortenedObjectType; @@ -29,6 +31,10 @@ final class PropertyNaming public function getExpectedNameFromType(Type $type): ?string { + if ($type instanceof UnionType) { + $type = $this->unwrapNullableType($type); + } + if (! $type instanceof TypeWithClassName) { return null; } @@ -59,7 +65,6 @@ public function getExpectedNameFromType(Type $type): ?string // remove "_" $shortClassName = Strings::replace($shortClassName, '#_#', ''); - $shortClassName = $this->normalizeUpperCase($shortClassName); return lcfirst($shortClassName); @@ -128,4 +133,28 @@ private function normalizeUpperCase(string $shortClassName): string } return $shortClassName; } + + /** + * E.g. null|ClassType → ClassType + */ + private function unwrapNullableType(UnionType $unionType): ?Type + { + if (count($unionType->getTypes()) !== 2) { + return null; + } + + if (! $unionType->isSuperTypeOf(new NullType())->yes()) { + return null; + } + + foreach ($unionType->getTypes() as $unionedType) { + if ($unionedType instanceof NullType) { + continue; + } + + return $unionedType; + } + + return null; + } } diff --git a/rules/naming/src/Rector/Class_/RenamePropertyToMatchTypeRector.php b/rules/naming/src/Rector/Class_/RenamePropertyToMatchTypeRector.php index 8391a2583b0d..a675d87267d0 100644 --- a/rules/naming/src/Rector/Class_/RenamePropertyToMatchTypeRector.php +++ b/rules/naming/src/Rector/Class_/RenamePropertyToMatchTypeRector.php @@ -6,13 +6,12 @@ use PhpParser\Node; use PhpParser\Node\Expr\PropertyFetch; +use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; -use PhpParser\Node\Param; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Interface_; -use PhpParser\Node\Stmt\Property; use PhpParser\Node\VarLikeIdentifier; use Rector\Core\Rector\AbstractRector; use Rector\Core\RectorDefinition\CodeSample; @@ -106,7 +105,7 @@ private function refactorClassMethods(ClassLike $classLike): void $conflictingNames = $this->conflictingNameResolver->resolveConflictingVariableNames($classMethod); foreach ($classMethod->params as $param) { - $expectedName = $this->expectedNameResolver->resolveForParam($param); + $expectedName = $this->expectedNameResolver->resolveForParamIfNotYet($param); if ($expectedName === null) { continue; } @@ -136,7 +135,7 @@ private function refactorClassProperties(ClassLike $classLike): void } $oldName = $this->getName($property); - $expectedName = $this->expectedNameResolver->resolveForProperty($property); + $expectedName = $this->expectedNameResolver->resolveForPropertyIfNotYet($property); if ($expectedName === null) { continue; } @@ -162,7 +161,9 @@ private function renameVariableInClassMethod(ClassMethod $classMethod, string $o return null; } + /** @var Variable $node */ $node->name = new Identifier($expectedName); + return $node; }); } diff --git a/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_alias_prefix.php.inc b/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_alias_prefix.php.inc new file mode 100644 index 000000000000..3d15d3aa4b7a --- /dev/null +++ b/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_alias_prefix.php.inc @@ -0,0 +1,18 @@ +nikicParserFactory = $nikicParserFactory; + } +} diff --git a/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_double_trouble.php.inc b/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_double_trouble.php.inc new file mode 100644 index 000000000000..b3750a802c24 --- /dev/null +++ b/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_double_trouble.php.inc @@ -0,0 +1,18 @@ +getStatusCodeMethodCall; + } +} diff --git a/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_type_prefix.php.inc b/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_type_prefix.php.inc new file mode 100644 index 000000000000..6ddfc62ebaf0 --- /dev/null +++ b/rules/naming/tests/Rector/Class_/RenamePropertyToMatchTypeRector/Fixture/keep_type_prefix.php.inc @@ -0,0 +1,13 @@ +getFuncCall(); + $strposFuncCall = $strStartsWithValueObject->getFuncCall(); $strposFuncCall->name = new Name('str_starts_with'); return $strposFuncCall; diff --git a/src/Console/Command/ScanClassesCommand.php b/src/Console/Command/ScanClassesCommand.php deleted file mode 100644 index 8abbd93a0fd1..000000000000 --- a/src/Console/Command/ScanClassesCommand.php +++ /dev/null @@ -1,60 +0,0 @@ -symfonyStyle = $symfonyStyle; - - parent::__construct(); - $this->classFinder = $classFinder; - } - - protected function configure(): void - { - $this->setName(CommandNaming::classToName(self::class)); - $this->setDescription('Show classes in provided source'); - - $this->addArgument(self::SOURCE_ARGUMENT, InputArgument::REQUIRED, 'Path to file to be scanned'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - /** @var string[] $source */ - $source = (array) $input->getArgument(self::SOURCE_ARGUMENT); - - $foundClasses = $this->classFinder->findClassesInDirectories($source); - $this->symfonyStyle->listing($foundClasses); - - $this->symfonyStyle->success(sprintf('We found %d classes', count($foundClasses))); - - return ShellCode::SUCCESS; - } -} diff --git a/src/FileSystem/ClassFinder.php b/src/FileSystem/ClassFinder.php deleted file mode 100644 index b02d1b7063b7..000000000000 --- a/src/FileSystem/ClassFinder.php +++ /dev/null @@ -1,31 +0,0 @@ -addDirectory($singleSource); - } - - $robotLoader->setTempDirectory(sys_get_temp_dir() . '/_class_finder'); - $robotLoader->rebuild(); - - $classes = array_keys($robotLoader->getIndexedClasses()); - - sort($classes); - - return $classes; - } -} diff --git a/src/PhpParser/Printer/BetterStandardPrinter.php b/src/PhpParser/Printer/BetterStandardPrinter.php index 8f58717071b9..04ea84d8185d 100644 --- a/src/PhpParser/Printer/BetterStandardPrinter.php +++ b/src/PhpParser/Printer/BetterStandardPrinter.php @@ -235,13 +235,13 @@ protected function pSingleQuotedString(string $string): string /** * Emulates 1_000 in PHP 7.3- version */ - protected function pScalar_DNumber(DNumber $DNumber): string + protected function pScalar_DNumber(DNumber $dNumber): string { - if (is_string($DNumber->value)) { - return $DNumber->value; + if (is_string($dNumber->value)) { + return $dNumber->value; } - return parent::pScalar_DNumber($DNumber); + return parent::pScalar_DNumber($dNumber); } /**