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

Do I need the highest PHP version to downgrade? #6419

Closed
shyim opened this issue May 15, 2021 · 8 comments
Closed

Do I need the highest PHP version to downgrade? #6419

shyim opened this issue May 15, 2021 · 8 comments

Comments

@shyim
Copy link
Contributor

shyim commented May 15, 2021

Question

I would give the downgrade possibility a try and got fast a hidden error:

Analyze error: "ParseError (syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE)) thrown while looking for class Frosh\MailArchive\Controller\Api\MailResendController."
```

From the internal error, I assume that I will need PHP 8.0 on cli to downgrade the code from 8.0 to 7.4? Is that right?

Maybe makes sense to check the used PHP version in the CLI then when that set / etc is active 🤔 
@shyim
Copy link
Contributor Author

shyim commented May 15, 2021

Hmm after using PHP 8 on the CLI it works. A RuntimeException would be awesome when the running PHP is below the set

@sabbelasichon
Copy link
Contributor

If you want to downgrade from PHP 8 to PHP 7.4 PHP 8 is needed. True.
Could you provide a solution for better / clearer communication?

@shyim
Copy link
Contributor Author

shyim commented May 15, 2021

Hmm difficult as the set used doesn't matter. Maybe extending the error with a message like: The file couldn't be parsed. This could be a Syntax error or the used PHP to run rector can't read the file.

Btw: Should the Reflection Class stuff doesn't execute the PHP code? 🤔

@sabbelasichon
Copy link
Contributor

We are using Static Reflection here, so no execution involved.

@TomasVotruba
Copy link
Member

The downgrade should work even from version bellow.
It's possible Rector is autoloading projects' vendor/autoload.php. Then the class is invoked from the project and not loaded by static reflection.

Could you provide minimal reproducible repository with failing Github action with the downgrade? We'll be able to help then

@sabbelasichon
Copy link
Contributor

I am surprised, that this is possible. Downgrade from PHP 8 to let´s say to PHP 7.4 by running 7.4. Is this possible due to static reflection? Otherwise i would say, we can close this issue here.

@shyim
Copy link
Contributor Author

shyim commented May 18, 2021

I have packed it as zip. I tried debug_print_backtrace() but couldn't find a caller.

Zip: https://drive.google.com/file/d/183efpMwiW2nmUWz_kfRq92IqOR5OMlMd/view?usp=sharing

Unpack it and run: rector process -c rector.php src/ -a vendor/autoload.php -vvv
You will see then the error: [printing skipped due error] src/Controller/Api/MailResendController.php on PHP 7.4 and with 8.0 it works

@TomasVotruba
Copy link
Member

@shyim At the moment we'll stick with a practise to use the same PHP we downgrade code. The composer install must run on such project anyway. If you don't have such PHP locally and that's a blockre, you can use the GitHub Actions like we do in Rector.

Downgrade from PHP 8 to let´s say to PHP 7.4 by running 7.4. Is this possible due to static reflection? Otherwise i would say, we can close this issue here.

Agreed, we can close it.

TomasVotruba added a commit that referenced this issue Nov 12, 2024
rectorphp/rector-src@06adce3 use ->isInteger()->yes() on ReturnTypeFromStrictNewArrayRector (#6419)
carlos-granados added a commit to carlos-granados/rector that referenced this issue Nov 13, 2024
carlos-granados/rector-src@f7ea3db [PHP8.3] add new rectors for get_class()/get_parent_class() without arguments (rectorphp#6405)
carlos-granados/rector-src@1afc647 Rectify (rectorphp#6408)
carlos-granados/rector-src@afe7c46 [DeadCode] Skip nullable @ template on RemoveUselessReturnTagRector (rectorphp#6409)
carlos-granados/rector-src@293eb97 [Php81] Skip Doctrine Embeddable on ReadOnlyPropertyRector (rectorphp#6411)
carlos-granados/rector-src@1b1807b [Privatization] Skip with parameter on PrivatizeLocalGetterToPropertyRector (rectorphp#6412)
carlos-granados/rector-src@2c67908 Fix ClassDependencyManipulator to add dependency on right position (rectorphp#6413)
carlos-granados/rector-src@29e8932 [automated] Apply Coding Standard (rectorphp#6414)
carlos-granados/rector-src@3949fc2 Move instanceof PHPStan Type to ->is*() take 1 (rectorphp#6416)
carlos-granados/rector-src@0cac71a [CodeQuality] Add fixture test for skip nullable array from property with default value (rectorphp#6417)
carlos-granados/rector-src@d2db35e [Php80] Returns null on no change on ClassPropertyAssignToConstructorPromotionRector (rectorphp#6418)
carlos-granados/rector-src@06adce3 use ->isInteger()->yes() on ReturnTypeFromStrictNewArrayRector (rectorphp#6419)
carlos-granados/rector-src@bcfb598 Add ClassNameFromObjectTypeResolver to cover TypeWithClassName instance checks (rectorphp#6420)
carlos-granados/rector-src@84bb596 [StaticTypeMapper] Reduce instanceof TypeWithClassName usage via ClassNameFromObjectTypeResolver (rectorphp#6421)
carlos-granados/rector-src@26b8b54 [Naming] Reduce instanceof ObjectType on ExpectedNameResolver (take 5) (rectorphp#6423)
carlos-granados/rector-src@5baf487 Require-dev phpstan/phpstan-deprecation-rules to show list of deprecated (rectorphp#6415)
carlos-granados/rector-src@c23ba82 [deprecation] Remove deprecated PublicConstantVisibilityRector, cleanup deprecated SetListInterface (rectorphp#6424)
carlos-granados/rector-src@c2053c7 [deprecation] Deprecate AbstractScopeAwareRector in favor of single AbstractRector (rectorphp#6425)
carlos-granados/rector-src@2c5cd97 [deprecated] Remove deprecated AbstractTestCase (rectorphp#6426)
carlos-granados/rector-src@fb3c33a Merge commit '2c5cd97a3a98ab5af9efb846f6f78738e4a195a6'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants