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

Changes necessary for compatibility with ORM 3 #373

Closed
wants to merge 1 commit into from

Conversation

greg0ire
Copy link
Member

No description provided.

@@ -35,7 +35,7 @@ public function getIdentifier(): array;
*
* @return ReflectionClass<T>
*/
public function getReflectionClass(): ReflectionClass;
public function getReflectionClass();
Copy link
Member Author

Choose a reason for hiding this comment

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

In ORM 3, the return type is ReflectionClass|null

@@ -71,7 +71,7 @@ public function getGlobalBasename(): string
*
* @throws MappingException
*/
public function getElement(string $className): ClassMetadata
public function getElement(string $className)
Copy link
Member Author

Choose a reason for hiding this comment

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

When running the ORM 3 test suite, line 95 causes lots of issues:

Doctrine\Persistence\Mapping\Driver\FileDriver::getElement(): Return value must be of type Doctrine\Persistence\Mapping\ClassMetadata, SimpleXMLElement returned

Copy link
Member

Choose a reason for hiding this comment

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

to me, this looks like invalid tests

Copy link
Member

Choose a reason for hiding this comment

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

hmm, actually, it might be that the new types don't match the actual usages. The XmlDriver of the orm returns array<string, SimpleXMLElement> in loadMappingFile, which is why getElement also returns a SimpleXMLElement.

My guess is that the types added for this method are totally wrong, as it looks like each FileDriver child class is free to choose the format of the data they want to cache per class anyway (as the implementation of the public API loadMetadataForClass is left to the child classes).
And this method should probably have been defined as protected instead.

@@ -139,7 +139,7 @@ public function getAllClassNames(): array
* @return ClassMetadata[]
* @psalm-return array<class-string, ClassMetadata<object>>
*/
abstract protected function loadMappingFile(string $file): array;
abstract protected function loadMappingFile(string $file);
Copy link
Member Author

Choose a reason for hiding this comment

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

The type declaration was simply not updated in ORM 3

src/Persistence/Proxy.php Show resolved Hide resolved
@@ -139,7 +139,7 @@ public function getAllClassNames(): array
* @return ClassMetadata[]
* @psalm-return array<class-string, ClassMetadata<object>>
*/
abstract protected function loadMappingFile(string $file): array;
abstract protected function loadMappingFile(string $file);
Copy link
Member

Choose a reason for hiding this comment

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

does the ORM need to return something else than an array here ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's just that the return type declaration was not added in ORM 3 (it was forgotten)

@greg0ire greg0ire marked this pull request as draft June 20, 2024 12:26
@greg0ire greg0ire closed this Jun 27, 2024
@greg0ire
Copy link
Member Author

Closing now that compatibility seems doable: doctrine/orm#11533

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.

2 participants