-
-
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
test: Improve ExplicitIndirectVariableFixerTest
#7451
test: Improve ExplicitIndirectVariableFixerTest
#7451
Conversation
935bb34
to
d5b086d
Compare
@@ -33,29 +33,32 @@ public function testFix(string $expected, ?string $input = null): void | |||
$this->doTest($expected, $input); | |||
} | |||
|
|||
/** | |||
* @return iterable<string, array{0: string, 1?: null|string}> |
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.
* @return iterable<string, array{0: string, 1?: null|string}> | |
* @return iterable<string, array{0: string, 1?: string}> |
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.
Technically it's possible to return null
explicitly as a second array item and it will work, because testFix
signature allows it. I just reflected the actual contract 🙂.
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.
it's technically possible to provide null to testFix
, but I wouldn't like to have provider explicitly returning null.
IMHO we shall have same approaches for all providers, i was always using 1?: string
. if you want to change approach, please change for whole project.
but again, i would avoid provider returning null, either 0: string, 1?: string
or 0: string, 1: null|string
. combining ?
with |null
is overkill and bringing more than one way to provide data cases
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.
I agree, but it's forward-compatible with providers returning more than 2 elements, e.g. rules configuration. I am pretty sure there are already places where input is explicitly returned as null
because of that.
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.
@keradus the example: signature + test case with explicit null
as the input value. I know it can be changed later if third argument is introduced, but I think it's good to describe existing contract from the beginning.
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.
LGTM, the discussion about the PHPDoc is not really related to the topic of this PR, I believe we can shift such discussion to separate conversations.
d5b086d
to
1f3e726
Compare
--testdox
output)iterable
type for PHPStanRelated to #7442.