1 | <?php |
||
29 | class VariantManager extends AbstractManager |
||
30 | { |
||
31 | public function getAttributesCollectionForProduct(Product $product, array $values): Collection |
||
44 | |||
45 | protected function getVariant($id, $value): Variant |
||
46 | { |
||
47 | /** @var $variant Variant */ |
||
48 | $variant = $this->repository->find($id); |
||
49 | if (null === $variant) { |
||
50 | $variant = $this->initResource(); |
||
51 | } |
||
52 | |||
53 | $variantOptions = $this->makeVariantOptionCollection($variant, $value['attributes']); |
||
|
|||
54 | |||
55 | $variant->setModifierType($value['suffix']); |
||
56 | $variant->setModifierValue($value['modifier']); |
||
57 | $variant->setStock($value['stock']); |
||
58 | $variant->setSymbol($value['symbol']); |
||
59 | $variant->setWeight($value['weight']); |
||
60 | $variant->setHierarchy($value['hierarchy']); |
||
61 | $variant->setPhoto($this->get('media.repository')->find($value['photo'])); |
||
62 | $variant->setOptions($variantOptions); |
||
63 | |||
64 | return $variant; |
||
65 | } |
||
66 | |||
67 | protected function makeVariantOptionCollection(Variant $variant, $values): Collection |
||
79 | |||
80 | protected function getVariantOption(Variant $variant, Attribute $attribute, AttributeValue $attributeValue): VariantOption |
||
93 | |||
94 | protected function findVariantOption(Variant $variant, Attribute $attribute, AttributeValue $attributeValue) |
||
102 | |||
103 | protected function getAttribute(int $id): Attribute |
||
107 | |||
108 | protected function getAttributeValue(int $id): AttributeValue |
||
112 | |||
113 | private function filterValues(array $values): array |
||
119 | } |
||
120 |
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.