Skip to content

Share the value-vs-expected-type issue tree between arguments, returns and properties (experimental) - #14727

Merged
orklah merged 6 commits into
vimeo:masterfrom
orklah:type-mismatch-reporter
Nov 23, 2026
Merged

orklah merged 6 commits into
vimeo:masterfrom
orklah:type-mismatch-reporter

Conversation

@orklah

@orklah orklah commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Experimental. This PR comes from a codebase-wide simplification survey, not from an issue. It moves the "value type vs expected type → which issue" decision tree that ArgumentAnalyzer::verifyType(), ReturnAnalyzer, InstancePropertyAssignmentAnalyzer and StaticPropertyAssignmentAnalyzer each walked on their own into one TypeMismatchReporter, with a subclass per place giving its issues. Aligning the four trees fixes the gaps below.

Static property assignments are not checked for null and false

Psalm's own PsalmEndToEndTestCase had one (self::$tmpDir = tempnam(...)).

Before

<?php
final class A {
    public static int $i = 0;
}

A::$i = null; // no issue

After

A::$i = null; // PossiblyNullPropertyAssignmentValue

true|int accepts false for properties and return values

Before

<?php
final class A {
    public true|int $p = 1;

    public function set(int|false $i): void {
        $this->p = $i; // no issue
    }
}

function f(int|false $i): true|int { // no issue
    return $i; // no issue
}

After

        $this->p = $i; // PossiblyFalsePropertyAssignmentValue
function f(int|false $i): true|int { // InvalidFalsableReturnType
    return $i; // FalsableReturnStatement

Under strict_types, a Stringable assigned to or returned as a native string is only an ImplicitToStringCast

PHP throws a TypeError there, as it does for arguments, which Psalm already reports as InvalidArgument.

Before

<?php
declare(strict_types=1);

final class S {
    public function __toString(): string {
        return "s";
    }
}

final class A {
    public string $s = "";

    /** @var non-empty-string */
    public string $nes = "a";

    public function set(S $s): void {
        $this->s = $s; // ImplicitToStringCast
        $this->nes = $s; // PropertyTypeCoercion
    }
}

function f(S $s): string { // ImplicitToStringCast
    return $s;
}

After

        $this->s = $s; // InvalidPropertyAssignmentValue
        $this->nes = $s; // InvalidPropertyAssignmentValue
function f(S $s): string { // InvalidReturnType
    return $s; // InvalidReturnStatement

In a namespaced file, strict_types only applies to class methods

The statements of a namespace, its functions and its closures were analysed before the declare that precedes the namespace.

Before

<?php
declare(strict_types=1);

namespace N;

final class S {
    public function __toString(): string {
        return "s";
    }
}

function takesString(string $s): void {}

function f(S $s): void {
    takesString($s); // ImplicitToStringCast
}

takesString(new S()); // ImplicitToStringCast

After

    takesString($s); // InvalidArgument
takesString(new S()); // InvalidArgument

The code of a trait is checked under the strict_types of the class that uses it

PHP applies the strict_types of the file the code is written in.

Before

<?php // trait.php
trait T {
    public function set(S $o): void {
        takesString($o); // InvalidArgument, when a class of a strict_types file uses T
    }
}

After

        takesString($o); // ImplicitToStringCast

Smaller alignments

  • A nullable static property assigned ?string reports InvalidPropertyAssignmentValue, like instance properties and arguments, instead of PossiblyInvalidPropertyAssignmentValue (self::$nullableInt = $nullableString;), and its PossiblyInvalidPropertyAssignmentValue message says "possibly different type" like the instance one.
  • An instance property assigned int|null|false reports both PossiblyNullPropertyAssignmentValue and PossiblyFalsePropertyAssignmentValue, like arguments and return statements, instead of stopping after the first; on an A|B object, a possibly null value no longer hides the PossiblyInvalidPropertyAssignmentValue of the other class.
  • A value that is exactly null or false is reported even when it comes from a @psalm-ignore-nullable-return/@psalm-ignore-falsable-return function, as arguments already did.
  • ToStringTest::implicitCastInToString loses its declare(strict_types=1): under strict types, a __toString() returning an object throws a TypeError, now reported as InvalidReturnStatement/InvalidToString; the case still covers the cast without strict types.

…s and properties

ArgumentAnalyzer::verifyType(), ReturnAnalyzer and the instance and static property
assignment analyzers each walked the same tree after UnionTypeComparator::isContainedBy()
(coercion from mixed, coercion, __toString cast, mismatch, null and false). It now lives in
TypeMismatchReporter, with one subclass per place giving its issues.

Aligning the trees fixes:
- static property assignments were never checked for null and false;
- true|int accepted false for properties and return values;
- under strict_types, a Stringable assigned to or returned as a native string was only an
  ImplicitToStringCast, while PHP throws a TypeError.

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-23T16:33:58.483060Z
We couldn’t complete this review. Comment @codex review to try again.
2a3a452 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

orklah and others added 4 commits November 23, 2026 17:54
Under strict_types, an object only fitting a native string through __toString does not fit
through a coercion of the cast string either (a non-empty-string property, a narrower return
type). The rule now lives in TypeMismatchReporter for arguments, properties and returns.

The code of a trait is analysed under the strict_types of the trait's file, not of the file of
the class that uses it.

Also adds the purity annotations of the reporters, and fixes the possibly false tempnam()
assignment to a static property the new check found in PsalmEndToEndTestCase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scanner records the strict_types declaration in the file storage, and each function-like
is analysed under the strict_types of its file: the methods of a trait, including a trait
constructor analysed for property initialisations, follow the trait's file, and a file starting
with a shebang keeps its declaration. ReturnTypeAnalyzer also reports InvalidReturnType when a
Stringable only fits a native return type through __toString and a coercion.

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

ClassLikeAnalyzer::getMethodMutations() analyses the called method with the context of the
caller, which the method now sets to the strict_types of its own file.

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

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: increased

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 772 79.0 $\color{gray}{\textsf{+2.7\%}}$ 25 790 $\color{red}{\textsf{+12}}$ $\color{green}{\textsf{-6}}$ 53 085 $\color{red}{\textsf{+27}}$ 743 0
✅ symfony 3 619 264.9 $\color{gray}{\textsf{+0.4\%}}$ 51 774 $\color{red}{\textsf{+21}}$ $\color{green}{\textsf{-2}}$ 100 640 $\color{red}{\textsf{+57}}$ 1 582 0
✅ doctrine-orm 381 23.1 $\color{gray}{\textsf{-3.0\%}}$ 3 458 6 215 0 0
✅ psl 618 31.0 1 387 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-3}}$ 5 600 $\color{green}{\textsf{-13}}$ 1 0
✅ phpunit 456 11.4 $\color{gray}{\textsf{+0.9\%}}$ 1 735 3 418 18 0
✅ php-parser 226 7.6 $\color{gray}{\textsf{-1.3\%}}$ 17 116 21 187 0 0
✅ tempest 898 20.7 $\color{gray}{\textsf{+0.4\%}}$ 5 094 $\color{red}{\textsf{+25}}$ $\color{green}{\textsf{-24}}$ 10 556 $\color{green}{\textsf{-11}}$ 275 0
✅ amphp-amp 48 $\color{gray}{\textsf{+0.1\%}}$ 1.6 $\color{gray}{\textsf{+1.2\%}}$ 29 49 0 0
✅ webmozarts-assert 273 4.9 $\color{gray}{\textsf{-0.8\%}}$ 575 2 714 0 0
✅ guzzle-promises 46 1.8 $\color{gray}{\textsf{+1.2\%}}$ 155 $\color{gray}{\textsf{+0}}$ $\color{green}{\textsf{-1}}$ 433 $\color{green}{\textsf{-3}}$ 2 0
✅ monolog 136 6.2 $\color{gray}{\textsf{+1.0\%}}$ 918 2 491 11 0
✅ drupal 4 847 246.3 $\color{gray}{\textsf{+0.6\%}}$ 97 949 $\color{red}{\textsf{+10}}$ $\color{green}{\textsf{-8}}$ 169 915 $\color{red}{\textsf{+11}}$ 575 0
✅ wordpress 2 061 104.1 $\color{gray}{\textsf{-0.2\%}}$ 143 655 $\color{red}{\textsf{+8}}$ $\color{gray}{\textsf{-0}}$ 678 586 $\color{red}{\textsf{+28}}$ 505 1
Total 15 380 802.5 $\color{gray}{\textsf{+0.5\%}}$ 349 635 $\color{red}{\textsf{+76}}$ $\color{green}{\textsf{-44}}$ 1 054 889 $\color{red}{\textsf{+96}}$ 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.
✅ laravel: issues +12 −6

Memory 1 772 → 1 772 MB (<0.1 %) · Wall 77.0 → 79.0 s (+2.7 %)

Weighted 53 058 → 53 085 (+27, +0.05 %): L3 +3 · L6 +3

Issue type added removed
InvalidPropertyAssignmentValue 3 0
PossiblyInvalidPropertyAssignmentValue 3 6
PossiblyNullPropertyAssignmentValue 6 0

Changed in place (6); {self} is the class named after the file

@​@​ 3 places @​@​
  src/Illuminate/Database/Eloquent/Model.php:622
  src/Illuminate/Database/Eloquent/Model.php:644
  src/Illuminate/Database/Eloquent/Model.php:666
- PossiblyInvalidPropertyAssignmentValue: static::$lazyLoadingViolationCallback with declared type 'callable[impure]({self}, string):mixed|null' cannot be assigned type 'callable[impure]({self}, string, LazyLoadingViolationException):mixed|null'
+ InvalidPropertyAssignmentValue:         static::$lazyLoadingViolationCallback with declared type 'callable[impure]({self}, string):mixed|null' cannot be assigned type 'callable[impure]({self}, string, LazyLoadingViolationException):mixed|null'

@​@​ 3 places PossiblyInvalidPropertyAssignmentValue @​@​
  src/Illuminate/Validation/Rules/Email.php:80
  src/Illuminate/Validation/Rules/File.php:109
  src/Illuminate/Validation/Rules/Password.php:158
- …impure]|null|string' cannot be assigned type 'TGeneratedFromParam0:fn-email::defaults…
+ …impure]|null|string' cannot be assigned possibly different type 'TGeneratedFromParam0:fn-email::defaults…

Added (6)

  • src/Illuminate/Database/Eloquent/Factories/Factory.php:1124 PossiblyNullPropertyAssignmentValue (error): static::$modelNameResolver with non-nullable declared type 'callable[impure](Factory):class-string<TModel>' cannot be assigned nullable type 'null'
  • src/Illuminate/Database/Eloquent/Factories/Factory.php:1126 PossiblyNullPropertyAssignmentValue (error): static::$factoryNameResolver with non-nullable declared type 'callable[impure]' cannot be assigned nullable type 'null'
  • src/Illuminate/Database/Eloquent/Model.php:2347 PossiblyNullPropertyAssignmentValue (error): static::$resolver with non-nullable declared type 'ConnectionResolverInterface' cannot be assigned nullable type 'null'
  • src/Illuminate/Support/DateFactory.php:162 PossiblyNullPropertyAssignmentValue (error): static::$callable with non-nullable declared type 'callable[impure]' cannot be assigned nullable type 'null'
  • src/Illuminate/Support/DateFactory.php:191 PossiblyNullPropertyAssignmentValue (error): static::$callable with non-nullable declared type 'callable[impure]' cannot be assigned nullable type 'null'
  • src/Illuminate/Support/DateFactory.php:205 PossiblyNullPropertyAssignmentValue (error): static::$callable with non-nullable declared type 'callable[impure]' cannot be assigned nullable type 'null'
✅ symfony: issues +21 −2

Memory 3 619 → 3 619 MB (<0.1 %) · Wall 263.8 → 264.9 s (+0.4 %)

Weighted 100 583 → 100 640 (+57, +0.06 %): L3 +19

Issue type added removed
PossiblyFalsePropertyAssignmentValue 3 0
PossiblyInvalidPropertyAssignmentValue 1 1
PossiblyNullPropertyAssignmentValue 17 1

Changed in place (2)

@​@​ src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php:184 PossiblyInvalidPropertyAssignmentValue @​@​
- …array<array-key, mixed>' cannot be assigned type 'UnitEnum|array<array-key, mixed>|null…
+ …array<array-key, mixed>' cannot be assigned possibly different type 'UnitEnum|array<array-key, mixed>|null…

@​@​ src/Symfony/Component/VarDumper/Caster/XmlReaderCaster.php:84 PossiblyNullPropertyAssignmentValue @​@​
-  with non-nullable declared type 'int' cannot…
+ EnumStub::$cut with non-nullable declared type 'int' cannot…

