This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
11
{
12
const MACRO_METHOD = 'locale';
13
14
/**
15
* @var ExtensibleClassMetadata
16
*/
17
private $classMetadata;
18
19
/**
20
* @var string
21
*/
22
private $fieldName;
23
24
/**
25
* Locale constructor.
26
* @param ExtensibleClassMetadata $classMetadata
27
* @param string $fieldName
28
*/
29
2
public function __construct(ExtensibleClassMetadata $classMetadata, $fieldName)
30
{
31
2
$this->classMetadata = $classMetadata;
32
2
$this->fieldName = $fieldName;
33
2
}
34
35
/**
36
* @return void
37
*/
38
public static function enable()
39
{
40
2
Field::macro(self::MACRO_METHOD, function (Field $field) {
41
1
return new static($field->getClassMetadata(), $field->getName());
$field->getClassMetadata() of type object<Doctrine\ORM\Mapping\ClassMetadataInfo> is not a sub-type of object<LaravelDoctrine\F...xtensibleClassMetadata>. It seems like you assume a child class of the class Doctrine\ORM\Mapping\ClassMetadataInfo to be always present.
This check looks for parameters that are defined as one type in their type
hint or doc comment but seem to be used as a narrower type, i.e an
implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming
your parameter is of the expected type.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.