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

Allow Doctrine Annotations 2 #1596

Closed
wants to merge 1 commit into from

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Dec 20, 2022

The bundle itself should be compatible with Annotations 2 right away.

However, I wonder if the Annotations package should remain a mandatory dependency. If we use the bundle to configure the DBAL without the ORM, requiring Annotations feels pointless. Moreover, in a PHP 8 project with native attributes, we don't necessarily need Annotations for the ORM either.

@derrabus
Copy link
Member Author

Regarding the Psalm failure: psalm/psalm-plugin-symfony#296

@derrabus
Copy link
Member Author

The stable deps jobs will remain red until Symfony makes another round of bugfix releases, see symfony/symfony#48718

@greg0ire
Copy link
Member

greg0ire commented Dec 20, 2022

However, I wonder if the Annotations package should remain a mandatory dependency. If we use the bundle to configure the DBAL without the ORM, requiring Annotations feels pointless. Moreover, in a PHP 8 projects with native attributes, we don't necessarily need Annotations for the ORM either.

Looks like the dependency was added one year ago as a quick fix for the CI: d7afbac

I don't think it was reconsidered.

It seems to be only used here:

public static function createAnnotationMappingDriver(array $namespaces, array $directories, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [])
{
$reader = new Reference('annotation_reader');
$driver = new Definition(AnnotationDriver::class, [$reader, $directories]);
return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter, $aliasMap);
}

I have no idea what uses that method though; looked in Symfony, couldn't find a reference.

@mbabker
Copy link
Contributor

mbabker commented Dec 21, 2022

Looks like the dependency was added one year ago as a quick fix for the CI: d7afbac

I don't think it was reconsidered.

The quickest fix I could come up with in a PR to another bundle yesterday was to run composer require --no-update "doctrine/annotations:<constraint>" before installing all the dependencies. The FrameworkBundle uses ContainerBuilder::willBeAvailable() to decide if annotations support is enabled or disabled by default, so unless something has the package as a direct production dependency, it ends up not enabling annotations.

I have no idea what uses that method though; looked in Symfony, couldn't find a reference.

It's for apps/bundles that don't register their mapping files in an auto-mapped folder, you're not going to find too many uses of it TBH.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 21, 2022

I would also vote for removing the dep (or move it to req-dev if needed for tests)

@stof
Copy link
Member

stof commented Dec 21, 2022

I agree with @nicolas-grekas

@ostrolucky
Copy link
Member

I agree in principle, but if we simply remove it and install it in CI build, we wouldn't test for a case when it's not installed

@mbabker
Copy link
Contributor

mbabker commented Dec 21, 2022

2.8.x...mbabker:DoctrineBundle:28.x is pretty ugly but it gets the test suite to run when the annotations package isn't installed (all of the skips are needed because the test fixtures use an annotation based bundle).

@Tobion
Copy link
Contributor

Tobion commented Dec 21, 2022

Agree that the dependency on annotations should be removed.

@mbabker
Copy link
Contributor

mbabker commented Dec 21, 2022

See #1598 for a full PR

@derrabus
Copy link
Member Author

All right, let's continue there. Thanks for taking over.

@derrabus derrabus closed this Dec 22, 2022
@derrabus derrabus deleted the bump/annotations branch December 22, 2022 08:22
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.

None yet

7 participants