2019-11-30 05:46:21 +01:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2019-11-30 05:46:21 +01:00
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2021-12-04 21:55:53 +01:00
|
|
|
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
|
|
|
|
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
|
|
|
|
|
2020-08-22 16:00:36 +02:00
|
|
|
use const DIRECTORY_SEPARATOR;
|
|
|
|
|
2019-11-30 05:46:21 +01:00
|
|
|
class ClosureTest extends TestCase
|
|
|
|
{
|
2021-12-04 21:55:53 +01:00
|
|
|
use InvalidCodeAnalysisTestTrait;
|
|
|
|
use ValidCodeAnalysisTestTrait;
|
2019-11-30 05:46:21 +01:00
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerValidCodeParse(): iterable
|
2019-11-30 05:46:21 +01:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'byRefUseVar' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/** @return void */
|
|
|
|
function run_function(\Closure $fnc) {
|
|
|
|
$fnc();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @psalm-suppress MixedArgument
|
|
|
|
*/
|
|
|
|
function f() {
|
|
|
|
run_function(
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function() use(&$data) {
|
|
|
|
$data = 1;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
echo $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
f();',
|
|
|
|
],
|
|
|
|
'inferredArg' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$bar = ["foo", "bar"];
|
|
|
|
|
|
|
|
$bam = array_map(
|
|
|
|
function(string $a) {
|
|
|
|
return $a . "blah";
|
|
|
|
},
|
|
|
|
$bar
|
|
|
|
);',
|
|
|
|
],
|
|
|
|
'inferredArgArrowFunction' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$bar = ["foo", "bar"];
|
|
|
|
|
|
|
|
$bam = array_map(
|
|
|
|
fn(string $a) => $a . "blah",
|
|
|
|
$bar
|
|
|
|
);',
|
2020-08-23 16:32:07 +02:00
|
|
|
'assertions' => [],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
'varReturnType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$add_one = function(int $a) : int {
|
|
|
|
return $a + 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
$a = $add_one(1);',
|
|
|
|
'assertions' => [
|
|
|
|
'$a' => 'int',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'varReturnTypeArray' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$add_one = fn(int $a) : int => $a + 1;
|
|
|
|
|
|
|
|
$a = $add_one(1);',
|
|
|
|
'assertions' => [
|
|
|
|
'$a' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
'correctParamType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$take_string = function(string $s): string { return $s; };
|
|
|
|
$take_string("string");',
|
|
|
|
],
|
|
|
|
'arrayMapClosureVar' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$mirror = function(int $i) : int { return $i; };
|
|
|
|
$a = array_map($mirror, [1, 2, 3]);',
|
|
|
|
'assertions' => [
|
2022-11-12 02:14:21 +01:00
|
|
|
'$a' => 'list{int, int, int}',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'inlineCallableFunction' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {
|
|
|
|
function bar(): void {
|
|
|
|
function foobar(int $a, int $b): int {
|
|
|
|
return $a > $b ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$arr = [5, 4, 3, 1, 2];
|
|
|
|
|
|
|
|
usort($arr, "fooBar");
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
'closureSelf' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var self[]
|
|
|
|
*/
|
|
|
|
private $subitems;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param self[] $in
|
|
|
|
*/
|
|
|
|
public function __construct(array $in = [])
|
|
|
|
{
|
|
|
|
array_map(function(self $i): self { return $i; }, $in);
|
|
|
|
|
|
|
|
$this->subitems = array_map(
|
|
|
|
function(self $i): self {
|
|
|
|
return $i;
|
|
|
|
},
|
|
|
|
$in
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new A([new A, new A]);',
|
|
|
|
],
|
|
|
|
'arrayMapVariadicClosureArg' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$a = array_map(
|
|
|
|
function(int $type, string ...$args):string {
|
|
|
|
return "hello";
|
|
|
|
},
|
|
|
|
[1, 2, 3]
|
|
|
|
);',
|
|
|
|
],
|
|
|
|
'returnsTypedClosure' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure(int):int $f
|
|
|
|
* @param Closure(int):int $g
|
|
|
|
*
|
|
|
|
* @return Closure(int):int
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (int $x) use ($f, $g) : int {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureArrow' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure(int):int $f
|
|
|
|
* @param Closure(int):int $g
|
|
|
|
*
|
|
|
|
* @return Closure(int):int
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return fn(int $x):int => $f($g($x));
|
|
|
|
}',
|
2020-08-23 16:32:07 +02:00
|
|
|
'assertions' => [],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
'returnsTypedClosureWithClasses' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C):A
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (C $x) use ($f, $g) : A {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
$a = foo(
|
|
|
|
function(B $b) : A { return new A;},
|
|
|
|
function(C $c) : B { return new B;}
|
|
|
|
)(new C);',
|
|
|
|
'assertions' => [
|
|
|
|
'$a' => 'A',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithSubclassParam' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
class C2 extends C {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C2):A
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (C $x) use ($f, $g) : A {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
$a = foo(
|
|
|
|
function(B $b) : A { return new A;},
|
|
|
|
function(C $c) : B { return new B;}
|
|
|
|
)(new C2);',
|
|
|
|
'assertions' => [
|
|
|
|
'$a' => 'A',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithParentReturn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
class A2 extends A {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A2 $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C):A
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (C $x) use ($f, $g) : A2 {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
$a = foo(
|
|
|
|
function(B $b) : A2 { return new A2;},
|
|
|
|
function(C $c) : B { return new B;}
|
|
|
|
)(new C);',
|
|
|
|
'assertions' => [
|
|
|
|
'$a' => 'A',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'inferArrayMapReturnTypeWithoutTypehints' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
2022-11-12 02:14:21 +01:00
|
|
|
* @param array{0:string,1:string}[] $ret
|
|
|
|
* @return array{0:string,1:int}[]
|
2019-11-30 05:46:21 +01:00
|
|
|
*/
|
|
|
|
function f(array $ret) : array
|
|
|
|
{
|
|
|
|
return array_map(
|
|
|
|
/**
|
2022-11-12 02:14:21 +01:00
|
|
|
* @param array{0:string,1:string} $row
|
2019-11-30 05:46:21 +01:00
|
|
|
*/
|
|
|
|
function (array $row) {
|
|
|
|
return [
|
|
|
|
strval($row[0]),
|
|
|
|
intval($row[1]),
|
|
|
|
];
|
|
|
|
},
|
|
|
|
$ret
|
|
|
|
);
|
|
|
|
}',
|
|
|
|
'assertions' => [],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => ['MissingClosureReturnType'],
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
'inferArrayMapReturnTypeWithTypehints' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
2022-11-12 02:14:21 +01:00
|
|
|
* @param array{0:string,1:string}[] $ret
|
|
|
|
* @return array{0:string,1:int}[]
|
2019-11-30 05:46:21 +01:00
|
|
|
*/
|
|
|
|
function f(array $ret): array
|
|
|
|
{
|
|
|
|
return array_map(
|
|
|
|
/**
|
2022-11-12 02:14:21 +01:00
|
|
|
* @param array{0:string,1:string} $row
|
2019-11-30 05:46:21 +01:00
|
|
|
*/
|
|
|
|
function (array $row): array {
|
|
|
|
return [
|
|
|
|
strval($row[0]),
|
|
|
|
intval($row[1]),
|
|
|
|
];
|
|
|
|
},
|
|
|
|
$ret
|
|
|
|
);
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
'invokableProperties' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {
|
|
|
|
public function __invoke(): bool { return true; }
|
|
|
|
}
|
|
|
|
|
|
|
|
class C {
|
|
|
|
/** @var A $invokable */
|
|
|
|
private $invokable;
|
|
|
|
|
|
|
|
public function __construct(A $invokable) {
|
|
|
|
$this->invokable = $invokable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function callTheInvokableDirectly(): bool {
|
|
|
|
return ($this->invokable)();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function callTheInvokableIndirectly(): bool {
|
|
|
|
$r = $this->invokable;
|
|
|
|
return $r();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'mirrorCallableParams' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
namespace NS;
|
|
|
|
use Closure;
|
|
|
|
/** @param Closure(int):bool $c */
|
|
|
|
function acceptsIntToBool(Closure $c): void {}
|
|
|
|
|
|
|
|
acceptsIntToBool(Closure::fromCallable(function(int $n): bool { return $n > 0; }));',
|
|
|
|
],
|
|
|
|
'singleLineClosures' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$a = function() : Closure { return function() : string { return "hello"; }; };
|
|
|
|
$b = $a()();',
|
|
|
|
'assertions' => [
|
2022-01-16 16:07:56 +01:00
|
|
|
'$a' => 'pure-Closure():pure-Closure():string',
|
2019-11-30 05:46:21 +01:00
|
|
|
'$b' => 'string',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'voidReturningArrayMap' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
array_map(
|
|
|
|
function(int $i) : void {
|
|
|
|
echo $i;
|
|
|
|
},
|
|
|
|
[1, 2, 3]
|
|
|
|
);',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'closureFromCallableInvokableNamedClass' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
namespace NS;
|
|
|
|
use Closure;
|
|
|
|
|
|
|
|
/** @param Closure(int):bool $c */
|
|
|
|
function acceptsIntToBool(Closure $c): void {}
|
|
|
|
|
|
|
|
class NamedInvokable {
|
|
|
|
public function __invoke(int $p): bool {
|
|
|
|
return $p > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'closureFromCallableInvokableAnonymousClass' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
namespace NS;
|
|
|
|
use Closure;
|
|
|
|
|
|
|
|
/** @param Closure(int):bool $c */
|
|
|
|
function acceptsIntToBool(Closure $c): void {}
|
|
|
|
|
|
|
|
$anonInvokable = new class {
|
|
|
|
public function __invoke(int $p):bool {
|
|
|
|
return $p > 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
acceptsIntToBool(Closure::fromCallable($anonInvokable));',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'publicCallableFromInside' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class Base {
|
|
|
|
public function publicMethod() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Example extends Base {
|
|
|
|
public function test() : Closure {
|
|
|
|
return Closure::fromCallable([$this, "publicMethod"]);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'protectedCallableFromInside' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class Base {
|
|
|
|
protected function protectedMethod() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Example extends Base {
|
|
|
|
public function test() : Closure {
|
|
|
|
return Closure::fromCallable([$this, "protectedMethod"]);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'closureFromCallableNamedFunction' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
$closure = Closure::fromCallable("strlen");
|
|
|
|
',
|
|
|
|
'assertions' => [
|
2022-01-23 20:35:49 +01:00
|
|
|
'$closure' => 'pure-Closure(string):int<0, max>',
|
2022-12-18 17:15:15 +01:00
|
|
|
],
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2019-11-30 05:46:21 +01:00
|
|
|
'allowClosureWithNarrowerReturn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B extends A {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure():A $x
|
|
|
|
*/
|
|
|
|
function accept_closure($x) : void {
|
|
|
|
$x();
|
|
|
|
}
|
|
|
|
accept_closure(
|
|
|
|
function () : B {
|
|
|
|
return new B();
|
|
|
|
}
|
|
|
|
);',
|
|
|
|
],
|
|
|
|
'allowCallableWithWiderParam' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B extends A {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B $a):A $x
|
|
|
|
*/
|
|
|
|
function accept_closure($x) : void {
|
|
|
|
$x(new B());
|
|
|
|
}
|
|
|
|
accept_closure(
|
|
|
|
function (A $a) : A {
|
|
|
|
return $a;
|
|
|
|
}
|
|
|
|
);',
|
|
|
|
],
|
|
|
|
'allowCallableWithOptionalArg' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure():int $x
|
|
|
|
*/
|
|
|
|
function accept_closure($x) : void {
|
|
|
|
$x();
|
|
|
|
}
|
|
|
|
accept_closure(
|
|
|
|
function (int $x = 5) : int {
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
);',
|
|
|
|
],
|
|
|
|
'refineCallableTypeWithTypehint' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/** @param string[][] $arr */
|
|
|
|
function foo(array $arr) : void {
|
|
|
|
array_map(
|
|
|
|
function(array $a) {
|
|
|
|
return reset($a);
|
|
|
|
},
|
|
|
|
$arr
|
|
|
|
);
|
2022-12-18 17:15:15 +01:00
|
|
|
}',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
'refineCallableTypeWithoutTypehint' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/** @param string[][] $arr */
|
|
|
|
function foo(array $arr) : void {
|
|
|
|
array_map(
|
|
|
|
function($a) {
|
|
|
|
return reset($a);
|
|
|
|
},
|
|
|
|
$arr
|
|
|
|
);
|
2022-12-18 17:15:15 +01:00
|
|
|
}',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
2020-04-29 22:52:37 +02:00
|
|
|
'inferGeneratorReturnType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-04-29 22:52:37 +02:00
|
|
|
function accept(Generator $gen): void {}
|
|
|
|
|
|
|
|
accept(
|
|
|
|
(function() {
|
|
|
|
yield;
|
|
|
|
return 42;
|
|
|
|
})()
|
2022-12-18 17:15:15 +01:00
|
|
|
);',
|
2020-04-29 22:52:37 +02:00
|
|
|
],
|
2020-09-01 18:33:25 +02:00
|
|
|
'callingInvokeOnClosureIsSameAsCallingDirectly' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-09-01 18:33:25 +02:00
|
|
|
class A {
|
|
|
|
/** @var Closure(int):int */
|
|
|
|
private Closure $a;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->a = fn(int $a) : int => $a + 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function invoker(int $b) : int {
|
|
|
|
return $this->a->__invoke($b);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'assertions' => [],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2020-09-01 18:33:25 +02:00
|
|
|
],
|
2020-09-19 20:59:19 +02:00
|
|
|
'annotateShortClosureReturn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-09-19 20:59:19 +02:00
|
|
|
/** @psalm-suppress MissingReturnType */
|
|
|
|
function returnsBool() { return true; }
|
|
|
|
$a = fn() : bool => /** @var bool */ returnsBool();',
|
2022-01-13 19:49:37 +01:00
|
|
|
'assertions' => [],
|
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2020-09-19 20:59:19 +02:00
|
|
|
],
|
2020-11-09 21:20:28 +01:00
|
|
|
'rememberParentAssertions' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-11-09 21:20:28 +01:00
|
|
|
class A {
|
|
|
|
public ?A $a = null;
|
|
|
|
public function foo() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
function doFoo(A $a): void {
|
|
|
|
if ($a->a instanceof A) {
|
|
|
|
function () use ($a): void {
|
|
|
|
$a->a->foo();
|
|
|
|
};
|
|
|
|
}
|
2022-12-18 17:15:15 +01:00
|
|
|
}',
|
2020-11-09 21:20:28 +01:00
|
|
|
],
|
2021-03-12 20:05:22 +01:00
|
|
|
'CallableWithArrayMap' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-03-12 20:05:22 +01:00
|
|
|
/**
|
|
|
|
* @psalm-template T
|
|
|
|
* @param class-string<T> $className
|
|
|
|
* @return callable(...mixed):T
|
|
|
|
*/
|
|
|
|
function maker(string $className) {
|
|
|
|
return function(...$args) use ($className) {
|
|
|
|
/** @psalm-suppress MixedMethodCall */
|
|
|
|
return new $className(...$args);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
$maker = maker(stdClass::class);
|
|
|
|
$result = array_map($maker, ["abc"]);',
|
|
|
|
'assertions' => [
|
2022-12-18 17:15:15 +01:00
|
|
|
'$result' => 'list{stdClass}',
|
2021-03-12 20:05:22 +01:00
|
|
|
],
|
|
|
|
],
|
2022-08-24 16:04:22 +02:00
|
|
|
'CallableWithArrayReduce' => [
|
2022-10-16 13:59:15 +02:00
|
|
|
'code' => '<?php
|
2022-08-24 16:04:22 +02:00
|
|
|
/**
|
|
|
|
* @return callable(int, int): int
|
|
|
|
*/
|
|
|
|
function maker() {
|
|
|
|
return function(int $sum, int $e) {
|
|
|
|
return $sum + $e;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
$maker = maker();
|
|
|
|
$result = array_reduce([1, 2, 3], $maker, 0);',
|
|
|
|
'assertions' => [
|
2022-12-18 17:15:15 +01:00
|
|
|
'$result' => 'int',
|
2022-08-24 16:04:22 +02:00
|
|
|
],
|
|
|
|
],
|
2021-12-09 04:26:31 +01:00
|
|
|
'FirstClassCallable:NamedFunction:is_int' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
$closure = is_int(...);
|
|
|
|
$result = $closure(1);
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$closure' => 'pure-Closure(mixed):bool',
|
|
|
|
'$result' => 'bool',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
|
|
|
'FirstClassCallable:NamedFunction:strlen' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
$closure = strlen(...);
|
|
|
|
$result = $closure("test");
|
|
|
|
',
|
|
|
|
'assertions' => [
|
2022-01-23 20:35:49 +01:00
|
|
|
'$closure' => 'pure-Closure(string):int<0, max>',
|
|
|
|
'$result' => 'int<0, max>',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2021-12-27 21:29:33 +01:00
|
|
|
'FirstClassCallable:InstanceMethod:UserDefined' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
class Test {
|
|
|
|
public function __construct(private readonly string $string) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function length(): int {
|
|
|
|
return strlen($this->string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$test = new Test("test");
|
|
|
|
$closure = $test->length(...);
|
|
|
|
$length = $closure();
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2022-01-22 17:37:35 +01:00
|
|
|
'FirstClassCallable:InstanceMethod:Expr' => [
|
2022-01-23 23:44:04 +01:00
|
|
|
'code' => '<?php
|
2022-01-22 17:37:35 +01:00
|
|
|
class Test {
|
|
|
|
public function __construct(private readonly string $string) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function length(): int {
|
|
|
|
return strlen($this->string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$test = new Test("test");
|
|
|
|
$method_name = "length";
|
|
|
|
$closure = $test->$method_name(...);
|
|
|
|
$length = $closure();
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-23 23:44:04 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2022-01-22 17:37:35 +01:00
|
|
|
],
|
2021-12-27 21:29:33 +01:00
|
|
|
'FirstClassCallable:InstanceMethod:BuiltIn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
$queue = new \SplQueue;
|
|
|
|
$closure = $queue->count(...);
|
|
|
|
$count = $closure();
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$count' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
2021-12-09 04:26:31 +01:00
|
|
|
'FirstClassCallable:StaticMethod' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
class Test {
|
|
|
|
public static function length(string $param): int {
|
|
|
|
return strlen($param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$closure = Test::length(...);
|
|
|
|
$length = $closure("test");
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-23 23:44:04 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2022-01-22 17:37:35 +01:00
|
|
|
'FirstClassCallable:StaticMethod:Expr' => [
|
2022-01-23 23:44:04 +01:00
|
|
|
'code' => '<?php
|
2022-01-22 17:37:35 +01:00
|
|
|
class Test {
|
|
|
|
public static function length(string $param): int {
|
|
|
|
return strlen($param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$method_name = "length";
|
|
|
|
$closure = Test::$method_name(...);
|
|
|
|
$length = $closure("test");
|
|
|
|
',
|
2021-12-09 04:26:31 +01:00
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
|
|
|
'FirstClassCallable:InvokableObject' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
class Test {
|
|
|
|
public function __invoke(string $param): int {
|
|
|
|
return strlen($param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$test = new Test();
|
|
|
|
$closure = $test(...);
|
|
|
|
$length = $closure("test");
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
|
|
|
'FirstClassCallable:FromClosure' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-09 04:26:31 +01:00
|
|
|
$closure = fn (string $string): int => strlen($string);
|
|
|
|
$closure = $closure(...);
|
|
|
|
',
|
|
|
|
'assertions' => [
|
2022-01-23 20:35:49 +01:00
|
|
|
'$closure' => 'pure-Closure(string):int<0, max>',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-09 04:26:31 +01:00
|
|
|
],
|
2021-12-27 21:29:33 +01:00
|
|
|
'FirstClassCallable:MagicInstanceMethod' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
/**
|
|
|
|
* @method int length()
|
|
|
|
*/
|
|
|
|
class Test {
|
|
|
|
public function __construct(private readonly string $string) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __call(string $name, array $args): mixed {
|
|
|
|
return match ($name) {
|
|
|
|
"length" => strlen($this->string),
|
|
|
|
default => throw new \Error("Undefined method"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$test = new Test("test");
|
|
|
|
$closure = $test->length(...);
|
|
|
|
$length = $closure();
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
|
|
|
'FirstClassCallable:MagicStaticMethod' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
/**
|
|
|
|
* @method static int length(string $length)
|
|
|
|
*/
|
|
|
|
class Test {
|
|
|
|
public static function __callStatic(string $name, array $args): mixed {
|
|
|
|
return match ($name) {
|
|
|
|
"length" => strlen((string) $args[0]),
|
|
|
|
default => throw new \Error("Undefined method"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$closure = Test::length(...);
|
|
|
|
$length = $closure("test");
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$length' => 'int',
|
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
2022-08-04 16:16:06 +02:00
|
|
|
'FirstClassCallable:InheritedStaticMethod' => [
|
2022-10-16 13:59:15 +02:00
|
|
|
'code' => '<?php
|
2022-08-04 15:50:38 +02:00
|
|
|
|
|
|
|
abstract class A
|
|
|
|
{
|
|
|
|
public function foo(int $i): string
|
|
|
|
{
|
|
|
|
return (string) $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class C extends A {}
|
|
|
|
|
|
|
|
/** @param \Closure(int):string $_ */
|
|
|
|
function takesIntToString(\Closure $_): void {}
|
|
|
|
|
|
|
|
takesIntToString(C::foo(...));',
|
|
|
|
'assertions' => [],
|
2022-11-05 22:34:42 +01:00
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '8.1',
|
2022-08-04 15:50:38 +02:00
|
|
|
],
|
2022-08-04 16:16:06 +02:00
|
|
|
'FirstClassCallable:InheritedStaticMethodWithStaticTypeParameter' => [
|
2022-10-16 13:59:15 +02:00
|
|
|
'code' => '<?php
|
2022-08-04 16:16:06 +02:00
|
|
|
|
|
|
|
/** @template T */
|
|
|
|
class Holder
|
|
|
|
{
|
|
|
|
/** @param T $value */
|
|
|
|
public function __construct(public $value) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class A
|
|
|
|
{
|
|
|
|
final public function __construct(public int $i) {}
|
|
|
|
|
|
|
|
/** @return Holder<static> */
|
|
|
|
public static function create(int $i): Holder
|
|
|
|
{
|
|
|
|
return new Holder(new static($i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class C extends A {}
|
|
|
|
|
|
|
|
/** @param \Closure(int):Holder<C> $_ */
|
|
|
|
function takesIntToHolder(\Closure $_): void {}
|
|
|
|
|
2022-12-18 17:15:15 +01:00
|
|
|
takesIntToHolder(C::create(...));',
|
2022-08-04 16:16:06 +02:00
|
|
|
],
|
2021-12-27 21:29:33 +01:00
|
|
|
'FirstClassCallable:WithArrayMap' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
$array = [1, 2, 3];
|
|
|
|
$closure = fn (int $value): int => $value * $value;
|
|
|
|
$result1 = array_map((new \SplQueue())->enqueue(...), $array);
|
|
|
|
$result2 = array_map(strval(...), $array);
|
|
|
|
$result3 = array_map($closure(...), $array);
|
|
|
|
',
|
|
|
|
'assertions' => [
|
2022-11-12 02:14:21 +01:00
|
|
|
'$result1' => 'list{null, null, null}',
|
|
|
|
'$result2' => 'list{string, string, string}',
|
|
|
|
'$result3' => 'list{int, int, int}',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
2022-01-06 09:38:58 +01:00
|
|
|
'FirstClassCallable:array_map' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php call_user_func(array_map(...), intval(...), ["1"]);',
|
2022-01-06 09:38:58 +01:00
|
|
|
'assertions' => [],
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '8.1',
|
2022-01-06 09:38:58 +01:00
|
|
|
],
|
2022-02-22 01:37:20 +01:00
|
|
|
'FirstClassCallable:AssignmentVisitorMap' => [
|
2022-02-26 21:28:15 +01:00
|
|
|
'code' => '<?php
|
2022-02-22 01:37:20 +01:00
|
|
|
class Test {
|
|
|
|
/** @var list<\Closure():void> */
|
|
|
|
public array $handlers = [];
|
|
|
|
|
|
|
|
public function register(): void {
|
|
|
|
foreach ([1, 2, 3] as $index) {
|
|
|
|
$this->push($this->handler(...));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure():void $closure
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function push(\Closure $closure): void {
|
|
|
|
$this->handlers[] = $closure;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function handler(): void {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$test = new Test();
|
|
|
|
$test->register();
|
|
|
|
$handlers = $test->handlers;
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$handlers' => 'list<Closure():void>',
|
|
|
|
],
|
|
|
|
'ignored_issues' => [],
|
2022-12-03 04:28:22 +01:00
|
|
|
'php_version' => '8.1',
|
|
|
|
],
|
|
|
|
'FirstClassCallable:Method:Asserted' => [
|
|
|
|
'code' => '<?php
|
|
|
|
$r = false;
|
|
|
|
/** @var object $o */;
|
|
|
|
/** @var string $m */;
|
|
|
|
if (method_exists($o, $m)) {
|
|
|
|
$r = $o->$m(...);
|
|
|
|
}
|
|
|
|
',
|
|
|
|
'assertions' => [
|
|
|
|
'$r===' => 'Closure|false',
|
|
|
|
],
|
|
|
|
'ignored_issues' => [],
|
2022-02-22 01:37:20 +01:00
|
|
|
'php_version' => '8.1',
|
|
|
|
],
|
2022-01-06 21:12:51 +01:00
|
|
|
'arrowFunctionReturnsNeverImplictly' => [
|
2022-01-14 21:13:34 +01:00
|
|
|
'code' => '<?php
|
2022-01-06 21:12:51 +01:00
|
|
|
$bar = ["foo", "bar"];
|
|
|
|
|
|
|
|
$bam = array_map(
|
|
|
|
fn(string $a) => throw new Exception($a),
|
|
|
|
$bar
|
|
|
|
);',
|
|
|
|
'assertions' => [],
|
2022-01-14 21:13:34 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2022-01-06 21:12:51 +01:00
|
|
|
],
|
|
|
|
'arrowFunctionReturnsNeverExplictly' => [
|
2022-01-14 21:13:34 +01:00
|
|
|
'code' => '<?php
|
2022-01-06 21:12:51 +01:00
|
|
|
$bar = ["foo", "bar"];
|
|
|
|
|
|
|
|
$bam = array_map(
|
|
|
|
/** @return never */
|
|
|
|
fn(string $a) => die(),
|
|
|
|
$bar
|
|
|
|
);',
|
|
|
|
'assertions' => [],
|
2022-01-14 21:13:34 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2022-01-06 21:12:51 +01:00
|
|
|
],
|
2022-01-31 21:36:01 +01:00
|
|
|
'unknownFirstClassCallable' => [
|
2022-02-11 02:51:48 +01:00
|
|
|
'code' => '<?php
|
2022-01-31 21:51:31 +01:00
|
|
|
/** @psalm-suppress UndefinedFunction */
|
2022-01-31 21:36:01 +01:00
|
|
|
unknown(...);',
|
|
|
|
],
|
2022-12-28 19:31:47 +01:00
|
|
|
'reconcileClosure' => [
|
|
|
|
'code' => '<?php
|
|
|
|
/**
|
|
|
|
* @param Closure|callable-string $callable
|
|
|
|
*/
|
|
|
|
function use_callable($callable) : void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure|string $var
|
|
|
|
*/
|
|
|
|
function test($var) : void
|
|
|
|
{
|
|
|
|
if (is_callable($var))
|
|
|
|
use_callable($var);
|
|
|
|
else
|
|
|
|
echo $var; // $var should be string, instead it\'s considered to be Closure|string.
|
|
|
|
}',
|
|
|
|
],
|
2023-02-18 04:52:12 +01:00
|
|
|
'classExistsInOuterScopeOfArrowFunction' => [
|
|
|
|
'code' => <<<'PHP'
|
|
|
|
<?php
|
|
|
|
if (class_exists(Foo::class)) {
|
|
|
|
/** @return mixed */
|
|
|
|
fn() => Foo::bar(23, []);
|
|
|
|
}
|
|
|
|
PHP,
|
|
|
|
'assertions' => [],
|
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '7.4',
|
|
|
|
],
|
|
|
|
'classExistsInOuterScopeOfAClosure' => [
|
|
|
|
'code' => <<<'PHP'
|
|
|
|
<?php
|
|
|
|
if (class_exists(Foo::class)) {
|
|
|
|
/** @return mixed */
|
|
|
|
function () {
|
|
|
|
return Foo::bar(23, []);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
PHP,
|
|
|
|
],
|
2023-09-24 20:58:10 +02:00
|
|
|
'returnByReferenceVariableInClosure' => [
|
|
|
|
'code' => '<?php
|
|
|
|
function &(): int {
|
|
|
|
/** @var int $x */
|
|
|
|
static $x = 1;
|
|
|
|
return $x;
|
|
|
|
};
|
|
|
|
',
|
|
|
|
],
|
|
|
|
'returnByReferenceVariableInShortClosure' => [
|
|
|
|
'code' => '<?php
|
|
|
|
fn &(int &$x): int => $x;
|
|
|
|
',
|
|
|
|
],
|
2019-11-30 05:46:21 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerInvalidCodeParse(): iterable
|
2019-11-30 05:46:21 +01:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'wrongArg' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$bar = ["foo", "bar"];
|
|
|
|
|
|
|
|
$bam = array_map(
|
|
|
|
function(int $a): int {
|
|
|
|
return $a + 1;
|
|
|
|
},
|
|
|
|
$bar
|
|
|
|
);',
|
|
|
|
'error_message' => 'InvalidScalarArgument',
|
|
|
|
],
|
|
|
|
'noReturn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$bar = ["foo", "bar"];
|
|
|
|
|
|
|
|
$bam = array_map(
|
|
|
|
function(string $a): string {
|
|
|
|
},
|
|
|
|
$bar
|
|
|
|
);',
|
|
|
|
'error_message' => 'InvalidReturnType',
|
|
|
|
],
|
|
|
|
'possiblyNullFunctionCall' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @var Closure|null $foo
|
|
|
|
*/
|
|
|
|
$foo = null;
|
|
|
|
|
|
|
|
|
|
|
|
$foo =
|
|
|
|
/**
|
|
|
|
* @param mixed $bar
|
|
|
|
* @psalm-suppress MixedFunctionCall
|
|
|
|
*/
|
|
|
|
function ($bar) use (&$foo): string
|
|
|
|
{
|
|
|
|
if (is_array($bar)) {
|
|
|
|
return $foo($bar);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $bar;
|
|
|
|
};',
|
|
|
|
'error_message' => 'MixedReturnStatement',
|
|
|
|
],
|
|
|
|
'wrongParamType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$take_string = function(string $s): string { return $s; };
|
|
|
|
$take_string(42);',
|
|
|
|
'error_message' => 'InvalidScalarArgument',
|
|
|
|
],
|
|
|
|
'missingClosureReturnType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$a = function() {
|
|
|
|
return "foo";
|
|
|
|
};',
|
|
|
|
'error_message' => 'MissingClosureReturnType',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithBadReturnType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure(int):int $f
|
|
|
|
* @param Closure(int):int $g
|
|
|
|
*
|
|
|
|
* @return Closure(int):string
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (int $x) use ($f, $g) : int {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidReturnStatement',
|
|
|
|
],
|
|
|
|
'returnsTypedCallableWithBadReturnType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure(int):int $f
|
|
|
|
* @param Closure(int):int $g
|
|
|
|
*
|
|
|
|
* @return callable(int):string
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : callable {
|
|
|
|
return function (int $x) use ($f, $g) : int {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidReturnStatement',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithBadParamType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure(int):int $f
|
|
|
|
* @param Closure(int):int $g
|
|
|
|
*
|
|
|
|
* @return Closure(string):int
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (int $x) use ($f, $g) : int {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidReturnStatement',
|
|
|
|
],
|
|
|
|
'returnsTypedCallableWithBadParamType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure(int):int $f
|
|
|
|
* @param Closure(int):int $g
|
|
|
|
*
|
|
|
|
* @return callable(string):int
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : callable {
|
|
|
|
return function (int $x) use ($f, $g) : int {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidReturnStatement',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithBadCall' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
class D {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C):A
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (int $x) use ($f, $g) : int {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidArgument',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithSubclassParam' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
class C2 extends C {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C):A
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (C2 $x) use ($f, $g) : A {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'LessSpecificReturnStatement',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureWithSubclassReturn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
class A2 extends A {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C):A2
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : Closure {
|
|
|
|
return function (C $x) use ($f, $g) : A {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}',
|
|
|
|
'error_message' => 'LessSpecificReturnStatement',
|
|
|
|
],
|
|
|
|
'returnsTypedClosureFromCallable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B {}
|
|
|
|
class C {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return callable(C):A
|
|
|
|
*/
|
|
|
|
function foo(Closure $f, Closure $g) : callable {
|
|
|
|
return function (C $x) use ($f, $g) : A {
|
|
|
|
return $f($g($x));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Closure(B):A $f
|
|
|
|
* @param Closure(C):B $g
|
|
|
|
*
|
|
|
|
* @return Closure(C):A
|
|
|
|
*/
|
|
|
|
function bar(Closure $f, Closure $g) : Closure {
|
|
|
|
return foo($f, $g);
|
|
|
|
}',
|
|
|
|
'error_message' => 'LessSpecificReturnStatement',
|
|
|
|
],
|
|
|
|
'undefinedVariable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$a = function() use ($i) {};',
|
|
|
|
'error_message' => 'UndefinedVariable',
|
|
|
|
],
|
|
|
|
'voidReturningArrayMap' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$arr = array_map(
|
|
|
|
function(int $i) : void {
|
|
|
|
echo $i;
|
|
|
|
},
|
|
|
|
[1, 2, 3]
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ($arr as $a) {
|
|
|
|
if ($a) {}
|
|
|
|
}',
|
|
|
|
'error_message' => 'TypeDoesNotContainType',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'closureFromCallableInvokableNamedClassWrongArgs' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
namespace NS;
|
|
|
|
use Closure;
|
|
|
|
|
|
|
|
/** @param Closure(string):bool $c */
|
|
|
|
function acceptsIntToBool(Closure $c): void {}
|
|
|
|
|
|
|
|
class NamedInvokable {
|
|
|
|
public function __invoke(int $p): bool {
|
|
|
|
return $p > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));',
|
|
|
|
'error_message' => 'InvalidScalarArgument',
|
|
|
|
],
|
|
|
|
'undefinedClassForCallable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class Foo {
|
|
|
|
public function __construct(UndefinedClass $o) {}
|
|
|
|
}
|
|
|
|
new Foo(function() : void {});',
|
|
|
|
'error_message' => 'UndefinedClass',
|
|
|
|
],
|
|
|
|
'useDuplicateName' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
$foo = "bar";
|
|
|
|
|
|
|
|
$a = function (string $foo) use ($foo) : string {
|
|
|
|
return $foo;
|
|
|
|
};',
|
|
|
|
'error_message' => 'DuplicateParam',
|
|
|
|
],
|
2022-01-04 10:40:55 +01:00
|
|
|
'privateCallable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class Base {
|
|
|
|
private function privateMethod() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Example extends Base {
|
|
|
|
public function test() : Closure {
|
|
|
|
return Closure::fromCallable([$this, "privateMethod"]);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidArgument',
|
|
|
|
],
|
|
|
|
'prohibitCallableWithRequiredArg' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
/**
|
|
|
|
* @param Closure():int $x
|
|
|
|
*/
|
|
|
|
function accept_closure($x) : void {
|
|
|
|
$x();
|
|
|
|
}
|
|
|
|
accept_closure(
|
|
|
|
function (int $x) : int {
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
);',
|
|
|
|
'error_message' => 'InvalidArgument',
|
|
|
|
],
|
|
|
|
'useClosureDocblockType' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
class A {}
|
|
|
|
class B extends A {}
|
|
|
|
|
|
|
|
function takesA(A $_a) : void {}
|
|
|
|
function takesB(B $_b) : void {}
|
|
|
|
|
|
|
|
$getAButReallyB = /** @return A */ function() {
|
|
|
|
return new B;
|
|
|
|
};
|
|
|
|
|
|
|
|
takesA($getAButReallyB());
|
|
|
|
takesB($getAButReallyB());',
|
2022-08-03 19:56:38 +02:00
|
|
|
'error_message' => 'ArgumentTypeCoercion - src' . DIRECTORY_SEPARATOR . 'somefile.php:13:28 - Argument 1 of takesB expects B, but parent type A provided',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
|
|
|
'closureByRefUseToMixed' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2019-11-30 05:46:21 +01:00
|
|
|
function assertInt(int $int): int {
|
|
|
|
$s = static function() use(&$int): void {
|
|
|
|
$int = "42";
|
|
|
|
};
|
|
|
|
|
|
|
|
$s();
|
|
|
|
|
|
|
|
return $int;
|
|
|
|
}',
|
2022-12-18 17:15:15 +01:00
|
|
|
'error_message' => 'MixedReturnStatement',
|
2019-11-30 05:46:21 +01:00
|
|
|
],
|
2020-09-07 17:11:01 +02:00
|
|
|
'noCrashWhenComparingIllegitimateCallable' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-09-07 17:11:01 +02:00
|
|
|
class C {}
|
|
|
|
|
|
|
|
function foo() : C {
|
|
|
|
return fn (int $i) => "";
|
|
|
|
}',
|
|
|
|
'error_message' => 'InvalidReturnStatement',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '7.4',
|
2020-09-07 17:11:01 +02:00
|
|
|
],
|
2020-12-04 19:16:05 +01:00
|
|
|
'detectImplicitVoidReturn' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2020-12-04 19:16:05 +01:00
|
|
|
/**
|
|
|
|
* @param Closure():Exception $c
|
|
|
|
*/
|
|
|
|
function takesClosureReturningException(Closure $c) : void {
|
|
|
|
echo $c()->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
takesClosureReturningException(
|
|
|
|
function () {
|
|
|
|
echo "hello";
|
|
|
|
}
|
|
|
|
);',
|
2022-12-18 17:15:15 +01:00
|
|
|
'error_message' => 'InvalidArgument',
|
2020-12-04 19:16:05 +01:00
|
|
|
],
|
2021-03-11 06:06:23 +01:00
|
|
|
'undefinedVariableInEncapsedString' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-03-11 06:06:23 +01:00
|
|
|
fn(): string => "$a";
|
|
|
|
',
|
|
|
|
'error_message' => 'UndefinedVariable',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2021-03-11 06:06:23 +01:00
|
|
|
],
|
|
|
|
'undefinedVariableInStringCast' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-03-11 06:06:23 +01:00
|
|
|
fn(): string => (string) $a;
|
|
|
|
',
|
|
|
|
'error_message' => 'UndefinedVariable',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2021-03-11 06:06:23 +01:00
|
|
|
],
|
2021-03-29 21:10:04 +02:00
|
|
|
'forbidTemplateAnnotationOnClosure' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-03-29 21:10:04 +02:00
|
|
|
/** @template T */
|
|
|
|
function (): void {};
|
|
|
|
',
|
|
|
|
'error_message' => 'InvalidDocblock',
|
|
|
|
],
|
|
|
|
'forbidTemplateAnnotationOnShortClosure' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-03-29 21:10:04 +02:00
|
|
|
/** @template T */
|
|
|
|
fn(): bool => false;
|
|
|
|
',
|
|
|
|
'error_message' => 'InvalidDocblock',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '7.4',
|
2021-03-29 21:10:04 +02:00
|
|
|
],
|
2021-12-16 17:39:08 +01:00
|
|
|
'closureInvalidArg' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-16 17:39:08 +01:00
|
|
|
/** @param Closure(int): string $c */
|
|
|
|
function takesClosure(Closure $c): void {}
|
|
|
|
|
|
|
|
takesClosure(5);',
|
|
|
|
'error_message' => 'InvalidArgument',
|
|
|
|
],
|
2021-12-27 21:29:33 +01:00
|
|
|
'FirstClassCallable:UndefinedMethod' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
$queue = new \SplQueue;
|
|
|
|
$closure = $queue->undefined(...);
|
|
|
|
$count = $closure();
|
|
|
|
',
|
|
|
|
'error_message' => 'UndefinedMethod',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
|
|
|
'FirstClassCallable:UndefinedMagicInstanceMethod' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
class Test {
|
|
|
|
public function __call(string $name, array $args): mixed {
|
|
|
|
return match ($name) {
|
|
|
|
default => throw new \Error("Undefined method"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$test = new Test();
|
|
|
|
$closure = $test->length(...);
|
|
|
|
$length = $closure();
|
|
|
|
',
|
|
|
|
'error_message' => 'UndefinedMagicMethod',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
2022-12-18 17:15:15 +01:00
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
|
|
|
'FirstClassCallable:UndefinedMagicStaticMethod' => [
|
2022-01-13 19:49:37 +01:00
|
|
|
'code' => '<?php
|
2021-12-27 21:29:33 +01:00
|
|
|
class Test {
|
|
|
|
public static function __callStatic(string $name, array $args): mixed {
|
|
|
|
return match ($name) {
|
|
|
|
default => throw new \Error("Undefined method"),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$closure = Test::length(...);
|
|
|
|
$length = $closure();
|
|
|
|
',
|
|
|
|
'error_message' => 'MixedAssignment',
|
2022-01-13 19:49:37 +01:00
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '8.1',
|
2021-12-27 21:29:33 +01:00
|
|
|
],
|
2023-01-23 10:16:12 +01:00
|
|
|
'thisInStaticClosure' => [
|
|
|
|
'code' => '<?php
|
|
|
|
class C {
|
|
|
|
public string $a = "zzz";
|
|
|
|
public function f(): void {
|
|
|
|
$f = static function (): void {
|
|
|
|
echo $this->a;
|
|
|
|
};
|
|
|
|
$f();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
'error_message' => 'InvalidScope',
|
|
|
|
],
|
|
|
|
'thisInStaticArrowFunction' => [
|
|
|
|
'code' => '<?php
|
|
|
|
class C {
|
|
|
|
public int $a = 1;
|
|
|
|
public function f(): int {
|
|
|
|
$f = static fn(): int => $this->a;
|
|
|
|
return $f();;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
'error_message' => 'InvalidScope',
|
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '7.4',
|
|
|
|
],
|
2023-02-19 09:18:32 +01:00
|
|
|
'FirstClassCallable:WithNew' => [
|
|
|
|
'code' => <<<'PHP'
|
|
|
|
<?php
|
|
|
|
new stdClass(...);
|
|
|
|
PHP,
|
|
|
|
'error_message' => 'ParseError',
|
|
|
|
'ignored_issues' => [],
|
|
|
|
'php_version' => '8.1',
|
|
|
|
],
|
2023-09-24 20:58:10 +02:00
|
|
|
'returnByReferenceNonVariableInClosure' => [
|
|
|
|
'code' => '<?php
|
|
|
|
function &(): int {
|
|
|
|
return 45;
|
|
|
|
};
|
|
|
|
',
|
|
|
|
'error_message' => 'NonVariableReferenceReturn',
|
|
|
|
],
|
|
|
|
'returnByReferenceNonVariableInShortClosure' => [
|
|
|
|
'code' => '<?php
|
|
|
|
fn &(): int => 45;
|
|
|
|
',
|
|
|
|
'error_message' => 'NonVariableReferenceReturn',
|
|
|
|
],
|
2019-11-30 05:46:21 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|