Skip to content

Keep the intersection of a template return type resolved to object - #14684

Merged
danog merged 1 commit into
vimeo:masterfrom
danog:keep-template-intersection-types
Nov 23, 2026
Merged

danog merged 1 commit into
vimeo:masterfrom
danog:keep-template-intersection-types

Conversation

@danog

@danog danog commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Resolving a T&Stub return type whose T is only known as object (e.g. a mixed class-string<T> argument) shifted Stub out of the template parameter in the method's storage, so every later call of the method in the same process returned T without the intersection:

$this->createStub($className);                     // T resolved to object
$stub = $this->createStub(SerializerInterface::class);
$stub->method('serialize');                        // UndefinedInterfaceMethod: SerializerInterface::method does not exist

The result depended on which files a process analyzed before, so it changed with --threads (on symfony/ai, 355 false UndefinedInterfaceMethod with one thread, 71 with four).

@github-actions

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: decreased

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 769 96.9 25 714 53 040 682 0
✅ symfony 3 628 261.6 $\color{gray}{\textsf{+1.8\%}}$ 51 742 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-2}}$ 100 574 $\color{green}{\textsf{-6}}$ 1 572 0
✅ doctrine-orm 380 21.7 $\color{gray}{\textsf{+3.0\%}}$ 3 481 6 153 0 0
✅ psl 617 27.5 $\color{gray}{\textsf{+1.1\%}}$ 1 395 5 637 1 0
✅ phpunit 455 13.8 $\color{gray}{\textsf{+2.8\%}}$ 1 735 3 418 18 0
✅ php-parser 226 8.9 $\color{gray}{\textsf{+1.5\%}}$ 17 118 21 193 0 0
✅ tempest 895 24.9 $\color{gray}{\textsf{-0.3\%}}$ 5 070 10 567 252 0
✅ amphp-amp 46 1.1 $\color{gray}{\textsf{-0.9\%}}$ re-run 29 49 0 0
✅ webmozarts-assert 273 3.6 $\color{gray}{\textsf{-0.3\%}}$ 575 2 714 0 0
✅ guzzle-promises 45 1.3 $\color{gray}{\textsf{+0.8\%}}$ 156 436 2 0
✅ monolog 135 4.3 $\color{gray}{\textsf{-2.5\%}}$ 917 2 491 10 0
✅ drupal 4 843 263.9 $\color{gray}{\textsf{+3.4\%}}$ 97 797 169 645 575 0
✅ wordpress 2 041 168.6 $\color{gray}{\textsf{+0.5\%}}$ 143 516 678 190 461 1
Total 15 352 897.9 $\color{gray}{\textsf{+1.8\%}}$ 349 245 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-2}}$ 1 054 107 $\color{green}{\textsf{-6}}$ 3 573 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.
✅ symfony: issues +0 −2

Memory 3 628 → 3 628 MB (<0.1 %) · Wall 257.0 → 261.6 s (+1.8 %)

Weighted 100 580 → 100 574 (−6, −0.01 %): L3 −2

Issue type added removed
LessSpecificReturnStatement 0 1
MoreSpecificReturnType 0 1

Removed (2)

  • src/Symfony/Component/DependencyInjection/Extension/Extension.php:60 MoreSpecificReturnType (error): The declared return type 'ConfigurationInterface|null' for Extension::getConfiguration is more specific than the inferred return type 'null|object'
  • src/Symfony/Component/DependencyInjection/Extension/Extension.php:80 LessSpecificReturnStatement (error): The type 'object' is more general than the declared return type 'ConfigurationInterface|null' for Extension::getConfiguration

head 98101fd · base 81915ee (merge-base) · workflow run

@danog danog added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 23, 2026
@danog
danog merged commit 2a3c9e4 into vimeo:master Nov 23, 2026
57 of 75 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.

1 participant