Return value of Prezent\Doctrine\Translatable\Mapping\Driver\AnnotationDriver::loadMetadataForClass() must be an instance of Metadata\ClassMetadata or null, none returned
My research has led me to this specific change in AnnotationDriver.php on line 47 of PR #33:
+ public function loadMetadataForClass(\ReflectionClass $class): ?ClassMetadata
Since the method now has a nullable, but typed return value, it cannot omit the return statement any more, despite the following statement:
If the return is omitted the value NULL will be returned.
Now if none of the two conditions in the aforementioned method is true, the function will terminate without returning the required value of null or ClassMetadata.
I suggest adding return null; at the end of the method.
I can submit a pull request if desired.
Dear Prezent Team,
I just stumbled across a bug after upgrading the prezent/doctrine-translatable-bundle to v1.0.7, which updated this bundle to v2.0.0.
Error message:
My research has led me to this specific change in
AnnotationDriver.php
on line 47 of PR #33:+ public function loadMetadataForClass(\ReflectionClass $class): ?ClassMetadata
Since the method now has a nullable, but typed return value, it cannot omit the return statement any more, despite the following statement:
The 'Nullable Types' segment in ''PHP 7.1 New Features' has the following comment:
Now if none of the two conditions in the aforementioned method is true, the function will terminate without returning the required value of
null
orClassMetadata
.I suggest adding
return null;
at the end of the method. I can submit a pull request if desired.