[Renaming] Add test fixture for same-namespaced short class fail (#5040)

Co-authored-by: Tom Klingenberg <tklingenberg@lastflood.net>
This commit is contained in:
Tomas Votruba 2020-12-29 18:01:51 +01:00 committed by GitHub
parent a43d3e3863
commit 1850a2dcc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,7 @@
<?php
namespace Rector\Renaming\Tests\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\Fixture;
class DateTime
{
}

View File

@ -0,0 +1,15 @@
<?php
namespace Rector\Renaming\Tests\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector\Fixture;
class PreslashedBug
{
/**
* @param \DateTime $time1
* @return int
*/
public function test(\DateTime $time1)
{
return $time1->getOffset();
}
}

View File

@ -128,7 +128,7 @@ final class ObjectTypeSpecifier
return null;
}
$namespacedObject = $namespaceName . '\\' . $objectType->getClassName();
$namespacedObject = $namespaceName . '\\' . ltrim($objectType->getClassName(), '\\');
if (ClassExistenceStaticHelper::doesClassLikeExist($namespacedObject)) {
return new FullyQualifiedObjectType($namespacedObject);

View File

@ -80,6 +80,7 @@ final class ValidateFixtureSuffixCommand extends Command
->notPath('Namespace_/ImportFullyQualifiedNamesRector/Fixture/SharedShortName.php')
->notPath('Name/RenameClassRector/Fixture/DuplicatedClass.php')
->notPath('Rector/FileNode/RenameSpecFileToTestFileRector/Fixture/some_file_Spec.php')
->notPath('Rector/FileWithoutNamespace/PseudoNamespaceToNamespaceRector/Fixture/DateTime.php')
->in(__DIR__ . '/../../../../tests')
->in(__DIR__ . '/../../../../packages/*/tests')
->in(__DIR__ . '/../../../../rules/*/tests');