Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PhpParser] Fix crash read jetbrains/phpstorm-stubs included in phpstan.phar on PHP 8.0 and PHP 7.4 #5001

Merged
merged 5 commits into from Sep 12, 2023

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Sep 12, 2023

@vjik this should fix rectorphp/rector#8193

also fix rectorphp/rector#8145

Before

php80 vendor/bin/rector process src/StringableObject.php --dry-run --clear-cache
 0/1 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%string(226) "phar:///Users/samsonasik/www/rector-custom/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/../../../../../jetbrains/phpstorm-stubs/Core/Core_c.stub"
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
                                                                                                                        
 [ERROR] Could not process "src/StringableObject.php" file, due to:                                                     
         "System error: "Syntax error, unexpected T_STRING, expecting T_VARIABLE906, Syntax error, unexpected T_STRING, 
         expecting T_VARIABLE920, Syntax error, unexpected T_STRING, expecting T_VARIABLE945, Syntax error, unexpected  
         T_STRING, expecting T_VARIABLE970, Syntax error, unexpected T_STRING, expecting T_VARIABLE1119"                
         Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 56

After

php80 vendor/bin/rector process src/StringableObject.php --dry-run --clear-cache
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

                                                                                                                        
 [OK] Rector is done!                                                                                                   
                                                                                                                        

@samsonasik samsonasik changed the title [PhpParser] Fix crash read jetbrains/phpstorm-stubs on PHP 8.0 [PhpParser] Fix crash read jetbrains/phpstorm-stubs included in phpstan.phar on PHP 8.0 Sep 12, 2023
@samsonasik
Copy link
Member Author

@buffcode this should also fix rectorphp/rector#8145

Before

php74 vendor/bin/rector process src/DemoFile.php --dry-run --clear-cache
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
                                                                                                                        
 [ERROR] Could not process "src/DemoFile.php" file, due to:                                                             
         "System error: "Argument 2 passed to                                                                           
         Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator::decorateNodesFromFile() must be of the type array, null 
         given, called in vendor/rector/rector/src/PhpParser/AstResolver.php313"                                        
         Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 52

After

php74 vendor/bin/rector process src/DemoFile.php --dry-run --clear-cache
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1 file with changes
===================

1) src/DemoFile.php:0

    ---------- begin diff ----------
@@ @@
 <?php

-class CurlSoapClient extends \SoapClient
+class CurlSoapClient extends SoapClient
 {

     /**
    ----------- end diff -----------

                                                                                                                        
 [OK] 1 file would have changed (dry-run) by Rector                                                                     
                                                                                                                        

@samsonasik samsonasik changed the title [PhpParser] Fix crash read jetbrains/phpstorm-stubs included in phpstan.phar on PHP 8.0 [PhpParser] Fix crash read jetbrains/phpstorm-stubs included in phpstan.phar on PHP 8.0 and PHP 7.4 Sep 12, 2023
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@vjik
Copy link

vjik commented Sep 12, 2023

@samsonasik Thank you! Waiting merge and release.

@TomasVotruba
Copy link
Member

Thank you 👏

@TomasVotruba TomasVotruba merged commit ffa43a1 into main Sep 12, 2023
39 checks passed
@TomasVotruba TomasVotruba deleted the fix-crash-read-phpstrom-stubs branch September 12, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants