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

[Symfony 6.4] Add DataTransformerInterface return types #624

Merged
merged 1 commit into from
Jun 22, 2024

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Jun 22, 2024

Ref #537

@TomasVotruba TomasVotruba enabled auto-merge (squash) June 22, 2024 17:44
@TomasVotruba TomasVotruba merged commit 2357ee7 into main Jun 22, 2024
5 checks passed
@TomasVotruba TomasVotruba deleted the tv-symfony-70-types branch June 22, 2024 17:45
@trsteel88
Copy link
Contributor

@TomasVotruba is this forcing a return type on DataTransformers in symfony?

I have the following

public function reverseTransform(mixed $value): ?string
    {
        if (null === $value || '' === (string) $value) {
            return null;
        }

        return 'foo';
    }

But rector is changing this to:

public function reverseTransform(mixed $value): object|string
    {
        if (null === $value || '' === (string) $value) {
            return null;
        }

        return 'foo';
    }

But this isn't correct. It can only be ?string so now I have PHPStan failing on me:

::reverseTransform() should return object|string but returns null.  

@trsteel88
Copy link
Contributor

Ah using the 71 set instead of 64 fixed it.

$rectorConfig->import(Rector\Symfony\Set\SymfonySetList::SYMFONY_71);

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