diff --git a/packages-tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php b/packages-tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php index 38d0b669586..ba4e95c1968 100644 --- a/packages-tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php +++ b/packages-tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TestModifyReprintTest.php @@ -61,7 +61,7 @@ public function test(): void // this will extended tokens of first node $doctrineAnnotationTagValueNode->changeValue('methods', new CurlyListNode(['"GET"', '"HEAD"'])); - $expectedDocContent = trim($inputFileInfoAndExpected->getExpected()); + $expectedDocContent = trim((string) $inputFileInfoAndExpected->getExpected()); $printedPhpDocInfo = $this->printPhpDocInfoToString($phpDocInfo); $this->assertSame($expectedDocContent, $printedPhpDocInfo); diff --git a/packages-tests/Comments/CommentRemover/CommentRemoverTest.php b/packages-tests/Comments/CommentRemover/CommentRemoverTest.php index 6ac43414ea6..4f636184ae5 100644 --- a/packages-tests/Comments/CommentRemover/CommentRemoverTest.php +++ b/packages-tests/Comments/CommentRemover/CommentRemoverTest.php @@ -46,7 +46,7 @@ public function test(SmartFileInfo $smartFileInfo): void $fileContent = $this->nodePrinter->print($nodesWithoutComments); $fileContent = trim($fileContent); - $expectedContent = trim($fileInfoToLocalInputAndExpected->getExpected()); + $expectedContent = trim((string) $fileInfoToLocalInputAndExpected->getExpected()); $this->assertSame($fileContent, $expectedContent, $smartFileInfo->getRelativeFilePathFromCwd()); diff --git a/packages/Parallel/Command/WorkerCommandLineFactory.php b/packages/Parallel/Command/WorkerCommandLineFactory.php index d112306bb1f..2278fedd335 100644 --- a/packages/Parallel/Command/WorkerCommandLineFactory.php +++ b/packages/Parallel/Command/WorkerCommandLineFactory.php @@ -61,7 +61,7 @@ public function create( break; } - $workerCommandArray[] = escapeshellarg($arg); + $workerCommandArray[] = escapeshellarg((string) $arg); } $workerCommandArray[] = $workerCommandName; @@ -110,7 +110,7 @@ public function create( * * tested in macOS and Ubuntu (github action) */ - $workerCommandArray[] = escapeshellarg($input->getOption(Option::CONFIG)); + $workerCommandArray[] = escapeshellarg((string) $input->getOption(Option::CONFIG)); } return implode(' ', $workerCommandArray); diff --git a/rules-tests/Php81/Rector/Class_/ConstantListClassToEnumRector/Fixture/enum_no_namespace.php.inc b/rules-tests/Php81/Rector/Class_/ConstantListClassToEnumRector/Fixture/enum_no_namespace.php.inc new file mode 100644 index 00000000000..9385780beb4 --- /dev/null +++ b/rules-tests/Php81/Rector/Class_/ConstantListClassToEnumRector/Fixture/enum_no_namespace.php.inc @@ -0,0 +1,20 @@ + +----- + diff --git a/rules/Naming/Naming/PropertyNaming.php b/rules/Naming/Naming/PropertyNaming.php index 770682c44a8..c69d5b90544 100644 --- a/rules/Naming/Naming/PropertyNaming.php +++ b/rules/Naming/Naming/PropertyNaming.php @@ -64,7 +64,7 @@ public function getExpectedNameFromMethodName(string $methodName): ?ExpectedName return null; } - $originalName = lcfirst($matches['root_name']); + $originalName = lcfirst((string) $matches['root_name']); return new ExpectedName($originalName, $this->rectorNamingInflector->singularize($originalName)); } @@ -123,11 +123,7 @@ public function fqnToVariableName(ThisType | ObjectType | string $objectType): s } $className = $this->resolveClassName($objectType); - if (str_contains($className, '\\')) { - $shortClassName = (string) Strings::after($className, '\\', -1); - } else { - $shortClassName = $className; - } + $shortClassName = str_contains($className, '\\') ? (string) Strings::after($className, '\\', -1) : $className; $variableName = $this->removeInterfaceSuffixPrefix($shortClassName, 'interface'); $variableName = $this->removeInterfaceSuffixPrefix($variableName, 'abstract'); diff --git a/rules/Php81/NodeFactory/EnumFactory.php b/rules/Php81/NodeFactory/EnumFactory.php index c9fa916d45e..58cecd19cd3 100644 --- a/rules/Php81/NodeFactory/EnumFactory.php +++ b/rules/Php81/NodeFactory/EnumFactory.php @@ -31,6 +31,7 @@ public function createFromClass(Class_ $class): Enum_ { $shortClassName = $this->nodeNameResolver->getShortName($class); $enum = new Enum_($shortClassName); + $enum->namespacedName = $class->namespacedName; $constants = $class->getConstants(); @@ -53,6 +54,7 @@ public function createFromSpatieClass(Class_ $class): Enum_ { $shortClassName = $this->nodeNameResolver->getShortName($class); $enum = new Enum_($shortClassName); + $enum->namespacedName = $class->namespacedName; // constant to cases $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index cecc8a241c3..ee7989aa490 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -56,7 +56,7 @@ public static function resolvePackageVersion(): string ); } - $version = trim($commitHashExecOutput[0]); + $version = trim((string) $commitHashExecOutput[0]); return trim($version, '"'); } @@ -69,6 +69,6 @@ public static function resolverReleaseDateTime(): DateTime ); } - return new DateTime(trim($output[0])); + return new DateTime(trim((string) $output[0])); } } diff --git a/src/NodeAnalyzer/ScopeAnalyzer.php b/src/NodeAnalyzer/ScopeAnalyzer.php index 66580c4f5f9..1abb7c4c684 100644 --- a/src/NodeAnalyzer/ScopeAnalyzer.php +++ b/src/NodeAnalyzer/ScopeAnalyzer.php @@ -9,7 +9,6 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Param; -use PhpParser\Node\Stmt\Enum_; use PhpParser\Node\Stmt\Namespace_; use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace; @@ -23,7 +22,6 @@ final class ScopeAnalyzer Namespace_::class, FileWithoutNamespace::class, Identifier::class, - Enum_::class, Param::class, Arg::class, ];