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

willdurand/Hateoas#325 support for php attributes #104

Merged
merged 5 commits into from
Oct 16, 2024

Conversation

ixarlie
Copy link
Contributor

@ixarlie ixarlie commented Jan 10, 2023

Adds a new service hateoas.configuration.metadata.attribute_driver for the AttributeDriver class (willdurand/Hateoas#326)

Moreover, hateoas.configuration.metadata.attribute_driver and hateoas.configuration.metadata.annotation_driver are combined in a new service hateoas.configuration.metadata.annotation_or_attribute_driver to give the extension feature to both services.

The hateoas.configuration.metadata.attribute_driver will be removed if the PHP version is prior 8.1.0, so the hateoas.configuration.metadata.annotation_or_attribute_driver will have only the annotation driver.

This PR will require a new release version of willdurand/Hateoas

@fabianoroberto
Copy link

Is anyone handling this PR?


if (PHP_VERSION_ID >= 80100 && class_exists(AttributeReader::class)) {
$container->register('hateoas.metadata.annotation_and_attributes_reader', AttributeReader::class)
->setArgument(0, new Reference('annotation_reader'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service "annotation_reader" has been removed as of symfony/framework-bundle:^7.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored the way the new AttributeDriver is configured in the bundle along with the annotation driver.

For this issue in particular, I've created a new private service hateoas.configuration.metadata.annotation_reader to provide Doctrine\Common\Annotations\AnnotationReader as a short-term solution.

https://github.com/willdurand/BazingaHateoasBundle/pull/104/files#diff-b542b053bcd2c59c85433c7f6e6f2f2c46aa452e7f15b6f315f668cb428bd400R87

Since willdurand/hateoas requires doctrine/annotations as a root package, it should be safe to create the service "hateoas.configuration.metadata.annotation_reader" definition.

Also, I would say the annotation driver should be marked as deprecated (I saw JMS did it), but I am not sure if you want to do the same.

@loic425
Copy link

loic425 commented Apr 25, 2024

any new about this PR?

@jeandonaldroselin
Copy link

Hello everyone,
Any news about this PR ?

I have developed a catalog of micro services that are using this great bundle and I recently migrated all annotations to php8 attributes except hateoas because it is still not available. If it is necessary I can apply any requested changes to this PR, I have 1-2 month availability to contribute.

What do you think @ixarlie @W0rma ?

@ixarlie
Copy link
Contributor Author

ixarlie commented Jun 24, 2024

Hi @jeandonaldroselin ,

I am still waiting for the final review by the maintainers.

Nonetheless, I appreciate any suggestions that may improve the code.
Same for willdurand/Hateoas#326

Thank you kindly

@goetas
Copy link
Collaborator

goetas commented Oct 14, 2024

I'm really sorry if this took so long. I have merged willdurand/Hateoas#326 and tagged https://github.com/willdurand/Hateoas/releases/tag/3.11.0-beta1

Can someone please rebase this pull request?

update bundle based on hateoas changes
@ixarlie ixarlie force-pushed the issue-325-php8-attributes branch from 4aa8bbe to b86f876 Compare October 14, 2024 22:14
@ixarlie
Copy link
Contributor Author

ixarlie commented Oct 14, 2024

Hi @goetas
Rebase was done. thanks

@goetas
Copy link
Collaborator

goetas commented Oct 15, 2024

So, I see a lot of test failing. if it helps, i'm fine with requiring php ^8.1 and willdurand/Hateoas 3.1@beta. That would simplify the pipelines and allow you to not worry about some edgecases

@ixarlie
Copy link
Contributor Author

ixarlie commented Oct 15, 2024

I will try to fix the tests this evening. I will reach out to you again in case I am unable to fix them.

To be honest, my intention was not to be disruptive with the php version.

@ixarlie
Copy link
Contributor Author

ixarlie commented Oct 16, 2024

Hi @goetas

I believe this would be ready for a new try.

Thanks

@goetas
Copy link
Collaborator

goetas commented Oct 16, 2024

To me looks good. I'm going to merge it and to tag a beta release.

Please ping me here again after some time so I tag a stable release if there will be no problems.

The ci failures are unrelated to your changes

@goetas goetas merged commit 0fe46a9 into willdurand:master Oct 16, 2024
42 of 49 checks passed
@ixarlie ixarlie deleted the issue-325-php8-attributes branch October 16, 2024 21:33
@loic425
Copy link

loic425 commented Oct 17, 2024

Great, I'll try the beta release on sylius resource package. Thx a lot

@W0rma
Copy link
Contributor

W0rma commented Oct 22, 2024

The ci failures are unrelated to your changes

@goetas I don't think that the failures are unrelated.

The tests with PHP 8.0 fail because this PHP version knows about attributes but does not support nested attributes which are used by the test fixtures.
That's why tests with PHP < 8.0 and PHP > 8..0 are green but tests with PHP 8.0 are red.

I encountered a similar issue when working on willdurand/Hateoas#334

The simplest solution to fix that would be to drop support for PHP < 8.1. WDYT?

@goetas
Copy link
Collaborator

goetas commented Oct 31, 2024

@loic425 did you try the beta ?

@loic425
Copy link

loic425 commented Nov 4, 2024

@loic425 did you try the beta ?

The configuration is ok, but the result is different here, any idea?
https://github.com/Sylius/SyliusResourceBundle/actions/runs/11660165241/job/32461971586?pr=960#step:13:87

@W0rma
Copy link
Contributor

W0rma commented Nov 4, 2024

@loic425 Did you also try the latest beta https://github.com/willdurand/Hateoas/releases/tag/3.12.0-beta1 together with #110 ?

Especially willdurand/Hateoas@b3b5da5 is important to make willdurand/hateoas usable without annotations.
This commit is part of the latest beta version.

@goetas
Copy link
Collaborator

goetas commented Nov 4, 2024

@loic425 I see the test failures but is hard for me to understand what is wrong there since I'm not familiar at all with that codebase. I suggest you to try what @W0rma suggested and let us know.

@loic425
Copy link

loic425 commented Nov 4, 2024

@goetas, @W0rma I've fixed everything and I can confirm the beta is ok.

@goetas
Copy link
Collaborator

goetas commented Nov 4, 2024

@loic425 great! thanks for letting me know!

@W0rma are you available anywhere for a chat regarding the recent changes you did? you can contact me via any of the possible ways listed on my profile https://github.com/goetas

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

Successfully merging this pull request may close these issues.

6 participants