mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Don't emit MissingOverrideAttribute for implicit Stringable implementations
This commit is contained in:
parent
fb7278ea3e
commit
6269b804a0
@ -1996,6 +1996,8 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
|||||||
&& $codebase->config->ensure_override_attribute
|
&& $codebase->config->ensure_override_attribute
|
||||||
&& $overridden_method_ids
|
&& $overridden_method_ids
|
||||||
&& $storage->cased_name !== '__construct'
|
&& $storage->cased_name !== '__construct'
|
||||||
|
&& ($storage->cased_name !== '__toString'
|
||||||
|
|| isset($appearing_class_storage->direct_class_interfaces['stringable']))
|
||||||
) {
|
) {
|
||||||
IssueBuffer::maybeAdd(
|
IssueBuffer::maybeAdd(
|
||||||
new MissingOverrideAttribute(
|
new MissingOverrideAttribute(
|
||||||
|
@ -85,6 +85,19 @@ class OverrideTest extends TestCase
|
|||||||
'ignored_issues' => [],
|
'ignored_issues' => [],
|
||||||
'php_version' => '8.3',
|
'php_version' => '8.3',
|
||||||
],
|
],
|
||||||
|
'ignoreImplicitStringable' => [
|
||||||
|
'code' => '
|
||||||
|
<?php
|
||||||
|
class A {
|
||||||
|
public function __toString(): string {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
',
|
||||||
|
'assertions' => [],
|
||||||
|
'ignored_issues' => [],
|
||||||
|
'php_version' => '8.3',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,6 +203,19 @@ class OverrideTest extends TestCase
|
|||||||
'error_levels' => [],
|
'error_levels' => [],
|
||||||
'php_version' => '8.3',
|
'php_version' => '8.3',
|
||||||
],
|
],
|
||||||
|
'explicitStringable' => [
|
||||||
|
'code' => '
|
||||||
|
<?php
|
||||||
|
class A implements Stringable {
|
||||||
|
public function __toString(): string {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
',
|
||||||
|
'error_message' => 'MissingOverrideAttribute',
|
||||||
|
'error_levels' => [],
|
||||||
|
'php_version' => '8.3',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user