Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Nov 25, 2025

Q A
Type improvement
BC Break no (deprecation)
Fixed issues Related #2931

Summary

  • Move the classes from Doctrine\ODM\MongoDB\Mapping\Annotations to Doctrine\ODM\MongoDB\Mapping\Attribute
  • Add a deprecated alias for old names. The deprecation warning is triggered only when the class in Annotations namespace is loaded using the autoloader.

@GromNaN GromNaN added this to the 2.16.0 milestone Nov 25, 2025
@GromNaN
Copy link
Member Author

GromNaN commented Nov 25, 2025

This will force users to migrate without offering anything in return, except for consistency in the namespace with other projects (and not yet ORM). We can only do this if ORM also decides to do so.

@GromNaN
Copy link
Member Author

GromNaN commented Nov 25, 2025

In fact, ORM don't have this subnamespace (example: Doctrine\ORM\Mapping\Entity). So, we should consider whether we want to keep the namespace or move all the attribute classes to Doctrine\ODM\MongoDB\Mapping.
@alcaeus you had the idea that we should use the attribute classes as model classes for all the class metadata. In that case, that would make sense to remove the subnamespace Attribute.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the MongoDB ODM library's attribute system by moving attribute classes from the Annotations namespace to the new Attribute namespace. The old Annotations namespace is maintained as a deprecated alias to ensure backward compatibility while guiding users toward the new naming convention.

Key Changes:

  • Introduced new Doctrine\ODM\MongoDB\Mapping\Attribute namespace for all attribute classes
  • Added deprecation triggers when old Annotations namespace classes are loaded
  • Updated all test files and internal references to use the new namespace
  • Maintained backward compatibility through class aliases

Reviewed changes

Copilot reviewed 300 out of 434 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/Mapping/Attribute/*.php New attribute classes in the Attribute namespace with class aliases to Annotations namespace for backward compatibility
src/Mapping/Annotations/*.php Converted to deprecation stubs that trigger warnings and load the new Attribute classes
tests/**/*.php Updated import statements from Annotations to Attribute namespace
src/Mapping/Driver/*.php Updated internal references to use new Attribute namespace
src/Mapping/ClassMetadata.php Updated type hints to reference Attribute namespace
UPGRADE-2.16.md Added migration guide for the namespace change
phpstan-baseline.neon Updated static analysis baseline with new namespace references

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GromNaN GromNaN force-pushed the attribute-namespace branch from 71eff05 to 5e39484 Compare November 30, 2025 17:01
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.

1 participant