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

Support of PHP8 Attributes #27

Open
juliusstoerrle opened this issue Feb 25, 2022 · 1 comment
Open

Support of PHP8 Attributes #27

juliusstoerrle opened this issue Feb 25, 2022 · 1 comment

Comments

@juliusstoerrle
Copy link

Hey,

I tried to refactor an application to use Doctrine ORM Attributes, however this leads to an error in TsVectorSubscriber.php line 178 as no Column Annotation can be found anymore (its an Attibute now).

Unfortunatly, it requires some workarounds to support attributes and annotations at the same time in the same doctrine mapping space. So it is not nice to need to keep all entities in the same mapping space with "old" annotations. I suggest to first use the Reflection APIs ::getAttributes() in TsVectorSubscriber.php line 178 and if this fails use the Doctrine/AnnotationReader only.

For concistency I suggest to also move the Annotations of this package to support Attributes too (No BC break should be needed). Here is how Doctrine supports both on the same class:

use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;

/**
 * @Annotation
 * @NamedArgumentConstructor()
 * @Target({"PROPERTY","ANNOTATION"})
 */
#[Attribute(Attribute::TARGET_PROPERTY)]
final class Column implements Annotation
{ ...

The Doctrine ORM package achieves continued compatibility with PHP <8.0 by using symfony/polyfill-php80, so I would recommend the same.

I only have too few usages, but one could potentially create a rector rule for the migration as well.
If its wanted I am willing to try and create a PR in the next days.

@tacman
Copy link
Contributor

tacman commented Jun 9, 2022

I just did this for another bundle today, it's pretty easy:

bestit/flagception-bundle#98

Is this bundle still being maintained? The PR I've submitted here hasn't been acknowledged.

The other solution is tagging a new version and requiring PHP 8. PHP7.4 support ends in 5 months.

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

2 participants