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

Implement colocated mapping driver #9587

Merged
merged 1 commit into from
Mar 16, 2022

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Mar 14, 2022

This allows us to decouple further from doctrine/annotations, and to fix
some static analysis issues.

The assumption being made here is that the abstract class we are no
longer extending is not used in type declarations and instanceof checks.

* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
* docblock annotations.
*
* @param Reader $reader The AnnotationReader to use, duck-typed.
Copy link
Member

Choose a reason for hiding this comment

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

We should move away from the duck-typed part, imho. It has caused us trouble already.

*
* @var Reader
*/
protected $reader;
Copy link
Member

Choose a reason for hiding this comment

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

Shall we flag the property as @internal and make it private on 3.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't we deprecate AnnotationDriver and remove it entirely in 3.0?
Also, I'm wondering why AttributeDriver has a getReader() method, and is not final 🤔

@derrabus derrabus added this to the 2.12.0 milestone Mar 15, 2022
@@ -25,8 +26,10 @@

use const PHP_VERSION_ID;

class AttributeDriver extends AnnotationDriver
class AttributeDriver implements MappingDriver
Copy link
Member Author

@greg0ire greg0ire Mar 15, 2022

Choose a reason for hiding this comment

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

Ah, I should implement getReader as well, removing that method is a BC-break I guess 😅 … but since it's not breaking any tests, I think I should instantly deprecate it.

This allows us to decouple further from doctrine/annotations, and to fix
some static analysis issues.

The assumption being made here is that the abstract class we are no
longer extending is not used in type declarations and instanceof checks.
@greg0ire greg0ire merged commit 4471ad9 into doctrine:2.12.x Mar 16, 2022
@greg0ire greg0ire deleted the implement-colocated-driver branch March 16, 2022 09:54
* Initializes a new AnnotationDriver that uses the given AnnotationReader for reading
* docblock annotations.
*
* @param Reader $reader The AnnotationReader to use
Copy link
Member

Choose a reason for hiding this comment

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

why not using an actual parameter type ?

Copy link
Member

Choose a reason for hiding this comment

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

That would be a BC break. The old constructor explicitly mentioned the possibility of duck-typed annotation readers.

@@ -29,8 +32,19 @@
/**
* The AnnotationDriver reads the mapping metadata from docblock annotations.
*/
class AnnotationDriver extends AbstractAnnotationDriver
class AnnotationDriver implements MappingDriver
Copy link
Member

Choose a reason for hiding this comment

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

This BC break needs to be reverted, and moved to the next major.

Ref: #9668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants