Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix false MissingOverrideAttribute issue #10989

Open
wants to merge 5 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,7 @@ private function getFunctionInformation(
if (!$has_override_attribute
&& $codebase->config->ensure_override_attribute
&& $overridden_method_ids
&& $storage->visibility !== ClassLikeAnalyzer::VISIBILITY_PRIVATE
ghostwriter marked this conversation as resolved.
Show resolved Hide resolved
&& $storage->cased_name !== '__construct'
&& ($storage->cased_name !== '__toString'
|| isset($appearing_class_storage->direct_class_interfaces['stringable']))
Expand Down
29 changes: 29 additions & 0 deletions tests/OverrideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,35 @@ public function __toString(): string {
'ignored_issues' => [],
'php_version' => '8.3',
],
'Issue #10982 - https://github.com/vimeo/psalm/issues/10982' => [
'code' => '
<?php
trait Foo
{
private function inTrait(): void { echo "foobar\n"; }
}

class A {
use Foo;

public function bar(): void {
$this->inTrait();
}
}

class B extends A {
use Foo;

function baz(): void
{
$this->inTrait();
}
}
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.3',
],
];
}

Expand Down