Skip to content

fix(methods): no ParamNameMismatch for a name another overridden method uses - #14536

Merged
orklah merged 4 commits into
vimeo:masterfrom
jirkace:fix/11633-conflicting-param-names
Nov 23, 2026
Merged

orklah merged 4 commits into
vimeo:masterfrom
jirkace:fix/11633-conflicting-param-names

Conversation

@jirkace

@jirkace jirkace commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

ParamNameMismatch is reported for an override whose ancestors name the parameter differently, so whatever name it uses, one of them reports it.

Before

<?php
class A {
    public function foo(string $a): void {}
}

interface B {
    public function foo(string $b): void;
}

final class KeepsTheNameOfTheParent extends A implements B {
    public function foo(string $a): void {} // ParamNameMismatch: ... expecting $b as defined by B::foo
}

final class KeepsTheNameOfTheInterface extends A implements B {
    public function foo(string $b): void {} // ParamNameMismatch: ... expecting $a as defined by A::foo
}

After

    public function foo(string $a): void {} // no issue
    public function foo(string $b): void {} // no issue

Fixes #11633

…od uses vimeo#11633

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jirkace

jirkace commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Behaviour change

ParamNameMismatch (and its --alter renaming) is no longer reported for a parameter whose name is the one another method the implementer overrides uses at that position (ClassLikeStorage::$overridden_method_ids): the ancestors disagree, and no name satisfies them all. A name that none of them uses is still reported against each (testInvalidCode@paramNamedAsInNoneOfTwoConflictingAncestors), as is a plain rename of a single parent's parameter.

Corpora (errorLevel 1), only ParamNameMismatch removed, nothing added: laravel 27864 → 27861 (Illuminate\Console\OutputStyle::write()/writeln(), Symfony's OutputStyle/SymfonyStyle vs OutputInterface), symfony 11700 → 11684 (session handlers: AbstractSessionHandler::open($savePath, $sessionName) vs SessionHandlerInterface::open($path, $name), ContainerBag vs PSR ContainerInterface, SymfonyStyle), drupal −20 (LocalReadOnlyStream, TypedData definitions, TypedDataManager::createInstance(), field items/widgets, LayoutBuilderEntityViewDisplay::createCopy()); the cases I opened have an ancestor using the implementer's name.

Verified: ClassTest::testValidCode@paramNamedAsInOneOfTwoConflictingAncestors fails on master and passes here. Full self-analysis: no new issue (only 2 MixedArgument from my local revolt/event-loop v1.0.9, unrelated).

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: decreased

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 749 78.2 $\color{gray}{\textsf{+2.6\%}}$ 25 904 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-3}}$ 53 439 $\color{green}{\textsf{-21}}$ 682 0
✅ symfony 3 599 250.9 $\color{gray}{\textsf{-2.2\%}}$ 50 589 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-21}}$ 98 256 $\color{green}{\textsf{-147}}$ 1 528 0
✅ doctrine-orm 380 15.4 $\color{gray}{\textsf{-0.6\%}}$ 3 481 6 143 0 0
✅ psl 617 20.3 1 375 5 615 1 0
✅ phpunit 455 19.8 $\color{gray}{\textsf{+0.4\%}}$ 1 731 3 410 18 0
✅ php-parser 226 13.4 $\color{gray}{\textsf{+0.7\%}}$ 17 154 21 245 0 0
✅ tempest 895 36.1 $\color{gray}{\textsf{+0.3\%}}$ 5 045 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-2}}$ 10 514 $\color{green}{\textsf{-14}}$ 252 0
✅ amphp-amp 45 1.3 29 49 0 0
✅ webmozarts-assert 273 4.2 $\color{gray}{\textsf{-0.5\%}}$ 577 2 720 0 0
✅ guzzle-promises 44 1.4 155 434 2 0
✅ monolog 135 5.3 $\color{gray}{\textsf{-0.6\%}}$ 913 2 479 10 0
✅ drupal 4 842 147.0 $\color{gray}{\textsf{-1.7\%}}$ 97 516 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-75}}$ 168 768 $\color{green}{\textsf{-525}}$ 583 0
✅ wordpress 2 039 271.6 $\color{gray}{\textsf{-0.6\%}}$ 142 702 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-2}}$ 676 670 $\color{green}{\textsf{-14}}$ 461 1
Total 15 299 864.8 $\color{gray}{\textsf{-0.9\%}}$ 347 171 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-103}}$ 1 049 742 $\color{green}{\textsf{-721}}$ 3 537 1
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +10 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Its wall time warns above +5 % (±5 % is noise); the other thresholds apply per project.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.
✅ laravel: issues +0 −3

