Skip to content

Commit b8060ad

Browse files
committed
Add interface_exists to check for internal interfaces
1 parent 2b50b7e commit b8060ad

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ composer.lock
33
/vendor/
44
/.phpunit.result.cache
55
cghooks.lock
6-
6+
/.php-cs-fixer.cache

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.0.2
2+
Added a check for built-in interfaces
3+
14
# 1.0.1
25
Updated the version constraint of phpstan
36

src/Rules/NamespaceRestrictionRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function processNode(Node $node, Scope $scope): array
8484
if (!preg_match($fullPattern, $name)) {
8585
if (!isset($this->builtInChecks[$name])) {
8686
$reflection = null;
87-
if (class_exists($name)) {
87+
if (class_exists($name) || interface_exists($name)) {
8888
$reflection = new ReflectionClass($name);
8989
} elseif (function_exists($name)) {
9090
$reflection = new ReflectionFunction($name);

tests/Advanced/User/Core/UserService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
namespace MintwareDe\Tests\PhpStanNamespaceConstraints\Advanced\User\Core;
66

77
use MintwareDe\Tests\PhpStanNamespaceConstraints\Advanced\Shared\Core\Entity\User;
8+
use Throwable;
89

910
class UserService
1011
{
12+
/** @throws Throwable */
1113
public function getUser(): User
1214
{
15+
if (date('d') === '01') {
16+
throw new \Exception('Foo');
17+
}
1318
return new User();
1419
}
1520
}

0 commit comments

Comments
 (0)