Skip to content

Commit

Permalink
Fix calls on magic methods on abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Nov 28, 2023
1 parent a3024ad commit f037822
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,9 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool
$lc_method_name,
);
$storage->inheritable_method_ids[$lc_method_name] = $method_identifier;
if (!isset($storage->overridden_method_ids[$lc_method_name])) {
$storage->overridden_method_ids[$lc_method_name] = [];
}
$storage->declaring_method_ids[$lc_method_name] ??= $method_identifier;
$storage->appearing_method_ids[$lc_method_name] ??= $method_identifier;
$storage->overridden_method_ids[$lc_method_name] ??= [];
$storage->declaring_pseudo_method_ids[$lc_method_name] = $method_identifier;
}

Expand Down
14 changes: 14 additions & 0 deletions tests/MethodCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ public function __call(string $method_name, array $args) : string {
'$s' => 'string',
],
],
'magicCallOnAbstract' => [
'code' => '<?php
/**
* @method string getConfirmationUrl()
*/
abstract class AbstractConfirmation
{
}
function t(AbstractConfirmation $v): void {
$v->getConfirmationUrl();
}'
],
'canBeCalledOnMagic' => [
'code' => '<?php
class A {
Expand Down

0 comments on commit f037822

Please sign in to comment.