Skip to content

[issue 9492] create reproducer for PHPStan changing array_map args, printing invalid content as result#7676

Merged
TomasVotruba merged 4 commits into
mainfrom
tv-sort-args
Dec 4, 2025
Merged

[issue 9492] create reproducer for PHPStan changing array_map args, printing invalid content as result#7676
TomasVotruba merged 4 commits into
mainfrom
tv-sort-args

Conversation

@TomasVotruba
Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba commented Nov 27, 2025

Test case for: rectorphp/rector#9492

This test uses PHPStan RichParser and native Standard printer to decouple from any Rector custom logic.


How to reproduce:

vendor/bin/phpunit tests/PhpParser/Printer/PHPStanPrinterTest.php

PHPStan 2.1.18 ✔️

Keeps original argument order:

Runtime:       PHP 8.2.29
Configuration: /home/runner/work/rector-src/rector-src/phpunit.xml

.                                                                   1 / 1 (100%)

Time: 00:00.346, Memory: 52.00 MB

OK (1 test, 2 assertions)

PHPStan 2.1.19 🔴

Changes argument order:

Time: 00:00.138, Memory: 38.00 MB

There was 1 failure:

1) Rector\Tests\PhpParser\Printer\PHPStanPrinterTest::testAddingCommentOnSomeNodesFail
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 '...re;\n
 \n
-$result = array_map(array: [1, 2, 3], callback: fn(int $value) => $value);\n
+$result = array_map(callback: fn(int $value) => $value, array: [1, 2, 3]);\n

@TomasVotruba TomasVotruba changed the title tv sort args [issue 9492] create reproducer for PHPStan changing array_map args, printing invalid content as result Nov 27, 2025
@TomasVotruba TomasVotruba force-pushed the tv-sort-args branch 2 times, most recently from 2ab86f8 to 52ef860 Compare November 27, 2025 15:24
Comment thread composer.json Outdated
@TomasVotruba TomasVotruba force-pushed the tv-sort-args branch 2 times, most recently from baa4f0f to 2712027 Compare November 28, 2025 07:55
Comment thread tests/PhpParser/Printer/PHPStanPrinterTest.php Outdated
@TomasVotruba TomasVotruba force-pushed the tv-sort-args branch 4 times, most recently from 1ac947d to 34e1591 Compare November 28, 2025 08:19
Comment thread tests/PhpParser/Printer/PHPStanPrinterTest.php Outdated
@TomasVotruba TomasVotruba merged commit d29e5aa into main Dec 4, 2025
68 of 97 checks passed
@TomasVotruba TomasVotruba deleted the tv-sort-args branch December 4, 2025 21:04
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants