Skip to content

fix(visibility): a use adaptation changes the visibility a method call is checked with before __call() - #14399

Merged
orklah merged 1 commit into
vimeo:masterfrom
jirkace:fix/14020-trait-visibility-call
Nov 21, 2026
Merged

orklah merged 1 commit into
vimeo:masterfrom
jirkace:fix/14020-trait-visibility-call

Conversation

@jirkace

@jirkace jirkace commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

A public trait method made private by a use adaptation is reported as InaccessibleMethod when the class has a __call(), although PHP calls __call() for an inaccessible method.

Before

/** @method int product() */
class ParentClass {
    public function __call(string $name, array $args): int {
        return 1;
    }
}

trait RealTrait {
    public function product(): string {
        return "Screen";
    }
}

final class Child extends ParentClass {
    use RealTrait {
        product as private;
    }
}

$a = (new Child)->product(); // InaccessibleMethod, $a: string

After

$a = (new Child)->product(); // no issue, $a: int

A private trait method made protected by an adaptation in a parent class is visible from the child class too, so the grandparent's __call() no longer takes the call over.

Fixes #14020

…l is checked with before __call() vimeo#14020

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

jirkace commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Behaviour change

  • MethodAnalyzer::isMethodVisible() now uses the visibility a use adaptation gives a trait method (as private/as protected), as MethodVisibilityAnalyzer already does. Effects, each covered by a new TraitTest case:
    • a call from outside to a privately aliased trait method goes through __call() (UndefinedMagicMethod without an @method tag, the @method type with one) instead of InaccessibleMethod;
    • a private trait method made protected in a parent class is visible from a child class, so the grandparent's __call() no longer takes the call over;
    • without any __call(), a privately aliased trait method is still InaccessibleMethod (guard test).
  • Self-analysis: only the 2 PoolEventLoopDriverTest MixedArgument errors that master reports too here. Not run: the full suite (CI), corpus benchmarks.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 00c220d. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged

Project Memory (MB) Wall (s) Issues Weighted (types) Taint
✅ laravel 1 766 94.2 $\color{gray}{\textsf{-0.4\%}}$ 25 925 53 512 677
✅ symfony 3 605 161.6 $\color{gray}{\textsf{-0.8\%}}$ 50 580 98 373 1 491
✅ doctrine-orm 393 13.1 $\color{gray}{\textsf{+0.2\%}}$ 3 480 6 161 0
✅ psl 632 17.2 $\color{gray}{\textsf{+0.8\%}}$ 1 299 5 455 1
✅ phpunit 471 20.1 $\color{gray}{\textsf{+0.5\%}}$ 1 744 3 459 18
✅ php-parser 236 13.8 17 133 21 035 0
✅ tempest 903 35.7 $\color{gray}{\textsf{-0.1\%}}$ 5 039 10 507 242
✅ amphp-amp 61 1.5 29 49 0
✅ webmozarts-assert 287 3.4 $\color{gray}{\textsf{+4.7\%}}$ 578 2 724 0
✅ guzzle-promises 56 1.6 $\color{gray}{\textsf{+5.4\%}}$ 154 427 2
✅ monolog 153 4.3 $\color{gray}{\textsf{-2.1\%}}$ 903 2 403 10
✅ drupal 4 850 167.7 $\color{gray}{\textsf{+6.7\%}}$ 97 524 169 104 568
Total 13 413 534.0 $\color{gray}{\textsf{+1.8\%}}$ 204 388 373 209 3 009
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 +20 % 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. Thresholds apply per project, not to the total.
  • 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.

head 00c220d · base cc4ab02 (merge-base) · workflow run

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 21, 2026
@orklah
orklah merged commit 85b4624 into vimeo:master Nov 21, 2026
71 of 72 checks passed
@orklah

orklah commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks @jirkace!

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.

InaccessibleMethod on a trait method made private by a use adaptation when the parent has __call()

2 participants