Skip to content

Commit bb3f89c

Browse files
committed
test interface_exists()
1 parent 27f95cc commit bb3f89c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Diff for: tests/PHPStan/Rules/Classes/data/remember-class-exists-from-constructor.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace RememberClassExistsFromConstructor;
44

55
use SomeUnknownClass;
6+
use SomeUnknownInterface;
67

7-
class User
8+
class UserWithClass
89
{
910
public function __construct(
1011
) {
@@ -22,3 +23,22 @@ public function doFoo($m): bool
2223
}
2324

2425
}
26+
27+
class UserWithInterface
28+
{
29+
public function __construct(
30+
) {
31+
if (!interface_exists('SomeUnknownInterface')) {
32+
throw new \LogicException();
33+
}
34+
}
35+
36+
public function doFoo($m): bool
37+
{
38+
if ($m instanceof SomeUnknownInterface) {
39+
return false;
40+
}
41+
return true;
42+
}
43+
44+
}

0 commit comments

Comments
 (0)