Skip to content

Commit 67a41c7

Browse files
committed
Property from interface is abstract property
1 parent 56df7b3 commit 67a41c7

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/Reflection/ReflectionProperty.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ public function isFinal(): bool
309309

310310
public function isAbstract(): bool
311311
{
312-
return (bool) ($this->modifiers & ReflectionPropertyAdapter::IS_ABSTRACT_COMPATIBILITY);
312+
return (bool) ($this->modifiers & ReflectionPropertyAdapter::IS_ABSTRACT_COMPATIBILITY)
313+
|| $this->declaringClass->isInterface();
313314
}
314315

315316
public function isPromoted(): bool

test/unit/Fixture/PropertyHooks.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,8 @@ class FinalPropertyHooks
164164
final set => strtolower($value);
165165
}
166166
}
167+
168+
interface InterfaceWithProperty
169+
{
170+
public int $abstractPropertyFromInterface { get; set; }
171+
}

test/unit/Reflection/ReflectionPropertyTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,15 @@ public function testIsAbstract(): void
10211021
self::assertTrue($hookProperty->isAbstract());
10221022
}
10231023

1024+
public function testIsAbstractInInterface(): void
1025+
{
1026+
$reflector = new DefaultReflector(new SingleFileSourceLocator(__DIR__ . '/../Fixture/PropertyHooks.php', $this->astLocator));
1027+
$classInfo = $reflector->reflectClass('Roave\BetterReflectionTest\Fixture\InterfaceWithProperty');
1028+
1029+
$abstractProperty = $classInfo->getProperty('abstractPropertyFromInterface');
1030+
self::assertTrue($abstractProperty->isAbstract());
1031+
}
1032+
10241033
public function testNoHooks(): void
10251034
{
10261035
$classInfo = $this->reflector->reflectClass(ExampleClass::class);

0 commit comments

Comments
 (0)