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

Add types to entity manager #9292

Merged
merged 1 commit into from
Jan 4, 2022
Merged

Conversation

derrabus
Copy link
Member

This PR adds native parameter, return and property types to our entity manager implementations.

@derrabus derrabus added this to the 3.0.0 milestone Dec 27, 2021
use function array_fill;
use function in_array;

class EntityManagerDecoratorTest extends TestCase
Copy link
Member Author

Choose a reason for hiding this comment

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

As soon as we add return types, this test is broken beyond repair because it violates the type contracts almost everywhere. 🙁

@derrabus derrabus force-pushed the types/entity-manager branch 2 times, most recently from da93a8a to a0f7d27 Compare December 27, 2021 20:43
@derrabus derrabus marked this pull request as draft December 27, 2021 20:43
@derrabus
Copy link
Member Author

derrabus commented Dec 27, 2021

Waiting for #9293

@derrabus derrabus force-pushed the types/entity-manager branch from a0f7d27 to e81ce76 Compare January 2, 2022 01:35
@derrabus derrabus marked this pull request as ready for review January 2, 2022 01:36
@derrabus derrabus force-pushed the types/entity-manager branch from e81ce76 to a7a0d04 Compare January 2, 2022 20:06
@SenseException
Copy link
Member

SenseException commented Jan 4, 2022

How did you decide where you wanted to add a type and where not?

For example, why did $className get no type?

    public function getClassMetadata($className): ClassMetadata
    {
        return parent::getClassMetadata($className);
    }

@derrabus
Copy link
Member Author

derrabus commented Jan 4, 2022

How did you decide where you wanted to add a type and where not?

I want to add them everywhere. 🙂

For example, why did $className get no type?

    public function getClassMetadata($className): ClassMetadata
    {
        return parent::getClassMetadata($className);
    }

The interface that is implemented here originates in the persitence repository:

https://github.com/doctrine/persistence/blob/9f226731048d8efbd42e3b0079c6fc353f3a6b96/lib/Doctrine/Persistence/ObjectManager.php#L124-L138

PHP does not allow me to add native parameter types downstream (except for mixed that is). So the type would need to be added to the ObjectManager interface first before we can proceed here. I could declare the parameter as mixed, but I'd rather leave it untyped until the persistence has been patched with types in a stable release. Does that make sense?

Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

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

Yep, I forgot about the dependency to Persistence and a reminder to update it too.

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

Successfully merging this pull request may close these issues.

2 participants