forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope-function-call-stack.php
More file actions
52 lines (45 loc) · 1.08 KB
/
scope-function-call-stack.php
File metadata and controls
52 lines (45 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php // lint >= 8.0
namespace ScopeFunctionCallStack;
function (): void
{
var_dump(print_r(sleep(throw new \Exception())));
};
function (): void
{
var_dump(print_r(function () {
sleep(throw new \Exception());
}));
};
function (): void
{
var_dump(print_r(fn () => sleep(throw new \Exception())));
};
class NamedArgumentTest
{
/**
* @param-immediately-invoked-callable $immediate
*/
public function testMethod(callable $immediate, ?callable $notImmediate = null): void
{
$immediate();
}
public function test(): void
{
// When using named argument for $notImmediate, the parameter should be reported as "notImmediate", not "immediate"
$this->testMethod(
notImmediate: function () {
throw new \Exception(); // should report: NamedArgumentTest::testMethod ($notImmediate)
},
immediate: function () {},
);
}
public function testMissingRequiredArg(): void
{
// Named argument with missing required param - should still match parameter by name
$this->testMethod(
notImmediate: function () {
throw new \Exception(); // reports $notImmediate
},
);
}
}