forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-parent-class.php
More file actions
52 lines (39 loc) · 1.12 KB
/
get-parent-class.php
File metadata and controls
52 lines (39 loc) · 1.12 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
namespace ParentClass;
use function PHPStan\Testing\assertType;
class Foo
{
public function doFoo()
{
assertType('false', get_parent_class());
assertType('false', get_parent_class($this));
assertType('class-string<$this(ParentClass\Foo)>', get_class($this));
assertType('\'ParentClass\\\\Foo\'', get_class());
}
}
class Bar extends Foo
{
use FooTrait;
public function doBar()
{
assertType('\'ParentClass\\\\Foo\'', get_parent_class());
assertType('\'ParentClass\\\\Foo\'', get_parent_class($this));
}
}
function (string $s) {
assertType('false', get_parent_class());
assertType('class-string|false', get_parent_class($s));
assertType('false', get_parent_class(\ParentClass\Foo::class));
assertType('class-string|false', get_parent_class(NonexistentClass::class));
assertType('class-string|false', get_parent_class(1));
assertType('\'ParentClass\\\\Foo\'', get_parent_class(\ParentClass\Bar::class));
assertType('false', get_class());
};
trait FooTrait
{
public function doBaz()
{
assertType('class-string|false', get_parent_class());
assertType('class-string|false', get_parent_class($this));
}
}