mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Adjusted assertDifferentTypeOfArray
test to avoid intersecting incompatible string arrays
Getting one interesting failure caused by the `lowercase-string` refinement done before: ``` There was 1 error: 1) Psalm\Tests\AssertAnnotationTest::testValidCode with data set "assertDifferentTypeOfArray" ('<?php\n /*...ts[1];') Psalm\Exception\CodeException: DocblockTypeContradiction - src/somefile.php:21:21 - Cannot resolve types for $parts - docblock-defined type list{0: lowercase-string, 1?: lowercase-string} does not contain list{string, string} ``` Happens on this bit: ```php 'assertDifferentTypeOfArray' => [ 'code' => '<?php /** * @psalm-assert list{string, string} $value * @param mixed $value */ function isStringTuple($value): void { if (!is_array($value) || !isset($value[0]) || !isset($value[1]) || !is_string($value[0]) || !is_string($value[1]) ) { throw new \Exception("bad"); } } $s = ""; $parts = explode(":", $s, 2); isStringTuple($parts); echo $parts[0]; echo $parts[1];', ], ``` If I change this to: ``` @psalm-assert list{lowercase-string, lowercase-string} $value ``` Then everything works: I'm wondering if this error has to do with array intersections, and whether suppressing it suffices. For now, changing the input string, so it is not a `lowercase-string`, is sufficient.
This commit is contained in:
parent
c0c0116809
commit
45f743f851
@ -1006,7 +1006,7 @@ class AssertAnnotationTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
$s = "";
|
||||
$s = "Hello World!";
|
||||
|
||||
$parts = explode(":", $s, 2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user