Skip to content

Commit

Permalink
Cannot override being final for abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 6, 2025
1 parent 274e766 commit 9bb2ed5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Reflection/ClassReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ public function acceptsNamedArguments(): bool

public function hasFinalByKeywordOverride(): bool
{
return $this->isClass() && $this->finalByKeywordOverride !== null;
return $this->finalByKeywordOverride !== null;
}

public function isFinalByKeyword(): bool
Expand All @@ -1292,7 +1292,7 @@ public function isFinalByKeyword(): bool
return true;
}

if ($this->isClass() && $this->finalByKeywordOverride !== null) {
if ($this->finalByKeywordOverride !== null) {
return $this->finalByKeywordOverride;
}

Expand Down Expand Up @@ -1600,6 +1600,12 @@ public function asFinal(): self
if ($this->finalByKeywordOverride === true) {
return $this;
}
if (!$this->isClass()) {
return $this;
}
if ($this->isAbstract()) {
return $this;
}

return new self(
$this->reflectionProvider,
Expand Down

0 comments on commit 9bb2ed5

Please # to comment.