-
Notifications
You must be signed in to change notification settings - Fork 463
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/issue 7144 #1299
Fix/issue 7144 #1299
Conversation
I think that somehow, you need to handle multidimensional arrays too. The new error in CI is a false-positive: https://github.com/composer/composer/blob/3ae111140facdba8ae82adcd1085e4adfc7d715c/src/Composer/Util/Http/CurlDownloader.php#L230-L236
|
@ondrejmirtes To solve this case we need to implement type specification of Maybe I should solve these issues before this PR to avoid these kind of regressions (I'm looking into these issues but not easy to solve...) |
if (isset($options[$type][$name])) { | ||
\PHPStan\Testing\assertType('array{http: array, ssl?: array}', $options); | ||
if ($type === 'ssl' && $name === 'verify_peer_name') { | ||
\PHPStan\Testing\assertType('array{http: array, ssl?: array}', $options); |
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.
The goal for #1299 (comment) is to make $options[$type]
specified by isset
and also from $type === 'ssl'
the array type can be array{http: array, ssl: array}
(which looks not that easy to solve, because it is a result of multiple conditional expressions)
I'm happy with the improved type inference of this PR, I just don't want this code https://github.com/composer/composer/blob/3ae111140facdba8ae82adcd1085e4adfc7d715c/src/Composer/Util/Http/CurlDownloader.php#L230-L236 to report these errors:
Because the code involves expressions like |
I had investigated this issue in #1187.
this part is not true due to phpstan-src/src/Analyser/MutatingScope.php Lines 4358 to 4365 in 6f1535a
I tried to remove this line, but was not sure how to solve the failing tests. I'll look into it again!:+1: |
The linked lines are supposed to be just an optimization that we might be able to remove I think. (But it's a long time since I touched these parts last time). |
fixes phpstan/phpstan#7144
The root cause of this issue is expressed in this test dc5e865.
When specifying
ArrayDimFetch
type, it was relying only on$dimType
, which can be any type as seen in the test.The type to be specified should be only be a key existing in array`.