File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 2323 "nikic/php-parser" : " ^5.6.2" ,
2424 "ondram/ci-detector" : " ^4.2" ,
2525 "phpstan/phpdoc-parser" : " ^2.3" ,
26- "phpstan/phpstan" : " ^ 2.1.32" ,
26+ "phpstan/phpstan" : " 2.1.19 as 2.1.32" ,
2727 "react/event-loop" : " ^1.6" ,
2828 "react/promise" : " ^3.3" ,
2929 "react/socket" : " ^1.17" ,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \PhpParser \Printer \Fixture ;
4+
5+ $ result = array_map (
6+ array: [1 , 2 , 3 ],
7+ callback: fn (int $ value ) => $ value
8+ );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \PhpParser \Printer ;
6+
7+ use PhpParser \PrettyPrinter \Standard ;
8+ use PHPStan \Parser \Parser ;
9+ use PHPStan \Parser \RichParser ;
10+ use Rector \Testing \PHPUnit \AbstractLazyTestCase ;
11+
12+ /**
13+ * Test case for: https://github.com/rectorphp/rector/issues/9492
14+ * Most likely caused by https://github.com/phpstan/phpstan-src/pull/3763
15+ */
16+ final class PHPStanPrinterTest extends AbstractLazyTestCase
17+ {
18+ public function testAddingCommentOnSomeNodesFail (): void
19+ {
20+ /** @var RichParser $phpstanParser */
21+ $ phpstanParser = $ this ->make (Parser::class);
22+
23+ $ stmts = $ phpstanParser ->parseFile (__DIR__ . '/Fixture/some_array_map.php ' );
24+
25+ // get private property "parser"
26+ $ parserReflectionProperty = new \ReflectionProperty (RichParser::class, 'parser ' );
27+
28+ /** @var \PhpParser\Parser $innerParser */
29+ $ innerParser = $ parserReflectionProperty ->getValue ($ phpstanParser );
30+ $ tokens = $ innerParser ->getTokens ();
31+
32+ $ standardPrinter = new Standard ();
33+ $ printerContents = $ standardPrinter ->printFormatPreserving ($ stmts , $ stmts , $ tokens );
34+
35+ $ this ->assertStringEqualsFile (__DIR__ . '/Fixture/some_array_map.php ' , $ printerContents );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments