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
ltrim(class-string, '\\') should return a class-string #8218
Comments
I found these snippets: https://psalm.dev/r/b6ecdc9b09<?php
/**
* Removes the prepended backslash of a class string to conform with how php outputs class names
*
* @psalm-param class-string $className
*
* @psalm-return class-string
*/
function normalizeClassName(string $className): string
{
return ltrim($className, '\\');
}
|
I have very little knowledge of the inner working of psalm, but would 4.x...Tofandel:psalm:patch-1 Or is something like this possible: Edit: |
Tofandel
added a commit
to Tofandel/psalm
that referenced
this issue
Jul 6, 2022
orklah
added a commit
that referenced
this issue
Jul 6, 2022
fix: ltrim may return class-string #8218
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using
2 errors will be thrown
It would be a nice addition to avoid this false negatives as this specific ltrim of a class string will always result in the same class-string being returned
Psalm should detect this very specific ltrim call if the input is a class-string and in that case infer a class-string type instead of a string
This issue also exists for phpstan phpstan/phpstan#7483
The text was updated successfully, but these errors were encountered: