Your project must not contain invalid function or method calls 2
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- */
- public function getType(): ?string
- {
- $type = null;
- if (($parent = $this->getParent()) instanceof ElementHandler && $parent->hasAttribute(self::ATTRIBUTE_TYPE)) {
- $type = $parent->getAttribute(self::ATTRIBUTE_TYPE)->getValue(false, false);
- }
- return $type;
- }
- return $this->getNodeHandler($node, $this, $index);
- }
- public function getNodeByName(string $name): ?NodeHandler
- {
- return $this->domDocument->getElementsByTagName($name)->length > 0 ? $this->getNodeHandler($this->domDocument->getElementsByTagName($name)->item(0), $this) : null;
- }
- public function getElementByName(string $name): ?ElementHandler
- {
- $node = $this->getNodeByName($name);
Your project should not use invalid return types
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint
- $type = null;
- if (($parent = $this->getParent()) instanceof ElementHandler && $parent->hasAttribute(self::ATTRIBUTE_TYPE)) {
- $type = $parent->getAttribute(self::ATTRIBUTE_TYPE)->getValue(false, false);
- }
- return $type;
- }
- public function getValue(bool $withNamespace = false, bool $withinItsType = true, ?string $asType = self::DEFAULT_VALUE_TYPE)
- {
- $value = $this->getAttribute()->value;
Your project must not contain invalid instantiations 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- *
- * @return \DOMNodeList<\DOMAttr|\DOMElement|\DOMNode>|false
- */
- public function searchTagsByXpath(string $name, array $attributes, ?\DOMNode $node = null)
- {
- $xpath = new \DOMXPath($node ? $node->ownerDocument : $this->domDocument);
- $xQuery = sprintf("%s//*[local-name()='%s']", $node instanceof \DOMNode ? '.' : '', $name);
- foreach ($attributes as $attributeName => $attributeValue) {
- if (false !== strpos($attributeValue, '*')) {
- $xQuery .= sprintf("[contains(@%s, '%s')]", $attributeName, str_replace('*', '', $attributeValue));
- } else {
- {
- protected \DOMNameSpaceNode $nodeNameSpace;
- public function __construct(\DOMNameSpaceNode $nameSpaceNode, AbstractDomDocumentHandler $domDocumentHandler, int $index = -1)
- {
- parent::__construct(new \DOMAttr($nameSpaceNode->nodeName, $nameSpaceNode->nodeValue), $domDocumentHandler, $index);
- $this->nodeNameSpace = $nameSpaceNode;
- }
- public function getValue(bool $withNamespace = false, bool $withinItsType = true, ?string $asType = self::DEFAULT_VALUE_TYPE)
- {
- {
- protected \DOMNameSpaceNode $nodeNameSpace;
- public function __construct(\DOMNameSpaceNode $nameSpaceNode, AbstractDomDocumentHandler $domDocumentHandler, int $index = -1)
- {
- parent::__construct(new \DOMAttr($nameSpaceNode->nodeName, $nameSpaceNode->nodeValue), $domDocumentHandler, $index);
- $this->nodeNameSpace = $nameSpaceNode;
- }
- public function getValue(bool $withNamespace = false, bool $withinItsType = true, ?string $asType = self::DEFAULT_VALUE_TYPE)
- {
Your project should use dedicated PHP string functions 4
- Read doc
- Productivity
- Info
More information: https://insight.symfony.com/what-we-analyse/php.use_string_function
- public function getValueNamespace(): ?string
- {
- $value = $this->getAttribute()->value;
- $namespace = null;
- if (false !== strpos($value, ':')) {
- $namespace = implode('', array_slice(explode(':', $value), 0, -1));
- }
- return $namespace;
- }
- public function searchTagsByXpath(string $name, array $attributes, ?\DOMNode $node = null)
- {
- $xpath = new \DOMXPath($node ? $node->ownerDocument : $this->domDocument);
- $xQuery = sprintf("%s//*[local-name()='%s']", $node instanceof \DOMNode ? '.' : '', $name);
- foreach ($attributes as $attributeName => $attributeValue) {
- if (false !== strpos($attributeValue, '*')) {
- $xQuery .= sprintf("[contains(@%s, '%s')]", $attributeName, str_replace('*', '', $attributeValue));
- } else {
- $xQuery .= sprintf("[@%s='%s']", $attributeName, $attributeValue);
- }
- }
- }
- public function getName(): string
- {
- $name = $this->getNode()->nodeName;
- if (false !== strpos($name, ':')) {
- $name = implode('', array_slice(explode(':', $name), -1, 1));
- }
- return $name;
- }
- }
- public function getNamespace(): ?string
- {
- $name = $this->getNode()->nodeName;
- if (false !== strpos($name, ':')) {
- return implode('', array_slice(explode(':', $name), 0, -1));
- }
- return null;
- }