1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Ensure that explode($d, lowercase-string) produces list<lowercase-string> types

This specific distinction seems to be very important for Psalm, as `explode()` and
`lowercase-string` are used aggressively across the codebase.

Also, this change expands the baseline by a few entries, since some of the code locations
instide Psalm itself have un-checked list destructuring operations, as well as array
access calls on potentially undefined array keys produced by `explode()`, which were
previously just `list<string>`, and are now `array{0: string, 1?: string}`, which is
a bit more precise.
This commit is contained in:
Marco Pivetta 2022-12-28 17:26:25 +01:00
parent 04999b172a
commit bfded43614
2 changed files with 41 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="dev-master@6fc9e50b9765d573db796e81522af759bc6987a5">
<files psalm-version="dev-master@dbcfe62c5224603912c94c1eab5d7c31841ada82">
<file src="examples/TemplateChecker.php">
<PossiblyUndefinedIntArrayOffset>
<code>$comment_block-&gt;tags['variablesfrom'][0]</code>
@ -296,6 +296,12 @@
<code>$b[$y]</code>
</InvalidArrayOffset>
</file>
<file src="src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php">
<PossiblyUndefinedArrayOffset>
<code>$exploded[1]</code>
<code>$url</code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php">
<PossiblyUndefinedIntArrayOffset>
<code>$stmt-&gt;props[0]</code>
@ -379,9 +385,9 @@
<PossiblyInvalidArrayOffset>
<code>$fixed_type_tokens[$i - 1]</code>
</PossiblyInvalidArrayOffset>
<PossiblyUndefinedIntArrayOffset>
<PossiblyUndefinedArrayOffset>
<code>$source_param_string</code>
</PossiblyUndefinedIntArrayOffset>
</PossiblyUndefinedArrayOffset>
</file>
<file src="src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php">
<PossiblyUndefinedIntArrayOffset>
@ -695,6 +701,8 @@
<PossiblyUnusedMethod>
<code>allFloatLiterals</code>
<code>allFloatLiterals</code>
<code>hasLowercaseString</code>
<code>hasLowercaseString</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Internal/Codebase/InternalCallMapHandlerTest.php">

View File

@ -728,18 +728,38 @@ function join($separator, array $array = []): string
* @param non-empty-string $separator
*
* @return (
* $limit is int<min, -2>
* ? array<empty, empty>
* : (
* $limit is int<0, 1>
* ? array{string}
* $string is lowercase-string
* ? (
* $limit is int<min, -2>
* ? array<empty, empty>
* : (
* $limit is 2
* ? array{0: string, 1?: string}
* $limit is int<0, 1>
* ? array{lowercase-string}
* : (
* $limit is 3
* ? array{0: string, 1?: string, 2?: string}
* : non-empty-list<string>
* $limit is 2
* ? array{0: lowercase-string, 1?: lowercase-string}
* : (
* $limit is 3
* ? array{0: lowercase-string, 1?: lowercase-string, 2?: lowercase-string}
* : non-empty-list<lowercase-string>
* )
* )
* )
* )
* : (
* $limit is int<min, -2>
* ? array<empty, empty>
* : (
* $limit is int<0, 1>
* ? array{string}
* : (
* $limit is 2
* ? array{0: string, 1?: string}
* : (
* $limit is 3
* ? array{0: string, 1?: string, 2?: string}
* : non-empty-list<string>
* )
* )
* )
* )