Skip to content

Conversation

@samsonasik
Copy link
Member

Given the folllowing code:

final class UniqueTypeSingle
{
    public function getExtensions(): array
    {
        return [
            new \DateTime('now'),
            new \DateTime('tomorrow'),
        ];
    }
}

It got diff:

+    /**
+     * @return \DateTimeInterface[]
+     */
     public function getExtensions(): array
     {
        return [
            new \DateTime('now'),
            new \DateTime('tomorrow'),
        ];
    }

which should use \DateTime only, as all unique type is single. On complex application, it can cause PHPStan notice that not instanceof type

  - '#Parameter \#1 \$abc of method XYZ expects \DateTimeInterface, \DateTime given#'
  🪪 argument.type

…ddReturnDocblockForCommonObjectDenominatorRector
@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @TomasVotruba

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 9e93740 into main Sep 12, 2025
49 checks passed
@samsonasik samsonasik deleted the use-single-type branch September 12, 2025 12:13
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.

2 participants