Your project must not contain invalid function or method calls 2

More information: https://insight.symfony.com/what-we-analyse/php.invalid_call

  1. */
  2. public function getType(): ?string
  3. {
  4. $type = null;
  5. if (($parent = $this->getParent()) instanceof ElementHandler && $parent->hasAttribute(self::ATTRIBUTE_TYPE)) {
  6. $type = $parent->getAttribute(self::ATTRIBUTE_TYPE)->getValue(false, false);
    Cannot call method getValue() on WsdlToPhp\DomHandler\AttributeHandler|null.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Mikael DELSOL
  7. }
  8. return $type;
  9. }
  1. return $this->getNodeHandler($node, $this, $index);
  2. }
  3. public function getNodeByName(string $name): ?NodeHandler
  4. {
  5. return $this->domDocument->getElementsByTagName($name)->length > 0 ? $this->getNodeHandler($this->domDocument->getElementsByTagName($name)->item(0), $this) : null;
    Parameter #1 $node of method WsdlToPhp\DomHandler\AbstractDomDocumentHandler::getNodeHandler() expects DOMNode, DOMElement|null given.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Mikael DELSOL
  6. }
  7. public function getElementByName(string $name): ?ElementHandler
  8. {
  9. $node = $this->getNodeByName($name);

Your project should not use invalid return types

More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint

  1. $type = null;
  2. if (($parent = $this->getParent()) instanceof ElementHandler && $parent->hasAttribute(self::ATTRIBUTE_TYPE)) {
  3. $type = $parent->getAttribute(self::ATTRIBUTE_TYPE)->getValue(false, false);
  4. }
  5. return $type;
    Method WsdlToPhp\DomHandler\AbstractAttributeHandler::getType() should return string|null but returns mixed.
    Time to fix: about 9 minutes
    Read doc Open Issue Permalink Copy Prompt
    Last edited by Mikael DELSOL
  6. }
  7. public function getValue(bool $withNamespace = false, bool $withinItsType = true, ?string $asType = self::DEFAULT_VALUE_TYPE)
  8. {
  9. $value = $this->getAttribute()->value;

Your project must not contain invalid instantiations 3

More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation

  1. *
  2. * @return \DOMNodeList<\DOMAttr|\DOMElement|\DOMNode>|false
  3. */
  4. public function searchTagsByXpath(string $name, array $attributes, ?\DOMNode $node = null)
  5. {
  6. $xpath = new \DOMXPath($node ? $node->ownerDocument : $this->domDocument);
    Parameter #1 $document of class DOMXPath constructor expects DOMDocument, DOMDocument|null given.
    Last edited by Mikaël DELSOL
  7. $xQuery = sprintf("%s//*[local-name()='%s']", $node instanceof \DOMNode ? '.' : '', $name);
  8. foreach ($attributes as $attributeName => $attributeValue) {
  9. if (false !== strpos($attributeValue, '*')) {
  10. $xQuery .= sprintf("[contains(@%s, '%s')]", $attributeName, str_replace('*', '', $attributeValue));
  11. } else {
  1. {
  2. protected \DOMNameSpaceNode $nodeNameSpace;
  3. public function __construct(\DOMNameSpaceNode $nameSpaceNode, AbstractDomDocumentHandler $domDocumentHandler, int $index = -1)
  4. {
  5. parent::__construct(new \DOMAttr($nameSpaceNode->nodeName, $nameSpaceNode->nodeValue), $domDocumentHandler, $index);
    Parameter #2 $value of class DOMAttr constructor expects string, mixed given.
    Last edited by Mikaël DELSOL
  6. $this->nodeNameSpace = $nameSpaceNode;
  7. }
  8. public function getValue(bool $withNamespace = false, bool $withinItsType = true, ?string $asType = self::DEFAULT_VALUE_TYPE)
  9. {
  1. {
  2. protected \DOMNameSpaceNode $nodeNameSpace;
  3. public function __construct(\DOMNameSpaceNode $nameSpaceNode, AbstractDomDocumentHandler $domDocumentHandler, int $index = -1)
  4. {
  5. parent::__construct(new \DOMAttr($nameSpaceNode->nodeName, $nameSpaceNode->nodeValue), $domDocumentHandler, $index);
    Parameter #1 $name of class DOMAttr constructor expects string, mixed given.
    Last edited by Mikaël DELSOL
  6. $this->nodeNameSpace = $nameSpaceNode;
  7. }
  8. public function getValue(bool $withNamespace = false, bool $withinItsType = true, ?string $asType = self::DEFAULT_VALUE_TYPE)
  9. {

Your project should use dedicated PHP string functions 4

More information: https://insight.symfony.com/what-we-analyse/php.use_string_function

  1. public function getValueNamespace(): ?string
  2. {
  3. $value = $this->getAttribute()->value;
  4. $namespace = null;
  5. if (false !== strpos($value, ':')) {
    Consider replacing strpos() with str_contains() for improved readability.
    Last edited by Mikaël DELSOL
  6. $namespace = implode('', array_slice(explode(':', $value), 0, -1));
  7. }
  8. return $namespace;
  9. }
  1. public function searchTagsByXpath(string $name, array $attributes, ?\DOMNode $node = null)
  2. {
  3. $xpath = new \DOMXPath($node ? $node->ownerDocument : $this->domDocument);
  4. $xQuery = sprintf("%s//*[local-name()='%s']", $node instanceof \DOMNode ? '.' : '', $name);
  5. foreach ($attributes as $attributeName => $attributeValue) {
  6. if (false !== strpos($attributeValue, '*')) {
    Consider replacing strpos() with str_contains() for improved readability.
    Last edited by Mikaël DELSOL
  7. $xQuery .= sprintf("[contains(@%s, '%s')]", $attributeName, str_replace('*', '', $attributeValue));
  8. } else {
  9. $xQuery .= sprintf("[@%s='%s']", $attributeName, $attributeValue);
  10. }
  11. }
  1. }
  2. public function getName(): string
  3. {
  4. $name = $this->getNode()->nodeName;
  5. if (false !== strpos($name, ':')) {
    Consider replacing strpos() with str_contains() for improved readability.
    Last edited by Mikaël DELSOL
  6. $name = implode('', array_slice(explode(':', $name), -1, 1));
  7. }
  8. return $name;
  9. }
  1. }
  2. public function getNamespace(): ?string
  3. {
  4. $name = $this->getNode()->nodeName;
  5. if (false !== strpos($name, ':')) {
    Consider replacing strpos() with str_contains() for improved readability.
    Last edited by Mikaël DELSOL
  6. return implode('', array_slice(explode(':', $name), 0, -1));
  7. }
  8. return null;
  9. }