Memory 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

Issue type added removed
ParamNameMismatch 0 3

Removed (3)

  • src/Illuminate/Console/OutputStyle.php:68 ParamNameMismatch (error): Argument 3 of Illuminate\Console\OutputStyle::write has wrong name $options, expecting $type as defined by Symfony\Component\Console\Style\OutputStyle::write
  • src/Illuminate/Console/OutputStyle.php:68 ParamNameMismatch (error): Argument 3 of OutputStyle::write has wrong name $options, expecting $type as defined by SymfonyStyle::write
  • src/Illuminate/Console/OutputStyle.php:80 ParamNameMismatch (error): Argument 2 of OutputStyle::writeln has wrong name $type, expecting $options as defined by OutputInterface::writeln
✅ symfony: issues +0 −21

Memory 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

Issue type added removed
ParamNameMismatch 0 21

Removed (21)

  • src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AccessTokenFactory.php:71 ParamNameMismatch (error): Argument 1 of AccessTokenFactory::addConfiguration has wrong name $node, expecting $builder as defined by AuthenticatorFactoryInterface::addConfiguration
  • src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginLdapFactory.php:28 ParamNameMismatch (error): Argument 1 of FormLoginLdapFactory::addConfiguration has wrong name $node, expecting $builder as defined by AuthenticatorFactoryInterface::addConfiguration
  • src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpBasicLdapFactory.php:73 ParamNameMismatch (error): Argument 1 of HttpBasicLdapFactory::addConfiguration has wrong name $node, expecting $builder as defined by AuthenticatorFactoryInterface::addConfiguration
  • src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/JsonLoginLdapFactory.php:25 ParamNameMismatch (error): Argument 1 of JsonLoginLdapFactory::addConfiguration has wrong name $node, expecting $builder as defined by AuthenticatorFactoryInterface::addConfiguration
  • src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/LoginLinkFactory.php:31 ParamNameMismatch (error): Argument 1 of LoginLinkFactory::addConfiguration has wrong name $node, expecting $builder as defined by AuthenticatorFactoryInterface::addConfiguration
  • src/Symfony/Component/Console/Style/SymfonyStyle.php:404 ParamNameMismatch (error): Argument 2 of SymfonyStyle::writeln has wrong name $type, expecting $options as defined by OutputInterface::writeln
  • src/Symfony/Component/Console/Style/SymfonyStyle.php:416 ParamNameMismatch (error): Argument 3 of SymfonyStyle::write has wrong name $type, expecting $options as defined by OutputInterface::write
  • src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php:31 ParamNameMismatch (error): Argument 1 of ContainerBag::get has wrong name $name, expecting $id as defined by ContainerInterface::get
  • src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php:36 ParamNameMismatch (error): Argument 1 of ContainerBag::has has wrong name $name, expecting $id as defined by ContainerInterface::has
  • src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php:71 ParamNameMismatch (error): Argument 1 of MemcachedSessionHandler::updateTimestamp has wrong name $sessionId, expecting $id as defined by SessionUpdateTimestampHandlerInterface::updateTimestamp
  • … and 11 more
✅ tempest: issues +0 −2

Memory 895 → 895 MB (<0.1 %) · Wall 36.0 → 36.1 s (+0.3 %)

Weighted 10 528 → 10 514 (−14, −0.13 %): L7 −2

Issue type added removed
ParamNameMismatch 0 2

