-
Notifications
You must be signed in to change notification settings - Fork 678
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 dirname return type provider #8611
Add dirname return type provider #8611
Conversation
Seems great! Two issues left to resolve, the Typeprovider should be marked @internal and a test broke due to your PR resolving the type more precisely, you can just replace the literal-string by the literal value |
Changed: - Replaced extraction of `$dir_level` literal value to be from the NodeTypeProvider instead of from the statement; based on similar logic in `RoundReturnTypeProvider`. - Replaced `new` return type creation with `Type` method creation. - Replaced `null` return with string type. Fixed: - Typo on variable name for extracted `StatementsSource`. - Edge case where `$dir_level` is less than 1. - Broken unit tests.
Thanks for the feedback. Both issues have now been resolved. |
Thanks! |
@mcaskill could you do the same PR for |
@kkmuffme I should be able to add As for Just this morning, I realized the following use case does not work for $path = "a/b/c";
$dir = dirname($path); // ← return type is evaluated as 'string' instead of literal string |
I found these snippets: https://psalm.dev/r/1708b073c2<?php
/** @psalm-trace $foo */
$foo = __DIR__;
/** @psalm-trace $baz */
$baz = dirname( $foo );
echo $baz;
|
Like dirname return type provider of vimeo#8611
Like dirname return type provider of vimeo#8611
Resolves #7344
Replaces #8609:
master
)