Skip to content

[make:entity] add php8 attribute support #920

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

Conversation

SimonMarx
Copy link

Hey everyone,

i saw the open issue #892 and i had the same problem.
Since my application is running on php8 and i do not want to create all my entities manually, i've added attribute support for the make:entity command.
The Annotation support is still available and (i think) untouched.

Things I was / am unsure about:

  • Before i made changes, the process checked if the class is annotated. I was unsure if i should add a new check isAttributed, or decide which kind of manipulation strategy the ClassSourceManipulator should use (annotation or attribute) depending on the given MappingDriver. As you can see in the code, i selected option number 2.
  • The method DoctrineHelper::isClassAnnotated is theoretically not needed anymore. But removing public methods is forbidden, do i have to flag/annotate them somehow in the doc blocks?
  • Commands like make:user does not support Attributes now, should that logic be implemented in this Pull Request?

To be honest, this is my first public pull request and im a bit nervous 😰 . I tried to follow all rules from the contributing guidelines, but maybe i missed some rules, so I am grateful for any feedback, tips, dos and don'ts.

Thanks in advance for your feedbacks and here is a screenshot of an generated entity with attributes 😃

image

@davelima
Copy link

Working fine to me! There is something i can do to help getting it merged? 🙌

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

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

lgtm

@jrushlow
Copy link
Collaborator

jrushlow commented Aug 5, 2021

@SimonMarx can you rebase this against the main branch so we can see what the tests look like? thanks in advance!

@jrushlow jrushlow added the Status: Waiting Feedback Needs feedback from the author label Aug 5, 2021
@jrushlow jrushlow linked an issue Aug 5, 2021 that may be closed by this pull request
@adlpz
Copy link
Contributor

adlpz commented Aug 12, 2021

This change contains a bug in the Mapping Driver resolution that will return the wrong driver when multiple drivers are in place. I've submitted a pull request to @SimonMarx 's branch here: SimonMarx#2

I'd suggest getting that one through before rebasing and merging this one.

@jrushlow jrushlow added Status: Needs Review Needs to be reviewed and removed Status: Waiting Feedback Needs feedback from the author labels Sep 21, 2021
Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

Wow, tests are green and this is close! I've left some comments for things we should fix before merge - I think @jrushlow is going to keep pushing this across the finish line, but @SimonMarx you've been wonderful on this PR, so if you have some time, just coordinate with jrushlow so you don't both do the work. And thanks again!

true,
!$useAttributesForDoctrineMapping,
true,
$useAttributesForDoctrineMapping
Copy link
Member

Choose a reason for hiding this comment

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

This constructor is complex, in large part because that nasty, confusing 3rd argument (which is my fault).

Anyways, I've seen this twice so far and it gave me an idea: add a DoctrineHelper::createClassSourceManipulator(string $className) method that handles all of this ugliness for us.

@weaverryan
Copy link
Member

weaverryan commented Sep 24, 2021

@SimonMarx I noticed there are 2 of other committers on this PR (besides @jrushlow and I). Can you explain who they are?

Were you collaborating with these users?

I figured it out 😄

@weaverryan
Copy link
Member

weaverryan commented Sep 24, 2021

@SimonMarx - Also, see #978 for a cleaned up version of this PR, I need your "ok" on that PR (as well as determining where the other contributors came from).

Thanks!

weaverryan added a commit that referenced this pull request Sep 27, 2021
This PR was merged into the 1.0-dev branch.

Discussion
----------

Adding Entity attribute support

Hi!

This is #920 cleaned up.

Somehow, in that PR, the commits got tanged. For example, some commits were done twice, like SimonMarx@d12c2f9 and SimonMarx@3848f4f - but the bigger problem is that some commits (like the 2nd listed) have one date on GitHub (e.g. Aug 12th) but another date when pulled down locally (July 4th). Whatever is causing this seems to also cause, during a rebase, for these commits to be rebased on reverse. In short, it was an odd mess.

To fix this, I've created a single commit with co-authors. I need to verify that this is ok with `@SimonMarx` and determine where these other two contributors came from :) (see #920 (comment))

Cheers!

```
Co-authored-by: Simon Marx <[email protected]>
Co-authored-by: Morgan ABRAHAM <[email protected]>
Co-authored-by: Adria Lopez <[email protected]>
Co-authored-by: Jesse Rushlow <[email protected]>
```

Commits
-------

9ecc684 Adding Entity attribute support
@weaverryan weaverryan closed this Sep 27, 2021
@jrushlow jrushlow added the Feature New Feature label May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for PHP 8 Attributes to make:entity