Removed (2)

  • packages/container/src/GenericContainer.php:171 ParamNameMismatch (error): Argument 1 of GenericContainer::has has wrong name $className, expecting $id as defined by ContainerInterface::has
  • packages/container/src/GenericContainer.php:208 ParamNameMismatch (error): Argument 1 of GenericContainer::get has wrong name $className, expecting $id as defined by ContainerInterface::get
✅ drupal: issues +0 −75

Memory 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

Issue type added removed
ParamNameMismatch 0 75

Removed (75)

  • core/lib/Drupal/Component/Utility/DeprecatedArray.php:73 ParamNameMismatch (error): Argument 1 of DeprecatedArray::unserialize has wrong name $serialized, expecting $data as defined by Serializable::unserialize
  • core/lib/Drupal/Core/Action/Plugin/Action/DeleteAction.php:62 ParamNameMismatch (error): Argument 1 of DeleteAction::executeMultiple has wrong name $entities, expecting $objects as defined by ActionInterface::executeMultiple
  • core/lib/Drupal/Core/Config/Entity/Query/Query.php:73 ParamNameMismatch (error): Argument 1 of Query::condition has wrong name $property, expecting $field as defined by QueryInterface::condition
  • core/lib/Drupal/Core/Config/Schema/ArrayElement.php:80 ParamNameMismatch (error): Argument 1 of ArrayElement::get has wrong name $name, expecting $property_name as defined by ComplexDataInterface::get
  • core/lib/Drupal/Core/Entity/EntityTypeManager.php:160 ParamNameMismatch (error): Argument 1 of EntityTypeManager::getDefinition has wrong name $entity_type_id, expecting $plugin_id as defined by DiscoveryCachedTrait::getDefinition
  • core/lib/Drupal/Core/Entity/EntityTypeManager.php:160 ParamNameMismatch (error): Argument 1 of EntityTypeManager::getDefinition has wrong name $entity_type_id, expecting $plugin_id as defined by DiscoveryInterface::getDefinition
  • core/lib/Drupal/Core/Entity/EntityTypeManager.php:160 ParamNameMismatch (error): Argument 1 of EntityTypeManager::getDefinition has wrong name $entity_type_id, expecting $plugin_id as defined by PluginManagerBase::getDefinition
  • core/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php:62 ParamNameMismatch (error): Argument 1 of ConfigEntityAdapter::onChange has wrong name $property_name, expecting $name as defined by TraversableTypedDataInterface::onChange
  • core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php:63 ParamNameMismatch (error): Argument 1 of EntityDataDefinition::createFromDataType has wrong name $data_type, expecting $type as defined by DataDefinition::createFromDataType
  • core/lib/Drupal/Core/Field/BaseFieldDefinition.php:57 ParamNameMismatch (error): Argument 1 of BaseFieldDefinition::create has wrong name $type, expecting $item_type as defined by ListDataDefinition::create
  • … and 65 more
✅ wordpress: issues +0 −2

Memory 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

Issue type added removed
ParamNameMismatch 0 2

Removed (2)

  • src/wp-includes/Requests/src/Utility/FilteredIterator.php:96 ParamNameMismatch (error): Argument 1 of FilteredIterator::unserialize has wrong name $data, expecting $serialized as defined by ArrayIterator::unserialize
  • src/wp-includes/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php:240 ParamNameMismatch (error): Argument 1 of WP_REST_Template_Autosaves_Controller::get_parent has wrong name $parent_id, expecting $parent_post_id as defined by WP_REST_Revisions_Controller::get_parent

head 27f2fb0 · base 46d8098 (merge-base) · workflow run

@orklah orklah left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

jirkace and others added 2 commits November 23, 2026 16:41
…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>
@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 23, 2026

@orklah orklah left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jirkace!

@orklah
orklah merged commit 87aa0e6 into vimeo:master Nov 23, 2026
116 of 118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:fix The PR will be included in 'Fixes' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unfixable ParamNameMismatch when multiple parent classes/interfaces have conflicting param names already

2 participants