-
Notifications
You must be signed in to change notification settings - Fork 574
Fix phpstan/phpstan#14308: Offset 0 should not be optional on non empty list #5236
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
Changes from 6 commits
731b503
7a66ada
fdb4d05
8dfe8e6
34cda84
cca316e
81f9466
99fcf00
b5efc6a
a091de0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace Bug14308; | ||
|
|
||
| use RuntimeException; | ||
| use function PHPStan\Testing\assertType; | ||
|
|
||
| function getUi(string $s1, string $s2, string $s3): string | ||
| { | ||
| $available = array_keys(array_filter([ | ||
| 'swagger' => $s1, | ||
| 'redoc' => $s2, | ||
| 'scalar' => $s3, | ||
| ])); | ||
|
|
||
| if ([] === $available) { | ||
| throw new RuntimeException('No documentation UI is enabled.'); | ||
| } | ||
|
|
||
| assertType("list{0: 'redoc'|'scalar'|'swagger', 1?: 'redoc'|'scalar', 2?: 'scalar'}", $available); | ||
|
|
||
| return $available[0]; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -404,14 +404,6 @@ public static function dataToPhpDocNode(): iterable | |
| 'list{0?: string, 1?: string, 2?: string, 3?: string}', | ||
| ]; | ||
|
|
||
| yield [ | ||
| new IntersectionType([ | ||
| $listArrayWithAllOptionalKeys, | ||
| new NonEmptyArrayType(), | ||
| ]), | ||
| 'non-empty-list{0?: string, 1?: string, 2?: string, 3?: string}', | ||
| ]; | ||
|
Comment on lines
-407
to
-413
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the need to drop a test?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test was testing that the type is transformed into the description and the description is transformed into the type. But it's not true anymore. While is transformed into 'list{0: string, 1?: string, 2?: string, 3?: string}', the opposite is not true. This has to be a TypeCombinator test instead.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All review comments addressed and pushed. Here's a summary of the changes:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already handled — all 11588 tests passed and the commit has been pushed. |
||
|
|
||
| $constantArrayWithAllOptionalKeys = new ConstantArrayType([ | ||
| new ConstantIntegerType(0), | ||
| new ConstantIntegerType(1), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.