-
Notifications
You must be signed in to change notification settings - Fork 653
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-flow for string functions from sscanf to wordwrap #4591
Conversation
ebf3372
to
a564b67
Compare
Any pointers why the following test is failing? I defined the second argument as psalm/tests/FunctionCallTest.php Lines 504 to 515 in 494ec40
|
The test was added along with the fix for #915, and was probably related to how Psalm selects the overloaded signature (
That's too wide. It should be either string or array, depending on the number of parameters (string for 3 arg signature and array for 2). |
I was wrong. I looked at the wrong docs. https://www.php.net/manual/en/function.strtr.php and https://www.php.net/manual/en/function.strstr.php were confusing me :) |
src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php
Outdated
Show resolved
Hide resolved
Side-note: could someone elaborate why/when psalm-flow should be used? Its not documented.. is it a psalm internal-only phpdoc? |
See #4587 (comment) |
This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of vimeo#4576 Ref vimeo#3636
bc3f378
to
4629a7d
Compare
This should be ready to review now. For |
The error being thrown is from https://github.com/sebastianbergmann/phpunit/blob/58f69d18fd1e61b54c18cf9d06b762507be55562/src/TextUI/DefaultResultPrinter.php#L149-L154: if (!in_array($colors, self::AVAILABLE_COLORS, true)) {
throw InvalidArgumentException::create(
3,
vsprintf('value from "%s", "%s" or "%s"', self::AVAILABLE_COLORS)
);
} As per php.net:
And the code doesn't check for false. - Should this be accepted behaviour? For psalm/stubs/CoreGenericFunctions.phpstub Lines 755 to 762 in bf873b2
|
Thanks! Possibly-false returns in standard library functions are annoying. In > 99.9% of their common usage those functions don’t return |
I have a few differents false positives that popped in my work codebase that seems related to this PR. I'll need to verify them and post issues but if someone is faster than me:
|
* Add string functions from sscanf to wordwrap This should conclude all string functions from https://www.php.net/manual/en/book.strings.php Continuation of vimeo#4576 Ref vimeo#3636 * Add StrTrReturnTypeProvider * Fix psalm error * phpcs * Line length * Ignore false return on vsprintf Co-authored-by: Matthew Brown <github@muglug.com>
This should conclude all string functions from https://www.php.net/manual/en/book.strings.php
Continuation of #4576
Ref #3636
TODO