Why is this PHP method declaration not recognizing a hint namespace?

I am trying to write a Doctrine Extensions- based library that provides this interface:

namespace Gedmo\Mapping; use Doctrine\Common\Persistence\Mapping\ClassMetadata; interface Driver { public function readExtendedMetadata(ClassMetadata $meta, array &$config); public function setOriginalDriver($driver); } 

In my own code, I implement this interface:

 namespace Avit\Schedulable\Mapping\Driver; use Gedmo\Mapping\Driver, Doctrine\Common\Persistence\Mapping\ClassMetadata, Doctrine\Common\Annotations\AnnotationReader; class Annotation implements Driver { public function readExtendedMetadata(ClassMetadata $meta, array &$config) { // my implementation } } 

The error I get: Avit \ Schedulable \ Mapping \ Driver \ Annotation :: readExtendedMetadata () declaration must be compatible with the name Gedmo \ Mapping \ Driver :: readExtendedMetadata ()

I can avoid the error by removing the ClassMetadata method for my method.

I have information that this error occurs when the namespace is incompatible. This makes sense as I declare this class in my own namespace, however I am imposing the same Doctrine namespace for ClassMetadata that uses the original Driver interface.

Why is the type hint not recognized?

+4
source share
1 answer

The method in Driver here https://github.com/l3pp4rd/DoctrineExtensions/blob/master/lib/Gedmo/Mapping/Driver.php does not seem to have hints like ClassMetadata .

Remember if you check the one you use?

+1
source

Source: https://habr.com/ru/post/1391710/


All Articles