mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Migrate to PHP 8.1 #6979
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @greg0ire on GitHub (May 21, 2022).
This is something that I think should go in milestone 3.0.0
A big difference between branches 2 and 3 is the
phprequirement:Now that support for PHP 7 has been dropped, we can use features that are specific to PHP 8.
@derrabus has already done a lot about that. When this is over, we should be able to get rid of lines mentioning native type declarations in
phpcs.xml.dist. It can also be used to figure out what is left to do.We should rely on constructor property promotion when possible.
phpdoc that is found to be wrong on the way should be fixed on the next patch branch.
phpdoc that is found to be imprecise on the way should be improved on the next minor branch.
Here is an example for
AbstractQueryand related classes:@greg0ire commented on GitHub (Jun 2, 2022):
In fact, we can generalize that issue to any PHP-8.0-specific feature. I've tried using Rector with the following config that I stole from Sonata:
Make sure to install a version of Rector that is compatible with that:
composer require --dev rector/rector 0.14.8The result breaks the test suite (there is a Fatal error at compilation time), and after fixing, one will see many errors caused by wrong phpdoc transformed in wrong type declarations.
I think the best strategy to tackle this issue is to proceed in reasonably small PRs, targeting a small number of classes every time. I can post a message to this thread every time progress is made.
The workflow can be the following:
composer require rector/rector --dev); Rector has a dependency on PHPStan, so it will often requiring a specific PHPStan version@greg0ire commented on GitHub (Jun 2, 2022):
I have also created https://github.com/doctrine/orm/projects/6 to track progress and show examples
@greg0ire commented on GitHub (Jun 3, 2022):
Progress after #9776 🐌
@greg0ire commented on GitHub (Jun 15, 2022):
Progress after #9828 and #9835
But that's without
that I think we might use as well.
Updated config file:
Let's use it in the next PRs and see if it does what we think it does.
@greg0ire commented on GitHub (Jul 15, 2022):
updated list with the extra rules
@greg0ire commented on GitHub (Jul 28, 2022):
updated list after #9551
@greg0ire commented on GitHub (Aug 3, 2022):
Since #9925 we can use
UP_TO_PHP_81@greg0ire commented on GitHub (Oct 20, 2022):
updated list after the 5 PRs above (spoiler, there's nice progress)
@greg0ire commented on GitHub (Nov 9, 2022):
Close to 100 files
@greg0ire commented on GitHub (Nov 9, 2022):
Note: without `importNames()`, the result is exactly 100 files, and there are about half as many changes
@derrabus what's your opinion on this? That rule removes things such as
Expr\AndX()… I think we should either apply it on 2.14.x to avoid the 2 branches diverging too much, or turn it off when running Rector and fixing imports manually.I don't fully remember why I needed it it, so until I do, I should probably turn it off.Here is what happens when I turn it off:EDIT: in case you're wondering, running
vendor/bin/phpcbfon the code above produces this:The use statement goes away.
phpcsshows this:Maybe I should report a bug? Or maybe it's not fixable?
@derrabus commented on GitHub (Nov 9, 2022):
Shouldn't this be cleaned up by PHPCBF?
@greg0ire commented on GitHub (Nov 9, 2022):
PHPCBF wrongly removes the use statement (maybe because it wants to fix the first error).
@greg0ire commented on GitHub (Nov 10, 2022):
Reported at https://github.com/slevomat/coding-standard/issues/1466
@greg0ire commented on GitHub (Nov 10, 2022):
I wished I reported this earlier, @kukulich fixed it like was nothing! Let's definitely remove that
importName().@greg0ire commented on GitHub (Jan 3, 2023):
down to 65 files 💪
@greg0ire commented on GitHub (Jan 8, 2023):
Updated the above config file to disable
FinalizePublicClassConstantRector. We can treat that one separately if we want to.As a result of that and recent PRs,
we're down to 31 files if we include #10378
@greg0ire commented on GitHub (Feb 8, 2023):
All done! 🎉