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

Migrate to attributes #10113

Merged
merged 6 commits into from
Oct 26, 2022
Merged

Migrate to attributes #10113

merged 6 commits into from
Oct 26, 2022

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Oct 8, 2022

No description provided.

@greg0ire greg0ire marked this pull request as ready for review October 8, 2022 12:59
@greg0ire greg0ire marked this pull request as draft October 8, 2022 12:59
@greg0ire greg0ire force-pushed the migrate-to-attributes branch 3 times, most recently from e970087 to 01d0736 Compare October 9, 2022 20:30
docs/en/reference/advanced-configuration.rst Outdated Show resolved Hide resolved
Comment on lines 40 to 41
#[Column(unique: true)] protected string $name,
#[Cache] #[ManyToOne(targetEntity: 'City', inversedBy: 'attractions')] #[JoinColumn(name: 'city_id', referencedColumnName: 'id')] protected City $city,
Copy link
Member

Choose a reason for hiding this comment

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

My attempt at making this more readable. Are there already PHPCS rules for that?

Suggested change
#[Column(unique: true)] protected string $name,
#[Cache] #[ManyToOne(targetEntity: 'City', inversedBy: 'attractions')] #[JoinColumn(name: 'city_id', referencedColumnName: 'id')] protected City $city,
#[Column(unique: true)]
protected string $name,
#[Cache]
#[ManyToOne(targetEntity: 'City', inversedBy: 'attractions')]
#[JoinColumn(name: 'city_id', referencedColumnName: 'id')]
protected City $city,

Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh yeah indeed the output of Rector is not very easy on the eye here 😓 I'll try to see what phpcs rules currently exist if any.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did some digging and didnt find anything. Opened a feature request here - slevomat/coding-standard#1442 . Will see if we can find some resources in our company to work on this if it turns out that this is not available in some other standard already. No promises tho ;]

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome! Thanks!

Copy link
Contributor

@michnovka michnovka Oct 18, 2022

Choose a reason for hiding this comment

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

@greg0ire @derrabus https://github.com/slevomat/coding-standard/releases/tag/8.6.0 have a look

    <rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
    <rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>
    <rule ref="SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing"/>

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

For now, let's stick with the ugly version, and then when we use doctrine/coding-standard 11, it will be pretty again?

greg0ire added a commit to greg0ire/rector-src that referenced this pull request Oct 15, 2022
Found while working on doctrine/orm#10113
The fix should eliminate the need for doctrine/orm@37e34e9
greg0ire added a commit to greg0ire/rector-src that referenced this pull request Oct 15, 2022
Found while working on doctrine/orm#10113
The fix should eliminate the need for doctrine/orm@37e34e9
TomasVotruba pushed a commit to rectorphp/rector-src that referenced this pull request Oct 15, 2022
Found while working on doctrine/orm#10113
The fix should eliminate the need for doctrine/orm@37e34e9
I used the following config:

<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Doctrine\Set\DoctrineSetList;

return function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__ . '/tests',
    ]);
    $rectorConfig->sets([
        DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
    ]);
};
The tests does not behave as expected without it.
@greg0ire greg0ire marked this pull request as ready for review October 25, 2022 21:41
Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

I did not look into each and every file, there's way too many of them. The files I've picked looked good. Since this affects mainly tests, I think the PR is good to merge.

TODO for a follow-up:

  • Adjust UPGRADE.md because you've removed the annotation driver.
  • Purge annotations from the docs.

@greg0ire greg0ire merged commit 189883e into doctrine:3.0.x Oct 26, 2022
@greg0ire greg0ire deleted the migrate-to-attributes branch October 26, 2022 05:30
@greg0ire
Copy link
Member Author

Will do, thanks!

@greg0ire greg0ire added this to the 3.0.0 milestone Oct 26, 2022
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.

4 participants