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

Rename internal methods #10204

Merged
merged 5 commits into from Nov 6, 2022
Merged

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Nov 5, 2022

No description provided.

/** @var array<string,int> */
// @phpcs:ignore
/** @var array<class-string<MappingAttribute>, int> */
protected $entityAttributeClasses = [
Copy link
Member Author

Choose a reason for hiding this comment

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

Let me know if you think this should be a private property, I don't know why $entityAnnotationClasses is exposed or why the class isn't final.

Copy link
Member

Choose a reason for hiding this comment

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

Probably from the dark ages of PHP.

Copy link
Member

Choose a reason for hiding this comment

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

$entityAnnotationClasses is an extension point of the AnnotationDriver from Persistence 2. However, we already override all functionality that uses the property.

Theoretically, you could invent your own attributes and extend AttributeDriver to make use of them. Either way, a protected property is a bad extension point. The property is used in the isTransient() method only.

My suggestion: Move the array into a private constant, deprecate the property and tell people to override isTransient() instead of overriding or changing the property. For the time being, our implementation of isTransient() has to use the property, but we can switch it to the new constant on 3.0.x.

SenseException
SenseException previously approved these changes Nov 5, 2022
/** @var array<string,int> */
// @phpcs:ignore
/** @var array<class-string<MappingAttribute>, int> */
protected $entityAttributeClasses = [
Copy link
Member

Choose a reason for hiding this comment

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

Probably from the dark ages of PHP.

@SenseException
Copy link
Member

I'm not sure though if this does break something when someone extended it.

/** @var array<string,int> */
// @phpcs:ignore
/** @var array<class-string<MappingAttribute>, int> */
protected $entityAttributeClasses = [
Copy link
Member

Choose a reason for hiding this comment

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

$entityAnnotationClasses is an extension point of the AnnotationDriver from Persistence 2. However, we already override all functionality that uses the property.

Theoretically, you could invent your own attributes and extend AttributeDriver to make use of them. Either way, a protected property is a bad extension point. The property is used in the isTransient() method only.

My suggestion: Move the array into a private constant, deprecate the property and tell people to override isTransient() instead of overriding or changing the property. For the time being, our implementation of isTransient() has to use the property, but we can switch it to the new constant on 3.0.x.

derrabus
derrabus previously approved these changes Nov 6, 2022
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.

Minor nit-picking, feel free to merge after my comments have been addressed.

lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php Outdated Show resolved Hide resolved
@greg0ire greg0ire merged commit 8d9ab72 into doctrine:2.14.x Nov 6, 2022
@greg0ire greg0ire deleted the rename-internal-methods branch November 6, 2022 20:26
@derrabus derrabus added this to the 2.14.0 milestone Nov 21, 2022
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.

None yet

3 participants