Skip to content

Commit fda2b46

Browse files
Implement Class_::hasParent()
1 parent 8b2ee49 commit fda2b46

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/StaticAnalysis/Value/Class_.php

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public function endLine(): int
135135
return $this->endLine;
136136
}
137137

138+
public function hasParent(): bool
139+
{
140+
return $this->parentClass !== null;
141+
}
142+
138143
/**
139144
* @return ?non-empty-string
140145
*/

tests/tests/StaticAnalysis/Value/ClassTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ public function testMayHaveParentClass(): void
5151
{
5252
$parentClass = 'example\ParentClass';
5353

54-
$this->assertSame($parentClass, $this->class(parentClass: $parentClass)->parentClass());
54+
$class = $this->class(parentClass: $parentClass);
55+
56+
$this->assertTrue($class->hasParent());
57+
$this->assertSame($parentClass, $class->parentClass());
5558
}
5659

5760
public function testMayNotHaveParentClass(): void
5861
{
62+
$this->assertFalse($this->class()->hasParent());
5963
$this->assertNull($this->class()->parentClass());
6064
}
6165

0 commit comments

Comments
 (0)