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

Add @psalm-check-type and @psalm-check-type-exact. #7686

Merged
merged 1 commit into from Feb 17, 2022

Conversation

AndrolGenhald
Copy link
Collaborator

@AndrolGenhald AndrolGenhald commented Feb 17, 2022

I initially added these as part of my TryAnalyzer rewrite to allow testing complicated finally types like this:

$foo = 1;
try {
        $foo = 2;
} catch (Exception $_) {
        $foo = 3;
} finally {
        $bar = $foo;
        /** @psalm-check-type-exact $bar = 1|2|3 */;
}
/** @psalm-check-type-exact $bar = 2|3 */;

Using the 'assertions' in tests doesn't work since the type is different inside the finally.

I decided to extract the new annotation from the rest of my changes and do a separate pull request since I think others may find it useful, and it should be much easier to review than the entire TryAnalyzer rewrite.

@AndrolGenhald AndrolGenhald added the release:feature The PR will be included in 'Features' section of the release notes label Feb 17, 2022
I initially added these as part of my TryAnalyzer rewrite to allow testing complicated `finally` types like this:
```
$foo = 1;
try {
        $foo = 2;
} catch (Exception $_) {
        $foo = 3;
} finally {
        $bar = $foo;
        /** @psalm-check-type-exact $bar = 1|2|3 */;
}
/** @psalm-check-type-exact $bar = 2|3 */;
```
Using the `'assertions'` in tests doesn't work since the type is different inside the `finally`.

I decided to extract the new annotation from the rest of my changes and do a separate pull request since I think others may find it useful, and it should be much easier to review than the entire TryAnalyzer rewrite.
@orklah
Copy link
Collaborator

orklah commented Feb 17, 2022

That's so freaking great! I wanted something like that for ages!

@orklah orklah merged commit ec95244 into vimeo:master Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature The PR will be included in 'Features' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants