Skip to content

Commit 5a08802

Browse files
Fixed ClassFormatter for classes which extend/implement php default interfaces
1 parent ef611c2 commit 5a08802

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Formatter/ClassFormatter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function format(bool $ignoreSubElements = false): string
7171
// remove interfaces from parent class if there is a parent class
7272
if ($parentClass instanceof ReflectionClass) {
7373
$interfaces = array_filter($interfaces, function (ReflectionClass $interface) use ($parentClass) {
74+
// if the $parentClass is a default php class it cannot use an user defined interface
7475
if (!$parentClass->isUserDefined() && $interface->isUserDefined()) {
7576
return false;
7677
}
@@ -86,7 +87,11 @@ public function format(bool $ignoreSubElements = false): string
8687
/**
8788
* @var ReflectionClass $compareInterface
8889
*/
89-
if ($compareInterface->implementsInterface($interfaceName)) {
90+
/** @noinspection NotOptimalIfConditionsInspection */
91+
// if the $compareInterface is a default php interface it cannot use an user defined interface
92+
if ((!$compareInterface->isUserDefined() && $interface->isUserDefined())
93+
|| $compareInterface->implementsInterface($interfaceName)
94+
) {
9095
return false;
9196
}
9297
}

0 commit comments

Comments
 (0)