Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Renaming] Handle var static docblock in union on RenameClassRector #1248

Merged
merged 17 commits into from
Nov 16, 2021

Conversation

samsonasik
Copy link
Member

Given the following code:

class VarStaticInUnion extends \DateTime
{
    /**
     * @var DateTime|static|null
     */
    private $dateTime;
}

It currently produce error:

There was 1 error:

1) Rector\Tests\Renaming\Rector\Name\RenameClassRector\RenameClassRectorTest::test with data set #17 (Symplify\SmartFileSystem\SmartFileInfo Object (...))
TypeError: Rector\StaticTypeMapper\PhpDocParser\IdentifierTypeMapper::mapStatic(): Argument #1 ($scope) must be of type PHPStan\Analyser\Scope, null given, called in /Users/samsonasik/www/rector-src/packages/StaticTypeMapper/PhpDocParser/IdentifierTypeMapper.php on line 81

@samsonasik samsonasik changed the title [Renaming] Handle var sstatic docblock in union on RenameClassRector [Renaming] Handle var static docblock in union on RenameClassRector Nov 16, 2021
@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

I added another failing fixture for array static[]

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

I added another failing fixture for array<static>

@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik
Copy link
Member Author

@TomasVotruba I moved the check for special classname to IdentifierTypeMapper

@samsonasik samsonasik force-pushed the handle-error-var-static-in-union branch from 84c3631 to 3b2921a Compare November 16, 2021 02:28
@samsonasik
Copy link
Member Author

@TomasVotruba It seems moving check to IdentifierTypeMapper cause error in other places, rolled back to DocBlockClassRenamer

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik
Copy link
Member Author

@TomasVotruba I am trying move check into IdentifierTypeMapper by look ClassReflection from Node instance. da35702

@samsonasik
Copy link
Member Author

It works 🎉

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@TomasVotruba
Copy link
Member

Very nice cleanup 👍

@samsonasik samsonasik merged commit 50096d7 into main Nov 16, 2021
@samsonasik samsonasik deleted the handle-error-var-static-in-union branch November 16, 2021 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants