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:
parent
7c10a09ead
commit
695ececc22
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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";',
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user