1 | <?php |
||
16 | class FieldDescription extends BaseFieldDescription |
||
17 | { |
||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | public function __construct() |
||
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | public function setAssociationMapping($associationMapping) |
||
30 | { |
||
31 | if (!is_array($associationMapping)) { |
||
32 | throw new \RuntimeException('The association mapping must be an array'); |
||
33 | } |
||
34 | |||
35 | $this->associationMapping = $associationMapping; |
||
36 | |||
37 | $this->type = $this->type ? : $associationMapping['type']; |
||
38 | $this->mappingType = $this->mappingType ? : $associationMapping['type']; |
||
39 | $this->fieldName = $associationMapping['fieldName']; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function getTargetEntity() |
||
46 | { |
||
47 | if ($this->associationMapping) { |
||
|
|||
48 | return $this->associationMapping['targetEntity']; |
||
49 | } |
||
50 | |||
51 | return null; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function setFieldMapping($fieldMapping) |
||
58 | { |
||
59 | if (!is_array($fieldMapping)) { |
||
60 | throw new \RuntimeException('The field mapping must be an array'); |
||
61 | } |
||
62 | |||
63 | $this->fieldMapping = $fieldMapping; |
||
64 | |||
65 | $this->type = $this->type ? : $fieldMapping['type']; |
||
66 | $this->mappingType = $this->mappingType ? : $fieldMapping['type']; |
||
67 | $this->fieldName = $this->fieldName ? : $fieldMapping['fieldName']; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function setParentAssociationMappings(array $parentAssociationMappings) |
||
74 | { |
||
75 | foreach ($parentAssociationMappings as $parentAssociationMapping) { |
||
76 | if (!is_array($parentAssociationMapping)) { |
||
77 | throw new \RuntimeException('An association mapping must be an array'); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | $this->parentAssociationMappings = $parentAssociationMappings; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function isIdentifier() |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | public function getValue($object) |
||
103 | } |
||
104 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.