Repository navigation
fix(methods): no ParamNameMismatch for a name another overridden method uses - #14536
Conversation
…od uses vimeo#11633 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Behaviour change
Corpora (errorLevel 1), only Verified: |
✅ Performance: unchanged · Types: decreased
How to read this table
✅ laravel: issues +0 −3Memory 1 749 → 1 749 MB (<0.1 %) · Wall 76.2 → 78.2 s (+2.6 %) Weighted 53 460 → 53 439 (−21, −0.04 %): L7 −3
Removed (3)
✅ symfony: issues +0 −21Memory 3 599 → 3 599 MB (<0.1 %) · Wall 256.6 → 250.9 s (−2.2 %) Weighted 98 403 → 98 256 (−147, −0.15 %): L7 −21
Removed (21)
✅ tempest: issues +0 −2Memory 895 → 895 MB (<0.1 %) · Wall 36.0 → 36.1 s (+0.3 %) Weighted 10 528 → 10 514 (−14, −0.13 %): L7 −2
Removed (2)
✅ drupal: issues +0 −75Memory 4 842 → 4 842 MB (<0.1 %) · Wall 149.5 → 147.0 s (−1.7 %) Weighted 169 293 → 168 768 (−525, −0.31 %): L7 −75
Removed (75)
✅ wordpress: issues +0 −2Memory 2 039 → 2 039 MB (<0.1 %) · Wall 273.3 → 271.6 s (−0.6 %) Weighted 676 684 → 676 670 (−14, <0.01 %): L7 −2
Removed (2)
head 27f2fb0 · base 46d8098 (merge-base) · workflow run |
# Conflicts: # tests/ClassTest.php
orklah
left a comment
There was a problem hiding this comment.
Thanks! The direction is right, but isNamedAsInAnotherOverriddenMethod() accepts any overridden method that uses the implementer's name, even one whose parameter names are not binding. In that case the ancestors don't really conflict, and the issue is now missed:
<?php
class X {
/** @no-named-arguments */
public function foo(string $a): void {}
}
interface B {
public function foo(string $b): void;
}
final class KeepsX extends X implements B {
public function foo(string $a): void {} // master: ParamNameMismatch (expecting $b as defined by B::foo), this PR: no issue
}$b satisfies every ancestor here, since X::foo() can't be called with named arguments. The same happens with allowNamedArgumentCalls="false" when the ancestor using the name is a project class and the other one is not (abstract class A { public function foo(string $a): void {} } in src/, interface B { public function foo(string $b): void; } outside the project dirs, final class KeepsA extends A implements B { public function foo(string $a): void {} }: reported on master, silent here).
Could you only count the overridden methods against which ParamNameMismatch would be reported, i.e. reuse the conditions of the check itself (allowsNamedArguments(), then allow_named_arg_calls || guide outside the project dirs || NamedArguments::STABLE || requiresNamedArgument()), ideally extracted into one helper used in both places? Please add an invalid test case for each of the two examples above.
…onflicting name vimeo#11633 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alysis Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ParamNameMismatchis reported for an override whose ancestors name the parameter differently, so whatever name it uses, one of them reports it.Before
After
Fixes #11633