-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: PhpUnitStrictFixer
- do not crash on property having the name of method to fix
#7804
fix: PhpUnitStrictFixer
- do not crash on property having the name of method to fix
#7804
Conversation
@@ -686,17 +686,25 @@ public static function provideFunctionReturnTypeInfoPre80Cases(): iterable | |||
|
|||
/** | |||
* @dataProvider provideIsTheSameClassCallCases | |||
* | |||
* @param list<int> $sameClassCallIndices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list ❤️
{ | ||
$tokens = Tokens::fromCode($code); | ||
$analyzer = new FunctionsAnalyzer(); | ||
|
||
self::assertSame($isTheSameClassCall, $analyzer->isTheSameClassCall($tokens, $index)); | ||
for ($index = $tokens->count(); $index >= 0; --$index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for ($index = $tokens->count(); $index >= 0; --$index) { | |
for ($index = $tokens->count() - 1; $index >= 0; --$index) { |
if we have size==2, then array[2]
doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous tests had checked for -1
: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.49.0/tests/Tokenizer/Analyzer/FunctionsAnalyzerTest.php#L711-L715
Maybe we want to throw an error for a non-existing index? Definitely, we want to check what will happen if the non-existing index is given.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me code looks very counterintuitive to iterate over all existing indexes plus one non-existing , out of the blue it looks almost like a typo error to be fixed (even by sca detecting calling $array[non-exist-index]
, if sca advanced enough).
i would encourage to have dedicated check for non-existing index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to throw an error for a non-existing index?
out of the blue sounds like possible variant, probably how I would drive it if creating this function from scratch [~indexoutofboundsexception].
we could check how code would react, i hope we do not rely on this existing behaviour to return false instead of error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.