forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallables.php
More file actions
37 lines (27 loc) · 692 Bytes
/
callables.php
File metadata and controls
37 lines (27 loc) · 692 Bytes
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
<?php // lint >= 8.0
namespace Callables;
use function PHPStan\Testing\assertType;
class Foo
{
public function doFoo(): float
{
$closure = function (): string {
};
$foo = $this;
$arrayWithStaticMethod = ['Callables\\Foo', 'doBar'];
$stringWithStaticMethod = 'Callables\\Foo::doFoo';
$arrayWithInstanceMethod = [$this, 'doFoo'];
assertType('int', $foo());
assertType('string', $closure());
assertType('*ERROR*', $arrayWithStaticMethod());
assertType('*ERROR*', $stringWithStaticMethod());
assertType('float', $arrayWithInstanceMethod());
assertType('mixed', $closureObject());
}
public function doBar(): Bar
{
}
public function __invoke(): int
{
}
}