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

[Php74] Do not remove Array Shape docblock on TypedPropertyRector #1466

Merged
merged 5 commits into from
Dec 11, 2021

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Dec 11, 2021

Given the following code:

final class DoNotRemoveArrayShapeDocblock
{
    /**
     * @var array{a: \stdClass[], b: \DateTime[]}
     */
    private $property = [
        'a' => [],
        'b' => [],
    ];

    public function getProperty()
    {
        if ($this->property['a'] === [] && $this->property['b'] === []) {
            $this->property['a'] = [new stdClass()];
            $this->property['b'] = [new \DateTime()];
        }

        return $this->property;
    }
}

It currently produce:

-    /**
-     * @var array{a: \stdClass[], b: \DateTime[]}
-     */
-    private $property = [
+    private array $property = [

which docblock shoult not be removed.

This PR try to fix it.

@samsonasik samsonasik changed the title [Php74] Do not remove curly array docblock on TypedPropertyRector [Php74] Do not remove Array Shape docblock on TypedPropertyRector Dec 11, 2021
@samsonasik
Copy link
Member Author

Fixed 🎉

@samsonasik
Copy link
Member Author

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

@TomasVotruba TomasVotruba merged commit 6c96e01 into main Dec 11, 2021
@TomasVotruba TomasVotruba deleted the do-not-remove-curly-array-docblock branch December 11, 2021 16:04
@TomasVotruba
Copy link
Member

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants