Skip to content

Fix: array_map() infers list<mixed> for an invokable object callback - #14654

Merged
alies-dev merged 1 commit into
vimeo:masterfrom
alies-dev:alies-dev/array-map-invokable
Nov 22, 2026
Merged

alies-dev merged 1 commit into
vimeo:masterfrom
alies-dev:alies-dev/array-map-invokable

Conversation

@alies-dev

Copy link
Copy Markdown
Collaborator

array_map() with an invokable object as the callback infers list<mixed> instead of the return type of __invoke.

Before

<?php
final class IsLong {
    public function __invoke(string $value): bool { return strlen($value) > 3; }
}

/** @var list<string> $xs */
$xs = [];

$long = array_map(new IsLong(), $xs); // list<mixed>

After

$long = array_map(new IsLong(), $xs); // list<bool>

Fixes #14587

…imeo#14587

array_map() read the return type of closures and callables only, so an invokable object gave list<mixed>. The object now maps through its __invoke callable, unless the arguments are yet to bind its return type (a method template).
@alies-dev alies-dev added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 22, 2026
@alies-dev alies-dev self-assigned this Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged

Project Memory (MB) Wall (s) Issues Weighted (types) Taint
✅ laravel 1 768 73.2 $\color{gray}{\textsf{-1.7\%}}$ 25 691 52 996 682
✅ symfony 3 596 261.2 $\color{gray}{\textsf{+0.2\%}}$ 50 610 98 403 1 528
✅ doctrine-orm 380 20.7 $\color{gray}{\textsf{+0.2\%}}$ 3 481 6 143 0
✅ psl 617 26.8 $\color{gray}{\textsf{-0.1\%}}$ 1 375 5 615 1
✅ phpunit 455 19.5 $\color{gray}{\textsf{+0.1\%}}$ 1 731 3 410 18
✅ php-parser 226 13.3 $\color{gray}{\textsf{-0.4\%}}$ 17 154 21 245 0
✅ tempest 895 35.8 $\color{gray}{\textsf{+0.4\%}}$ 5 047 10 528 252
✅ amphp-amp 45 1.1 $\color{gray}{\textsf{-0.9\%}}$ 29 49 0
✅ webmozarts-assert 272 3.4 $\color{gray}{\textsf{-0.6\%}}$ 577 2 720 0
✅ guzzle-promises 44 1.2 155 434 2
✅ monolog 135 4.2 $\color{gray}{\textsf{-0.2\%}}$ 913 2 479 10
✅ drupal 4 839 245.9 $\color{gray}{\textsf{+0.2\%}}$ 97 591 169 293 583
Total 13 273 706.3 204 354 373 315 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 fe9585d · base b912d10 (merge-base) · workflow run

@alies-dev alies-dev changed the title Fix: array_map() infers list<mixed> for an invokable object callback Fix: array_map() infers list<mixed> for an invokable object callback Nov 22, 2026
@alies-dev
alies-dev merged commit 321c52d into vimeo:master Nov 22, 2026
69 of 73 checks passed
@alies-dev
alies-dev deleted the alies-dev/array-map-invokable branch November 22, 2026 11:35
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.

array_map() infers list<mixed> for an invokable object callback

1 participant