1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Add tests for 7c10a09

This commit is contained in:
Matthew Brown 2018-08-08 22:44:02 -04:00
parent 7c10a09ead
commit 695ececc22
3 changed files with 25 additions and 1 deletions

View File

@ -1623,6 +1623,18 @@ class AnnotationTest extends TestCase
class A {}',
'error_message' => 'InvalidDocblock',
],
'typeAliasInObjectLike' => [
'<?php
/**
* @psalm-type aType null|"a"|"b"|"c"|"d"
*/
/** @psalm-return array{0:bool,1:aType} */
function f(): array {
return [(bool)rand(0,1), rand(0,1) ? "z" : null];
}',
'error_message' => 'InvalidReturnStatement',
],
];
}
}

View File

@ -903,6 +903,18 @@ class FunctionCallTest extends TestCase
if ($b === false) {}
$c = new $b();',
],
'arraySplice' => [
'<?php
$a = [1, 2, 3];
$c = $a;
$b = ["a", "b", "c"];
array_splice($a, -1, 1, $b);',
'assertions' => [
'$a' => 'array<int, string|int>',
'$b' => 'array{0:string, 1:string, 2:string}',
'$c' => 'array{0:int, 1:int, 2:int}',
],
],
];
}

View File

@ -236,7 +236,7 @@ echo $a;';
function fooFoo() {
return "hello";
}',
'message' => "The type 'string' does not match the declared return type 'int' for fooFoo",
'message' => "The type 'string(hello)' does not match the declared return type 'int' for fooFoo",
'line' => 6,
'error' => 'return "hello";',
],