diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 8661ed3065f..81a5a038859 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -94,7 +94,7 @@ 'no_alias_functions' => true, 'no_useless_else' => true, 'no_useless_return' => true, - 'no_superfluous_phpdoc_tags' => true, + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], 'nullable_type_declaration_for_default_null_value' => true, 'operator_linebreak' => ['only_booleans' => true], 'ordered_class_elements' => true, diff --git a/.phpstan-baseline.neon b/.phpstan-baseline.neon index b9d2502619c..6b86ca24431 100644 --- a/.phpstan-baseline.neon +++ b/.phpstan-baseline.neon @@ -4525,11 +4525,6 @@ parameters: count: 1 path: engine/Shopware/Bundle/ContentTypeBundle/DependencyInjection/TypeReader.php - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\DependencyInjection\\\\TypeReader\\:\\:getConfigPaths\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/DependencyInjection/TypeReader.php - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\DependencyInjection\\\\TypeReader\\:\\:getTypes\\(\\) has parameter \\$activePlugins with no value type specified in iterable type array\\.$#" count: 1 @@ -4915,91 +4910,6 @@ parameters: count: 1 path: engine/Shopware/Bundle/ContentTypeBundle/Services/TypeProvider.php - - - message: "#^Argument of an invalid type DOMNamedNodeMap\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Cannot access property \\$nodeType on DOMNode\\|null\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Cannot access property \\$nodeValue on DOMNode\\|null\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:cleanArray\\(\\) has parameter \\$haystack with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:cleanArray\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseComboboStoreList\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseCustom\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseField\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseFieldset\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseItem\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseList\\(\\) has parameter \\$list with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:parseList\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:readType\\(\\) has parameter \\$xmlFile with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:readType\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:xmlToArray\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - - - message: "#^Parameter \\#1 \\$root of static method Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\XmlReader\\\\ContentTypesReader\\:\\:xmlToArray\\(\\) expects DOMNode, DOMElement\\|null given\\.$#" - count: 1 - path: engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php - - message: "#^Property Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Structs\\\\Criteria\\:\\:\\$filter type has no value type specified in iterable type array\\.$#" count: 1 @@ -18340,21 +18250,6 @@ parameters: count: 1 path: engine/Shopware/Components/Plugin/PaymentInstaller.php - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\RequirementValidator\\:\\:assertRequiredPlugins\\(\\) has parameter \\$requiredPlugins with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/RequirementValidator.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\RequirementValidator\\:\\:assertShopwareVersion\\(\\) has parameter \\$compatibility with no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/RequirementValidator.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\RequirementValidator\\:\\:validate\\(\\) has no return type specified\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/RequirementValidator.php - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\ResourceSubscriber\\:\\:onCollectCss\\(\\) return type with generic class Doctrine\\\\Common\\\\Collections\\\\ArrayCollection does not specify its types\\: TKey, T$#" count: 1 @@ -18390,156 +18285,6 @@ parameters: count: 1 path: engine/Shopware/Components/Plugin/XmlPluginInfoReader.php - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreExtjsValueParser\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreExtjsValueParser.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreValueParserInterface\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreValueParserInterface.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParser\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParser.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlConfigReader\\:\\:parseElementNodeList\\(\\) has parameter \\$list with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlConfigReader\\:\\:parseElementNodeList\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlConfigReader\\:\\:parseFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlCronjobReader\\:\\:parseFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlCronjobReader\\:\\:parseItem\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlCronjobReader\\:\\:parseList\\(\\) has parameter \\$list with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlCronjobReader\\:\\:parseList\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlMenuReader\\:\\:parseEntry\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlMenuReader\\:\\:parseFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php - - - - message: "#^Parameter \\#1 \\$node of static method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:getChildren\\(\\) expects DOMNode, DOMElement\\|null given\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php - - - - message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#" - count: 2 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Call to an undefined method DOMNode\\:\\:getElementsByTagName\\(\\)\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Cannot assign offset non\\-falsy\\-string to array\\\\>\\|string\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Cannot assign offset string to array\\\\>\\|string\\>\\|string\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlPluginReader\\:\\:parseBlacklist\\(\\) has parameter \\$items with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlPluginReader\\:\\:parseBlacklist\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlPluginReader\\:\\:parseFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlPluginReader\\:\\:parseRequiredPlugins\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php - - - - message: "#^Cannot access property \\$childNodes on DOMNode\\|null\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:parseFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:parseOptionsNodeList\\(\\) has parameter \\$optionsList with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:parseOptionsNodeList\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:parseStoreNodeList\\(\\) has parameter \\$list with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:parseStoreNodeList\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:parseTranslatableNodeList\\(\\) has parameter \\$list with generic class DOMNodeList but does not specify its types\\: TNode$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderBase\\:\\:read\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php - - - - message: "#^Method Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlReaderInterface\\:\\:read\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: engine/Shopware/Components/Plugin/XmlReader/XmlReaderInterface.php - - message: "#^Method Shopware\\\\Components\\\\Privacy\\\\CookieRemoveSubscriber\\:\\:convertToArray\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -41140,56 +40885,6 @@ parameters: count: 1 path: tests/Unit/Components/Plugin/RequirementValidatorTest.php - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreExtjsValueParserTest\\:\\:getStoreElement\\(\\) should return DOMElement but returns DOMNode\\|null\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreExtjsValueParserTest.php - - - - message: "#^Property Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreExtjsValueParserTest\\:\\:\\$parser \\(Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParser\\) does not accept Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreValueParserInterface\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreExtjsValueParserTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParserTest\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParserTest\\:\\:__construct\\(\\) has parameter \\$name with no type specified\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParserTest\\:\\:getStoreElement\\(\\) should return DOMElement but returns DOMNode\\|null\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php - - - - message: "#^Property Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParserTest\\:\\:\\$parser \\(Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreXmlValueParser\\) does not accept Shopware\\\\Components\\\\Plugin\\\\XmlReader\\\\StoreValueParser\\\\StoreValueParserInterface\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlConfigReaderTest\\:\\:readFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/XmlConfigReaderTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlCronjobReaderTest\\:\\:readFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/XmlCronjobReaderTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlMenuReaderTest\\:\\:readFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/XmlMenuReaderTest.php - - - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\Plugin\\\\XmlReader\\\\XmlPluginReaderTest\\:\\:readFile\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Unit/Components/Plugin/XmlReader/XmlPluginReaderTest.php - - message: "#^Method Shopware\\\\Tests\\\\Unit\\\\Components\\\\QueryAliasMapperTest\\:\\:testAliasesCanBeRetrieved\\(\\) has no return type specified\\.$#" count: 1 diff --git a/engine/Shopware/Bundle/ContentTypeBundle/DependencyInjection/TypeReader.php b/engine/Shopware/Bundle/ContentTypeBundle/DependencyInjection/TypeReader.php index 2ca77f2fe2d..21579915ae9 100644 --- a/engine/Shopware/Bundle/ContentTypeBundle/DependencyInjection/TypeReader.php +++ b/engine/Shopware/Bundle/ContentTypeBundle/DependencyInjection/TypeReader.php @@ -47,6 +47,9 @@ public function getTypes(array $activePlugins, array $pluginDirectories, array $ return $result; } + /** + * @return list + */ private function getConfigPaths(array $activePlugins, array $pluginDirectories): array { $configs = []; diff --git a/engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php b/engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php index 569be48b6a0..a2ed2c8e786 100644 --- a/engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php +++ b/engine/Shopware/Bundle/ContentTypeBundle/Services/XmlReader/ContentTypesReader.php @@ -39,6 +39,11 @@ class ContentTypesReader extends XmlReaderBase */ protected $xsdFile = __DIR__ . '/../../Resources/contenttypes.xsd'; + /** + * @param array{file: string, type: string} $xmlFile + * + * @return array> + */ public function readType(array $xmlFile): array { $data = $this->read($xmlFile['file']); @@ -53,6 +58,7 @@ public function readType(array $xmlFile): array protected function parseFile(DOMDocument $xml): array { + /** @var DOMNodeList|false $nodeList */ $nodeList = (new DOMXPath($xml))->query('//types/type'); if (!$nodeList instanceof DOMNodeList) { return []; @@ -61,6 +67,11 @@ protected function parseFile(DOMDocument $xml): array return self::parseList($nodeList); } + /** + * @param DOMNodeList $list + * + * @return array> + */ private static function parseList(DOMNodeList $list): array { if ($list->length === 0) { @@ -68,7 +79,6 @@ private static function parseList(DOMNodeList $list): array } $items = []; - /** @var DOMElement $item */ foreach ($list as $item) { $item = self::parseItem($item); $items[$item['typeName']] = $item; @@ -78,6 +88,9 @@ private static function parseList(DOMNodeList $list): array return $items; } + /** + * @return array + */ private static function parseItem(DOMElement $element): array { $item = []; @@ -148,6 +161,9 @@ private static function parseItem(DOMElement $element): array return $item; } + /** + * @return array + */ private static function parseField(DOMElement $element): array { $item = []; @@ -172,17 +188,17 @@ private static function parseField(DOMElement $element): array $item['custom'] = self::parseCustom($element); $item['options'] = self::parseCustom($element, 'options'); - $store = $element->getElementsByTagName('store'); - - if ($store->length) { - /** @var DOMElement $storeElement */ - $storeElement = $store->item(0); - $item['store'] = self::parseComboboStoreList($storeElement); + $storeItem = $element->getElementsByTagName('store')->item(0); + if ($storeItem) { + $item['store'] = self::parseComboStoreList($storeItem); } return $item; } + /** + * @return array + */ private static function parseFieldset(DOMElement $element): array { $fieldSet = []; @@ -202,6 +218,9 @@ private static function parseFieldset(DOMElement $element): array return $fieldSet; } + /** + * @return array + */ private static function parseCustom(DOMElement $element, string $fieldName = 'custom'): array { $elements = $element->getElementsByTagName($fieldName); @@ -209,32 +228,38 @@ private static function parseCustom(DOMElement $element, string $fieldName = 'cu return []; } - return self::cleanArray(self::xmlToArray($elements->item(0))); + $elementsItem = $elements->item(0); + if (!$elementsItem instanceof DOMNode) { + return []; + } + + return self::cleanArray(self::xmlToArray($elementsItem)); } /** * @see https://stackoverflow.com/questions/14553547/what-is-the-best-php-dom-2-array-function + * + * @return array */ - private static function xmlToArray(DOMNode $root) + private static function xmlToArray(DOMNode $root): array { $result = []; - if ($root->hasAttributes()) { - foreach ($root->attributes as $attr) { + $attributes = $root->attributes; + if ($attributes) { + foreach ($attributes as $attr) { $result['@attributes'][$attr->name] = $attr->value; } } if ($root->hasChildNodes()) { $children = $root->childNodes; - if ($children->length == 1) { + if ($children->length === 1) { $child = $children->item(0); - if ($child->nodeType == XML_TEXT_NODE) { + if ($child && $child->nodeType === XML_TEXT_NODE) { $result['_value'] = $child->nodeValue; - return \count($result) == 1 - ? $result['_value'] - : $result; + return \count($result) === 1 ? $result['_value'] : $result; } } $groups = []; @@ -254,6 +279,11 @@ private static function xmlToArray(DOMNode $root) return $result; } + /** + * @param array $haystack + * + * @return array + */ private static function cleanArray(array $haystack): array { foreach ($haystack as $key => $value) { @@ -269,22 +299,24 @@ private static function cleanArray(array $haystack): array return $haystack; } - private static function parseComboboStoreList(DOMElement $element): array + /** + * @return list + */ + private static function parseComboStoreList(DOMElement $element): array { $storeOptions = $element->getElementsByTagName('option'); if ($storeOptions->length === 0) { return []; } $options = []; - /** @var DOMElement $storeOption */ foreach ($storeOptions as $storeOption) { $value = ''; $label = ''; if ($optionValue = $storeOption->getElementsByTagName('value')->item(0)) { - $value = $optionValue->nodeValue; + $value = (string) $optionValue->nodeValue; } if ($labelNode = $storeOption->getElementsByTagName('label')->item(0)) { - $label = $labelNode->nodeValue; + $label = (string) $labelNode->nodeValue; } $options[] = [ 'id' => $value, diff --git a/engine/Shopware/Components/Plugin/RequirementValidator.php b/engine/Shopware/Components/Plugin/RequirementValidator.php index b19d5370011..3a598b41e44 100644 --- a/engine/Shopware/Components/Plugin/RequirementValidator.php +++ b/engine/Shopware/Components/Plugin/RequirementValidator.php @@ -1,4 +1,6 @@ } $compatibility + */ private function assertShopwareVersion(array $compatibility, string $shopwareVersion): void { - if (isset($compatibility['blacklist']) && \in_array($shopwareVersion, $compatibility['blacklist'])) { + if (isset($compatibility['blacklist']) && \in_array($shopwareVersion, $compatibility['blacklist'], true)) { throw new Exception(sprintf($this->namespace->get('shopware_version_blacklisted'), $shopwareVersion)); } @@ -114,6 +105,9 @@ private function assertShopwareVersion(array $compatibility, string $shopwareVer } } + /** + * @param array}> $requiredPlugins + */ private function assertRequiredPlugins(array $requiredPlugins): void { $pluginRepository = $this->em->getRepository(Plugin::class); @@ -135,7 +129,7 @@ private function assertRequiredPlugins(array $requiredPlugins): void throw new Exception(sprintf($this->namespace->get('required_plugin_not_active'), $requiredPlugin['pluginName'])); } - if (isset($requiredPlugin['blacklist']) && \in_array($plugin->getVersion(), $requiredPlugin['blacklist'])) { + if (isset($requiredPlugin['blacklist']) && \in_array($plugin->getVersion(), $requiredPlugin['blacklist'], true)) { throw new Exception(sprintf($this->namespace->get('required_plugin_blacklisted'), $plugin->getName(), $plugin->getVersion())); } diff --git a/engine/Shopware/Components/Plugin/XmlPluginInfoReader.php b/engine/Shopware/Components/Plugin/XmlPluginInfoReader.php index 0a951d6058f..4d654e3fb24 100644 --- a/engine/Shopware/Components/Plugin/XmlPluginInfoReader.php +++ b/engine/Shopware/Components/Plugin/XmlPluginInfoReader.php @@ -1,4 +1,6 @@ nodeValue ?: ''; diff --git a/engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreValueParserFactory.php b/engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreValueParserFactory.php index 567060f65e7..2b9270251cd 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreValueParserFactory.php +++ b/engine/Shopware/Components/Plugin/XmlReader/StoreValueParser/StoreValueParserFactory.php @@ -1,4 +1,6 @@ |null}> + */ public function parse(DOMElement $element) { $storeOptions = $element->getElementsByTagName('option'); @@ -42,7 +47,7 @@ public function parse(DOMElement $element) foreach ($storeOptions as $storeOption) { $value = ''; if ($optionValue = $storeOption->getElementsByTagName('value')->item(0)) { - $value = $optionValue->nodeValue; + $value = (string) $optionValue->nodeValue; } $label = XmlReaderBase::parseTranslatableNodeList( diff --git a/engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php b/engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php index 19f0834072e..e84dd1bb379 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php +++ b/engine/Shopware/Components/Plugin/XmlReader/XmlConfigReader.php @@ -1,4 +1,6 @@ |false $elements */ $elements = $xpath->query('//config/elements/element'); if ($elements instanceof DOMNodeList) { $form['elements'] = $this->parseElementNodeList($elements); @@ -74,6 +78,11 @@ protected function parseFile(DOMDocument $xml): array return $form; } + /** + * @param DOMNodeList $list + * + * @return list|null, description: array|null, options: array|null, store?: array|null}>|string|null}> + */ private function parseElementNodeList(DOMNodeList $list): array { if ($list->length === 0) { @@ -86,14 +95,9 @@ private function parseElementNodeList(DOMNodeList $list): array $element = []; // attributes - $element['scope'] = self::validateAttributeScope( - $item->getAttribute('scope') - ); + $element['scope'] = self::validateAttributeScope($item->getAttribute('scope')); - $element['isRequired'] = self::validateBooleanAttribute( - $item->getAttribute('required'), - false - ); + $element['isRequired'] = self::validateBooleanAttribute($item->getAttribute('required')); $element['type'] = self::validateTextAttribute( $item->getAttribute('type'), @@ -106,25 +110,27 @@ private function parseElementNodeList(DOMNodeList $list): array } if ($item->getElementsByTagName('value')->length) { - $element['value'] = XmlUtils::phpize($item->getElementsByTagName('value')->item(0)->nodeValue); + $valueItem = $item->getElementsByTagName('value')->item(0); + if ($valueItem instanceof DOMElement) { + $element['value'] = XmlUtils::phpize($valueItem->nodeValue); + } } $element['label'] = self::parseTranslatableElement($item, 'label'); $element['description'] = self::parseTranslatableElement($item, 'description'); $element['options'] = []; - if ($options = self::parseOptionsNodeList( - $item->getElementsByTagName('options') - )) { + if ($options = self::parseOptionsNodeList($item->getElementsByTagName('options'))) { $element['options'] = $options; } - if ($store = self::parseStoreNodeList( - $item->getElementsByTagName('store') - )) { + if ($store = self::parseStoreNodeList($item->getElementsByTagName('store'))) { $element['store'] = $store; } elseif ($item->getElementsByTagName('store')->length) { - $element['store'] = $item->getElementsByTagName('store')->item(0)->nodeValue; + $storeItem = $item->getElementsByTagName('store')->item(0); + if ($storeItem instanceof DOMElement) { + $element['store'] = $storeItem->nodeValue; + } } $elements[] = $element; diff --git a/engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php b/engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php index bcb63848c1b..e81624732c4 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php +++ b/engine/Shopware/Components/Plugin/XmlReader/XmlCronjobReader.php @@ -1,4 +1,6 @@ |false $nodeList */ $nodeList = (new DOMXPath($xml))->query('//cronjobs/cronjob'); if (!$nodeList instanceof DOMNodeList) { return []; @@ -43,6 +49,11 @@ protected function parseFile(DOMDocument $xml): array return $this->parseList($nodeList); } + /** + * @param DOMNodeList $list + * + * @return list + */ private function parseList(DOMNodeList $list): array { if ($list->length === 0) { @@ -58,6 +69,9 @@ private function parseList(DOMNodeList $list): array return $items; } + /** + * @return Cronjob + */ private function parseItem(DOMElement $element): array { $item = []; diff --git a/engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php b/engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php index 61c49abb955..7a566ebe610 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php +++ b/engine/Shopware/Components/Plugin/XmlReader/XmlMenuReader.php @@ -1,4 +1,6 @@ + */ private function parseEntry(DOMElement $entry): array { $menuEntry = []; @@ -81,9 +86,7 @@ private function parseEntry(DOMElement $entry): array 'controller' ); - $menuEntry['parent'] = [ - $identifiedBy => $parent->nodeValue, - ]; + $menuEntry['parent'] = [$identifiedBy => $parent->nodeValue]; } $active = self::getElementChildValueByName($entry, 'active'); @@ -99,9 +102,11 @@ private function parseEntry(DOMElement $entry): array $children = $entry->getElementsByTagName('children'); if ($children !== null && $children->length) { $children = $children->item(0); - $menuEntry['children'] = []; - foreach (self::getChildren($children, 'entry') as $child) { - $menuEntry['children'][] = $this->parseEntry($child); + if ($children !== null) { + $menuEntry['children'] = []; + foreach (self::getChildren($children, 'entry') as $child) { + $menuEntry['children'][] = $this->parseEntry($child); + } } } diff --git a/engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php b/engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php index a46859dbe6d..27000e21643 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php +++ b/engine/Shopware/Components/Plugin/XmlReader/XmlPluginReader.php @@ -1,4 +1,6 @@ $items + * + * @return list|null + */ public static function parseBlacklist(DOMNodeList $items): ?array { if ($items->length === 0) { @@ -106,7 +113,7 @@ protected function parseFile(DOMDocument $xml): array throw new InvalidArgumentException(sprintf('Element with name "compatibility" found multiple times in file "%s", but expected to be there only once', static::$xmlFile)); } $compatibility = $compatibility->item(0); - if ($compatibility instanceof DOMNode) { + if ($compatibility instanceof DOMElement) { $info['compatibility'] = [ 'minVersion' => $compatibility->getAttribute('minVersion'), 'maxVersion' => $compatibility->getAttribute('maxVersion'), @@ -129,6 +136,9 @@ protected function parseFile(DOMDocument $xml): array return $info; } + /** + * @return list}> + */ private function parseRequiredPlugins(DOMElement $requiredPluginNode): array { $plugins = []; diff --git a/engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php b/engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php index f103a95cbbd..6be8a30b82b 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php +++ b/engine/Shopware/Components/Plugin/XmlReader/XmlReaderBase.php @@ -1,4 +1,6 @@ |null}>|string|null */ public static function parseStoreNodeList(DOMNodeList $list) { @@ -172,13 +174,17 @@ public static function parseStoreNodeList(DOMNodeList $list) return StoreValueParserFactory::create($type)->parse($storeItem); } + /** + * @return array|null + */ public static function parseOptionsNodeList(DOMNodeList $optionsList): ?array { - if ($optionsList->length === 0) { + $optionsListItem = $optionsList->item(0); + if ($optionsListItem === null) { return null; } - $optionList = $optionsList->item(0)->childNodes; + $optionList = $optionsListItem->childNodes; if ($optionList->length === 0) { return null; @@ -223,5 +229,8 @@ public static function validateTextAttribute(string $type, string $defaultValue return $type; } + /** + * @return array + */ abstract protected function parseFile(DOMDocument $xml): array; } diff --git a/engine/Shopware/Components/Plugin/XmlReader/XmlReaderInterface.php b/engine/Shopware/Components/Plugin/XmlReader/XmlReaderInterface.php index 7fb56c329dc..2dff78121f3 100644 --- a/engine/Shopware/Components/Plugin/XmlReader/XmlReaderInterface.php +++ b/engine/Shopware/Components/Plugin/XmlReader/XmlReaderInterface.php @@ -1,4 +1,6 @@ + */ public function read(string $xmlFile): array; } diff --git a/tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php b/tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php index 5f67e36022c..1b15c635e0c 100644 --- a/tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php +++ b/tests/Unit/Components/Plugin/XmlReader/StoreValueParser/StoreXmlValueParserTest.php @@ -23,7 +23,6 @@ namespace Shopware\Tests\Unit\Components\Plugin\XmlReader\StoreValueParser; -use DOMDocument; use DOMElement; use DOMNodeList; use DOMXPath; @@ -34,20 +33,9 @@ class StoreXmlValueParserTest extends TestCase { - /** - * @var StoreXmlValueParser - */ - private $parser; - - /** - * @var DOMDocument - */ - private $xmlFile; + private StoreXmlValueParser $parser; - /** - * @var DOMXPath - */ - private $xpath; + private DOMXPath $xpath; /** * {@inheritdoc} @@ -56,12 +44,10 @@ public function __construct($name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); - $this->xmlFile = XmlUtils::loadFile( + $this->xpath = new DOMXPath(XmlUtils::loadFile( __DIR__ . '/../examples/config/config_store_xml.xml', __DIR__ . '/../../../../../../engine/Shopware/Components/Plugin/schema/config.xsd' - ); - - $this->xpath = new DOMXPath($this->xmlFile); + )); } protected function setUp(): void @@ -126,6 +112,9 @@ private function getStoreElement(int $elementIndex): DOMElement ); static::assertInstanceOf(DOMNodeList::class, $stores); - return $stores->item(0); + $item = $stores->item(0); + static::assertInstanceOf(DOMElement::class, $item); + + return $item; } } diff --git a/tests/Unit/Components/Plugin/XmlReader/XmlConfigReaderTest.php b/tests/Unit/Components/Plugin/XmlReader/XmlConfigReaderTest.php index 110739bbad3..40e694be402 100644 --- a/tests/Unit/Components/Plugin/XmlReader/XmlConfigReaderTest.php +++ b/tests/Unit/Components/Plugin/XmlReader/XmlConfigReaderTest.php @@ -168,6 +168,9 @@ public function testValidateAttributeScopeThrowsException(): void XmlConfigReader::validateAttributeScope('invalid value'); } + /** + * @return array + */ private function readFile(string $file): array { return $this->configReader->read( diff --git a/tests/Unit/Components/Plugin/XmlReader/XmlCronjobReaderTest.php b/tests/Unit/Components/Plugin/XmlReader/XmlCronjobReaderTest.php index 1a73b0a545b..3a302601832 100644 --- a/tests/Unit/Components/Plugin/XmlReader/XmlCronjobReaderTest.php +++ b/tests/Unit/Components/Plugin/XmlReader/XmlCronjobReaderTest.php @@ -86,6 +86,9 @@ public function testReadEmptyFile(): void static::assertCount(0, $result); } + /** + * @return array + */ private function readFile(): array { return $this->cronjobReader->read( diff --git a/tests/Unit/Components/Plugin/XmlReader/XmlMenuReaderTest.php b/tests/Unit/Components/Plugin/XmlReader/XmlMenuReaderTest.php index 77d5a583e7e..caa451dfd59 100644 --- a/tests/Unit/Components/Plugin/XmlReader/XmlMenuReaderTest.php +++ b/tests/Unit/Components/Plugin/XmlReader/XmlMenuReaderTest.php @@ -97,6 +97,9 @@ public function testMultipleChildren(): void static::assertEquals('PaypalUnifiedSettings', $result[0]['children'][1]['controller']); } + /** + * @return array + */ private function readFile(string $file): array { return $this->menuReader->read( diff --git a/tests/Unit/Components/Plugin/XmlReader/XmlPluginReaderTest.php b/tests/Unit/Components/Plugin/XmlReader/XmlPluginReaderTest.php index 3f75fbfeec1..03c2a4149b3 100644 --- a/tests/Unit/Components/Plugin/XmlReader/XmlPluginReaderTest.php +++ b/tests/Unit/Components/Plugin/XmlReader/XmlPluginReaderTest.php @@ -117,6 +117,9 @@ public function testReadFileWithMultipleVersion(): void $this->readFile('plugin_multiple_versions'); } + /** + * @return array + */ private function readFile(string $fileName = 'plugin'): array { return $this->pluginReader->read(