Skip to content

Report values sharing only null or false with the expected type as invalid - #14742

Merged
orklah merged 4 commits into
vimeo:masterfrom
orklah:null-false-overlap-invalid
Nov 23, 2026
Merged

orklah merged 4 commits into
vimeo:masterfrom
orklah:null-false-overlap-invalid

Conversation

@orklah

@orklah orklah commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

A value that only shares null or false with the expected type is reported as PossiblyInvalid… instead of Invalid… in three places, unlike other arguments and property assignments.

Closure parameters of array_map & co.

Before

<?php
final class Foo {}
final class Bar {}

/** @param list<?Foo> $l */
function f(array $l): void {
    array_map(function (?Bar $b): int { return 1; }, $l); // PossiblyInvalidArgument
}

After

    array_map(function (?Bar $b): int { return 1; }, $l); // InvalidArgument

Explicit __set() calls on a @property

Before

<?php
final class Foo {}
final class Bar {}

/** @property ?Bar $p */
final class A {
    /** @param mixed $value */
    public function __set(string $name, $value): void {}
}

function f(A $a, ?Foo $foo): void {
    $a->__set("p", $foo); // PossiblyInvalidPropertyAssignmentValue
}

After

    $a->__set("p", $foo); // InvalidPropertyAssignmentValue

false inside an expected bool

Before

<?php
final class Foo {}
final class Bar {}

function takes(Bar|bool $b): void {}

function f(Foo|false $foo): void {
    takes($foo); // PossiblyInvalidArgument
}

After

    takes($foo); // InvalidArgument

orklah and others added 2 commits November 23, 2026 20:27
… a pseudo property as invalid

array_map-style closure parameters and explicit __set() calls reported
PossiblyInvalidArgument / PossiblyInvalidPropertyAssignmentValue when the
value only shared null or false with the expected type, unlike other
arguments and property assignments, which use canBeContainedBy() with
null and false skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
canBeContainedBy() with $ignore_false skipped a false in the expected type
but not the false of a bool, so Foo|false passed to Bar|bool was reported
as possibly invalid while Foo|false passed to Bar|false was invalid.

Co-Authored-By: Claude Opus 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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T19:38:13.416052Z cb4e0ee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb4e0ee342

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

orklah and others added 2 commits November 23, 2026 20:41
A template bounded by bool was compared to the true the expected bool had
become, and no longer fitted. Dropping the parts of the value that are only
null or only false keeps everything else unchanged, and also covers false
inside an expected scalar.

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

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: increased

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 772 92.7 $\color{gray}{\textsf{+1.0\%}}$ 25 792 53 100 743 0
✅ symfony 3 619 171.9 $\color{gray}{\textsf{-2.8\%}}$ 51 767 $\color{red}{\textsf{+1}}$ $\color{green}{\textsf{-1}}$ 100 632 $\color{red}{\textsf{+3}}$ 1 582 0
✅ doctrine-orm 381 22.5 $\color{gray}{\textsf{+0.1\%}}$ 3 459 6 218 0 0
✅ psl 618 25.9 $\color{gray}{\textsf{+0.3\%}}$ 1 387 5 600 1 0
✅ phpunit 456 18.8 $\color{gray}{\textsf{+0.4\%}}$ 1 735 3 418 18 0
✅ php-parser 226 12.4 $\color{gray}{\textsf{-0.7\%}}$ 17 116 21 187 0 0
✅ tempest 898 35.0 $\color{gray}{\textsf{-0.2\%}}$ 5 094 10 556 275 0
✅ amphp-amp 48 1.1 $\color{gray}{\textsf{+1.0\%}}$ 29 49 0 0
✅ webmozarts-assert 273 2.9 $\color{gray}{\textsf{-1.4\%}}$ 575 2 714 0 0
✅ guzzle-promises 46 1.1 $\color{gray}{\textsf{-4.2\%}}$ 155 433 2 0
✅ monolog 136 4.0 $\color{gray}{\textsf{+2.0\%}}$ 918 2 491 11 0
✅ drupal 4 847 236.5 $\color{gray}{\textsf{-2.1\%}}$ 97 949 $\color{red}{\textsf{+1}}$ $\color{green}{\textsf{-1}}$ 169 918 $\color{red}{\textsf{+3}}$ 575 0
✅ wordpress 2 061 185.9 $\color{gray}{\textsf{+0.1\%}}$ 143 633 $\color{red}{\textsf{+2}}$ $\color{green}{\textsf{-2}}$ 678 509 $\color{red}{\textsf{+6}}$ 505 1
Total 15 381 810.8 $\color{gray}{\textsf{-1.1\%}}$ 349 609 $\color{red}{\textsf{+4}}$ $\color{green}{\textsf{-4}}$ 1 054 825 $\color{red}{\textsf{+12}}$ 3 712 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: drift: same issue count, weight changed; issues +1 −1

Memory 3 619 → 3 619 MB (+0.0 %) · Wall 177.0 → 171.9 s (−2.8 %)

Weighted 100 629 → 100 632 (+3, <0.01 %): L3 −1 · L6 +1

Issue type added removed
InvalidPropertyAssignmentValue 1 0
PossiblyInvalidPropertyAssignmentValue 0 1

Changed in place (1)

@​@​ src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php:58 @​@​
- PossiblyInvalidPropertyAssignmentValue: …ParentNodeDefinitionInterface|null' cannot be assigned possibly different type 'NodeDefinition&ParentNodeDefinitionInterface…
+ InvalidPropertyAssignmentValue:         …ParentNodeDefinitionInterface|null' cannot be assigned type 'NodeDefinition&ParentNodeDefinitionInterface…
✅ drupal: drift: same issue count, weight changed; issues +1 −1

Memory 4 847 → 4 847 MB (+0.0 %) · Wall 241.5 → 236.5 s (−2.1 %)

Weighted 169 915 → 169 918 (+3, <0.01 %): L3 −1 · L6 +1

Issue type added removed
InvalidArgument 1 0
PossiblyInvalidArgument 0 1

Changed in place (1)

@​@​ core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:270 @​@​
- PossiblyInvalidArgument: …array_map expects HttpExceptionInterface, but possibly different type ResourceIdentifierInterface provided
+ InvalidArgument:         …array_map expects HttpExceptionInterface, but ResourceIdentifierInterface provided
✅ wordpress: drift: same issue count, weight changed; issues +2 −2

Memory 2 061 → 2 061 MB (+0.0 %) · Wall 185.7 → 185.9 s (+0.1 %)

Weighted 678 503 → 678 509 (+6, <0.01 %): L3 −2 · L6 +2

Issue type added removed
InvalidArgument 2 0
PossiblyInvalidArgument 0 2

Changed in place (2)

@​@​ 2 places @​@​
  src/wp-includes/media.php:3870
  src/wp-includes/media.php:3899
- PossiblyInvalidArgument: …get_adjacent_image_link expects bool, but possibly different type false|string provided
+ InvalidArgument:         …get_adjacent_image_link expects bool, but false|string provided

head 6eb84fa · base b5ea40d (merge-base) · workflow run

@orklah
orklah merged commit a153399 into vimeo:master Nov 23, 2026
72 checks passed
@orklah
orklah deleted the null-false-overlap-invalid branch November 23, 2026 19:58
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