mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 01:10:53 +00:00
[Core] Apply Scope Refresh on Enum_ (#2549)
* [Core] Apply Scope Refresh on Enum_
* implemented 🎉
* more set namespacedName
* [ci-review] Rector Rectify
* [ci-review] Rector Rectify
* final touch: fixture for Enum_ no namespace
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
e8ca23fd15
commit
0fb4f5bfbb
|
@ -61,7 +61,7 @@ final class TestModifyReprintTest extends AbstractTestCase
|
|||
// 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);
|
||||
|
|
|
@ -46,7 +46,7 @@ final class CommentRemoverTest extends AbstractTestCase
|
|||
$fileContent = $this->nodePrinter->print($nodesWithoutComments);
|
||||
$fileContent = trim($fileContent);
|
||||
|
||||
$expectedContent = trim($fileInfoToLocalInputAndExpected->getExpected());
|
||||
$expectedContent = trim((string) $fileInfoToLocalInputAndExpected->getExpected());
|
||||
|
||||
$this->assertSame($fileContent, $expectedContent, $smartFileInfo->getRelativeFilePathFromCwd());
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ final class WorkerCommandLineFactory
|
|||
break;
|
||||
}
|
||||
|
||||
$workerCommandArray[] = escapeshellarg($arg);
|
||||
$workerCommandArray[] = escapeshellarg((string) $arg);
|
||||
}
|
||||
|
||||
$workerCommandArray[] = $workerCommandName;
|
||||
|
@ -110,7 +110,7 @@ final class WorkerCommandLineFactory
|
|||
*
|
||||
* tested in macOS and Ubuntu (github action)
|
||||
*/
|
||||
$workerCommandArray[] = escapeshellarg($input->getOption(Option::CONFIG));
|
||||
$workerCommandArray[] = escapeshellarg((string) $input->getOption(Option::CONFIG));
|
||||
}
|
||||
|
||||
return implode(' ', $workerCommandArray);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
class EnumNoNamespace
|
||||
{
|
||||
public const LEFT = 'left';
|
||||
|
||||
public const RIGHT = 'right';
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
enum EnumNoNamespace : string
|
||||
{
|
||||
case LEFT = 'left';
|
||||
case RIGHT = 'right';
|
||||
}
|
||||
|
||||
?>
|
|
@ -64,7 +64,7 @@ final class PropertyNaming
|
|||
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 @@ final class PropertyNaming
|
|||
}
|
||||
|
||||
$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');
|
||||
|
|
|
@ -31,6 +31,7 @@ final class EnumFactory
|
|||
{
|
||||
$shortClassName = $this->nodeNameResolver->getShortName($class);
|
||||
$enum = new Enum_($shortClassName);
|
||||
$enum->namespacedName = $class->namespacedName;
|
||||
|
||||
$constants = $class->getConstants();
|
||||
|
||||
|
@ -53,6 +54,7 @@ final class EnumFactory
|
|||
{
|
||||
$shortClassName = $this->nodeNameResolver->getShortName($class);
|
||||
$enum = new Enum_($shortClassName);
|
||||
$enum->namespacedName = $class->namespacedName;
|
||||
|
||||
// constant to cases
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
|
||||
|
|
|
@ -56,7 +56,7 @@ final class VersionResolver
|
|||
);
|
||||
}
|
||||
|
||||
$version = trim($commitHashExecOutput[0]);
|
||||
$version = trim((string) $commitHashExecOutput[0]);
|
||||
return trim($version, '"');
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,6 @@ final class VersionResolver
|
|||
);
|
||||
}
|
||||
|
||||
return new DateTime(trim($output[0]));
|
||||
return new DateTime(trim((string) $output[0]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ use PhpParser\Node\Arg;
|
|||
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,
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue
Block a user