Added (19)

  • src/Symfony/Component/Cache/Adapter/AbstractAdapter.php:60 PossiblyNullPropertyAssignmentValue (error): AbstractAdapter::$createCacheItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[write-props|read-globals|write-globals|io|time](mixed…
  • src/Symfony/Component/Cache/Adapter/AbstractAdapter.php:73 PossiblyNullPropertyAssignmentValue (error): AbstractAdapter::$mergeByLifetime with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[impure](mixed, mixed, mixed &$_, mixed, mixed):array<…
  • src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php:72 PossiblyNullPropertyAssignmentValue (error): AbstractTagAwareAdapter::$createCacheItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[pure](mixed, mixed, mixed):CacheItem|…
  • src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php:97 PossiblyNullPropertyAssignmentValue (error): AbstractTagAwareAdapter::$mergeByLifetime with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[impure](mixed, mixed &$_, mixed, mixe…
  • src/Symfony/Component/Cache/Adapter/ArrayAdapter.php:62 PossiblyNullPropertyAssignmentValue (error): ArrayAdapter::$createCacheItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[pure](mixed, mixed, mixed, mixed, mixed=, mixed=):CacheItem…
  • src/Symfony/Component/Cache/Adapter/ChainAdapter.php:72 PossiblyNullPropertyAssignmentValue (error): ChainAdapter::$syncItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[impure](mixed, mixed, mixed, mixed=):mixed|null'
  • src/Symfony/Component/Cache/Adapter/NullAdapter.php:28 PossiblyNullPropertyAssignmentValue (error): NullAdapter::$createCacheItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[pure](mixed):CacheItem|null'
  • src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php:53 PossiblyNullPropertyAssignmentValue (error): PhpArrayAdapter::$createCacheItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[pure](mixed, mixed, mixed):CacheItem|null'
  • src/Symfony/Component/Cache/Adapter/ProxyAdapter.php:55 PossiblyNullPropertyAssignmentValue (error): ProxyAdapter::$createCacheItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[read-props|write-props|read-globals|write-globals|io|time](…
  • src/Symfony/Component/Cache/Adapter/ProxyAdapter.php:79 PossiblyNullPropertyAssignmentValue (error): ProxyAdapter::$setInnerItem with non-nullable declared type 'Closure[impure]' cannot be assigned nullable type 'Closure[impure]|Closure[impure](CacheItemInterface, CacheItem, mixed=):void|null'
  • … and 9 more
✅ psl: issues +0 −3

Memory 618 → 618 MB (<0.1 %) · Wall 31.0 → 31.0 s (+0.0 %)

Weighted 5 613 → 5 600 (−13, −0.23 %): L3 −1 · L5 −2

Issue type added removed
InvalidNullableReturnType 0 1
NullableReturnStatement 0 1
PossiblyNullArgument 0 1

Removed (3)

  • packages/env/src/Psl/Env/current_exec.php:16 InvalidNullableReturnType (error): The declared return type 'string' for current_exec is not nullable, but 'null|string' contains null
  • packages/env/src/Psl/Env/current_exec.php:23 PossiblyNullArgument (error): Argument 1 of is_link cannot be null, possibly null value provided
  • packages/env/src/Psl/Env/current_exec.php:30 NullableReturnStatement (error): The declared return type 'string' for current_exec is not nullable, but the function returns 'null|string'
✅ tempest: issues +25 −24

Memory 898 → 898 MB (+0.0 %) · Wall 20.6 → 20.7 s (+0.4 %)

Weighted 10 567 → 10 556 (−11, −0.10 %): L3 +21 · L4 −23 · L6 +3

Issue type added removed
ImplicitToStringCast 0 21
InvalidReturnStatement 2 0
InvalidReturnType 1 0
InvalidScalarArgument 0 2
MixedArgument 1 0
MixedReturnStatement 0 1
PossiblyInvalidArgument 21 0

Changed in place (9)

@​@​ 2 places @​@​
  packages/console/src/Components/Interactive/TextInputComponent.php:46
  packages/core/src/PublishesFiles.php:267
- InvalidScalarArgument:   …StaticTextBoxComponent::__construct expects null|string, but int|null|string provided
+ PossiblyInvalidArgument: …StaticTextBoxComponent::__construct expects null|string, but possibly different type int|null|string provided

@​@​ packages/core/src/PublishesFiles.php:246 @​@​
- ImplicitToStringCast:    Argument 1 of AuthenticationInstaller::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of OAuthInstaller::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of CommandRepositoryInstaller::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeCommandCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeConfigCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeGeneratorCommandCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeMiddlewareCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of ConsoleInstaller::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of GeneratorCommandStub::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeMigrationCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeModelCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeRequestCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of MakeResponseCommand::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of SessionInstaller::detectIndent expects string, but ImmutableString|string provided with a __toString method
- ImplicitToStringCast:    Argument 1 of ViteInstaller::detectIndent expects string, but ImmutableString|string provided with a __toString method
+ PossiblyInvalidArgument: Argument 1 of AuthenticationInstaller::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of OAuthInstaller::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of CommandRepositoryInstaller::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeCommandCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeConfigCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeGeneratorCommandCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeMiddlewareCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of ConsoleInstaller::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of GeneratorCommandStub::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeMigrationCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeModelCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeRequestCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of MakeResponseCommand::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of SessionInstaller::detectIndent expects string, but possibly different type ImmutableString|string provided
+ PossiblyInvalidArgument: Argument 1 of ViteInstaller::detectIndent expects string, but possibly different type ImmutableString|string provided

@​@​ 4 places @​@​
  packages/core/src/PublishesFiles.php:248
  packages/support/src/Namespace/functions.php:95
  packages/support/src/Regex/functions.php:122
  packages/support/src/Str/functions.php:191
- ImplicitToStringCast:    Argument 1 of decode expects string, but ImmutableString|string provided with a __toString method
+ PossiblyInvalidArgument: Argument 1 of decode expects string, but possibly different type ImmutableString|string provided

@​@​ packages/database/src/Casters/EncryptedCaster.php:27 @​@​
- MixedReturnStatement:   Could not infer a return type
+ InvalidReturnStatement: The inferred type 'EncryptedData|mixed|string' does not match the declared return type 'null|string' for EncryptedCaster::cast

@​@​ packages/support/src/Str/functions.php:645 @​@​
- ImplicitToStringCast: The declared return type for slice expects 'string', 'Stringable|string' provided with a __toString method
+ InvalidReturnType:    The declared return type 'string' for slice is incorrect, got 'Stringable|string'

Added (2)

  • packages/debug/src/Debug.php:139 MixedArgument (error): Argument 2 of str_repeat cannot be int<0, max>|mixed, expecting int
  • packages/support/src/Str/functions.php:650 InvalidReturnStatement (error): The inferred type 'Stringable|string' does not match the declared return type 'string' for slice

Removed (1)

  • packages/support/src/Str/functions.php:180 ImplicitToStringCast (error): Argument 1 of preg_quote expects string, but Stringable|iterable<mixed, mixed>|string provided with a __toString method
✅ guzzle-promises: issues +0 −1

Memory 46 → 46 MB (+0.0 %) · Wall 1.7 → 1.8 s (+1.2 %)

Weighted 436 → 433 (−3, −0.69 %): L3 −1

Issue type added removed
PossiblyNullArgument 0 1

Removed (1)

  • src/EachPromise.php:134 PossiblyNullArgument (error): Argument 1 of next cannot be null, possibly null value provided
✅ drupal: issues +10 −8

Memory 4 847 → 4 847 MB (<0.1 %) · Wall 244.8 → 246.3 s (+0.6 %)

Weighted 169 904 → 169 915 (+11, +0.01 %): L3 +1 · L4 −1 · L6 +2

Issue type added removed
ImplicitToStringCast 0 1
InvalidPropertyAssignmentValue 3 3
InvalidReturnStatement 1 0
InvalidReturnType 1 0
PossiblyNullPropertyAssignmentValue 5 4

Changed in place (8)

@​@​ core/modules/ckeditor5/src/Controller/EntityLinkSuggestionsController.php:284 @​@​
- ImplicitToStringCast: The declared return type for EntityLinkSuggestionsController::computeGroup expects 'string', 'TranslatableMarkup|string' provided with a __toString method
+ InvalidReturnType:    The declared return type 'string' for EntityLinkSuggestionsController::computeGroup is incorrect, got 'TranslatableMarkup|string'

@​@​ 2 places InvalidPropertyAssignmentValue @​@​
  core/modules/locale/src/LocaleSource.php:109
  core/modules/locale/src/LocaleSource.php:124
-  with declared type 'array<array-key, LocaleFile…
+ LocaleTranslationSource::$files with declared type 'array<array-key, LocaleFile…

@​@​ 2 places PossiblyNullPropertyAssignmentValue @​@​
  core/modules/locale/src/LocaleSource.php:131
  core/modules/locale/src/LocaleSource.php:152
-  with non-nullable declared type 'int' cannot…
+ LocaleTranslationSource::$timestamp with non-nullable declared type 'int' cannot…

@​@​ core/modules/views/src/Entity/View.php:528 PossiblyNullPropertyAssignmentValue @​@​
-  with non-nullable declared type 'string…
+ ViewExecutable::$current_display with non-nullable declared type 'string…

@​@​ core/modules/views/src/Plugin/views/query/Sql.php:1709 PossiblyNullPropertyAssignmentValue @​@​
-  with non-nullable declared type 'EntityInterface…
+ ResultRow::$_entity with non-nullable declared type 'EntityInterface…

@​@​ core/modules/views/src/Plugin/views/query/Sql.php:1712 InvalidPropertyAssignmentValue @​@​
-  with declared type 'array<array-key, EntityInterface…
+ ResultRow::$_relationship_entities with declared type 'array<array-key, EntityInterface…

Added (2)

  • core/lib/Drupal/Component/Utility/Html.php:246 PossiblyNullPropertyAssignmentValue (error): static::$seenIds with non-nullable declared type 'array<array-key, mixed>' cannot be assigned nullable type 'null'
  • core/modules/ckeditor5/src/Controller/EntityLinkSuggestionsController.php:290 InvalidReturnStatement (error): The inferred type 'TranslatableMarkup|string' does not match the declared return type 'string' for EntityLinkSuggestionsController::computeGroup
✅ wordpress: issues +8 −0

Memory 2 061 → 2 061 MB (<0.1 %) · Wall 104.3 → 104.1 s (−0.2 %)

Weighted 678 558 → 678 586 (+28, <0.01 %): L3 +6 · L5 +2

Issue type added removed
FalsableReturnStatement 2 0
PossiblyNullPropertyAssignmentValue 6 0

Added (8)

  • src/wp-includes/SimplePie/src/SimplePie.php:1873 FalsableReturnStatement (error): The declared return type 'array<array-key, mixed>|true' for SimplePie::fetch_data does not allow false, but the function returns 'false'
  • src/wp-includes/SimplePie/src/SimplePie.php:1882 FalsableReturnStatement (error): The declared return type 'array<array-key, mixed>|true' for SimplePie::fetch_data does not allow false, but the function returns 'false'
  • src/wp-includes/class-wp-theme-json-resolver.php:744 PossiblyNullPropertyAssignmentValue (error): static::$core with non-nullable declared type 'WP_Theme_JSON' cannot be assigned nullable type 'null'
  • src/wp-includes/class-wp-theme-json-resolver.php:745 PossiblyNullPropertyAssignmentValue (error): static::$blocks with non-nullable declared type 'WP_Theme_JSON' cannot be assigned nullable type 'null'
  • src/wp-includes/class-wp-theme-json-resolver.php:752 PossiblyNullPropertyAssignmentValue (error): static::$theme with non-nullable declared type 'WP_Theme_JSON' cannot be assigned nullable type 'null'
  • src/wp-includes/class-wp-theme-json-resolver.php:753 PossiblyNullPropertyAssignmentValue (error): static::$user with non-nullable declared type 'WP_Theme_JSON' cannot be assigned nullable type 'null'
  • src/wp-includes/class-wp-theme-json-resolver.php:754 PossiblyNullPropertyAssignmentValue (error): static::$user_custom_post_type_id with non-nullable declared type 'int' cannot be assigned nullable type 'null'
  • src/wp-includes/class-wp-theme-json-resolver.php:755 PossiblyNullPropertyAssignmentValue (error): static::$i18n_schema with non-nullable declared type 'array<array-key, mixed>' cannot be assigned nullable type 'null'

head 33070e3 · base 86d44c1 (merge-base) · workflow run

…ment

The statements of a namespace, its functions and the closures in it were analysed before the
declare statement that precedes the namespace, so outside class methods strict_types was not
applied to most files. The file context now takes the declaration recorded by the scanner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@orklah
orklah merged commit 852300d into vimeo:master Nov 23, 2026
72 checks passed
@orklah
orklah deleted the type-mismatch-reporter branch November 23, 2026 18:29
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