Skip to content

Read C::{$name} like C::NAME when $name holds literal names - #14468

Merged
danog merged 1 commit into
vimeo:masterfrom
danog:dynamic-class-constant-fetch
Nov 21, 2026
Merged

danog merged 1 commit into
vimeo:masterfrom
danog:dynamic-class-constant-fetch

Conversation

@danog

@danog danog commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Literal names

A dynamic class constant fetch (PHP 8.3) is mixed even when the name is a known literal, and a missing constant isn't reported.

Before

<?php
final class C {
    public const A = 1;
    public const B = "b";
}
$name = "A";
$a = C::{$name}; // mixed
$either = C::{rand(0, 1) ? "A" : "B"}; // mixed
$missing = "Z";
echo C::{$missing}; // MixedArgument

After

$a = C::{$name}; // 1
$either = C::{rand(0, 1) ? "A" : "B"}; // 'b'|1
echo C::{$missing}; // UndefinedConstant

Missing class

A dynamic fetch on a class that doesn't exist isn't reported.

Before

<?php
function f(string $name): mixed {
    return Missing::{$name}; // no issue
}

After

    return Missing::{$name}; // UndefinedClass

https://claude.ai/code/session_0134ww6vqixM8wK7okgxnEvo

@danog danog added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 21, 2026

@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.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged

Project Memory (MB) Wall (s) Issues Weighted (types) Taint
✅ laravel 1 749 58.1 $\color{gray}{\textsf{-1.5\%}}$ 25 907 53 460 682
✅ symfony 3 599 200.5 $\color{gray}{\textsf{-0.2\%}}$ 50 610 98 403 1 528
✅ doctrine-orm 380 21.6 $\color{gray}{\textsf{-1.8\%}}$ 3 481 6 143 0
✅ psl 617 28.1 $\color{gray}{\textsf{-0.6\%}}$ 1 375 5 615 1
✅ phpunit 455 14.3 $\color{gray}{\textsf{+0.8\%}}$ 1 731 3 410 18
✅ php-parser 226 9.3 $\color{gray}{\textsf{+0.3\%}}$ 17 154 21 245 0
✅ tempest 895 26.8 $\color{gray}{\textsf{+0.4\%}}$ 5 047 10 528 252
✅ amphp-amp 45 0.9 $\color{gray}{\textsf{-3.1\%}}$ 29 49 0
✅ webmozarts-assert 273 2.8 $\color{gray}{\textsf{-1.1\%}}$ 577 2 720 0
✅ guzzle-promises 44 1.0 $\color{gray}{\textsf{-1.9\%}}$ 155 434 2
✅ monolog 135 3.7 $\color{gray}{\textsf{-1.3\%}}$ 913 2 479 10
✅ drupal 4 842 224.8 $\color{gray}{\textsf{+2.1\%}}$ 97 591 169 293 583
Total 13 260 591.9 $\color{gray}{\textsf{+0.5\%}}$ 204 570 373 779 3 076
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 dd845e8 · base 3e7a426 (merge-base) · workflow run

@danog

danog commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot review

1 similar comment
@danog

danog commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot review

@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.

Stale Bugbot comment from a previous run.

@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.

Stale Bugbot comment from a previous run.

@danog
danog force-pushed the dynamic-class-constant-fetch branch from 27474c9 to 322851e Compare November 21, 2026 16:26
@danog

danog commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot review

@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.

Stale Bugbot comment from a previous run.

@danog
danog force-pushed the dynamic-class-constant-fetch branch from 322851e to dd845e8 Compare November 21, 2026 17:32
@danog

danog commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot review

@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.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit dd845e8. Configure here.

@danog
danog merged commit ba64353 into vimeo:master Nov 21, 2026
72 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