diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c7d3c9e5..40cc99a4 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,8 @@ tools: enabled: true timeout: 900 php_sim: - min_mass: 16 + enabled: true + min_mass: 30 php_pdepend: true php_analyzer: true sensiolabs_security_checker: true diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 415526ee..1b9553cb 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -96,7 +96,7 @@ class XMLReader * @param string $path * @return \DOMElement|null */ - public function getElement($path, \DOMElement $contextNode) + public function getElement($path, \DOMElement $contextNode = null) { $elements = $this->getElements($path, $contextNode); if ($elements->length > 0) { @@ -113,16 +113,17 @@ class XMLReader * @param string $path * @return string|null */ - public function getAttribute($attribute, \DOMElement $contextNode, $path = null) + public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null) { - if (is_null($path)) { - $return = $contextNode->getAttribute($attribute); - } else { + $return = null; + if ($path !== null) { $elements = $this->getElements($path, $contextNode); if ($elements->length > 0) { $return = $elements->item(0)->getAttribute($attribute); - } else { - $return = null; + } + } else { + if ($contextNode !== null) { + $return = $contextNode->getAttribute($attribute); } } @@ -135,7 +136,7 @@ class XMLReader * @param string $path * @return string|null */ - public function getValue($path, \DOMElement $contextNode) + public function getValue($path, \DOMElement $contextNode = null) { $elements = $this->getElements($path, $contextNode); if ($elements->length > 0) { @@ -151,7 +152,7 @@ class XMLReader * @param string $path * @return integer */ - public function countElements($path, \DOMElement $contextNode) + public function countElements($path, \DOMElement $contextNode = null) { $elements = $this->getElements($path, $contextNode); @@ -164,7 +165,7 @@ class XMLReader * @param string $path * @return boolean */ - public function elementExists($path, \DOMElement $contextNode) + public function elementExists($path, \DOMElement $contextNode = null) { return $this->getElements($path, $contextNode)->length > 0; } diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index d6b48ca8..89bcfd37 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -51,9 +51,9 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle protected function getStyles() { /** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */ - /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ - $parentWriter = $this->parentWriter; + + /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ $element = $this->element; // Font style diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index cee1b157..abdf888d 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -32,9 +32,8 @@ class Text extends AbstractElement public function write() { /** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */ - - $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); $element = $this->element; + $elementClass = str_replace('\\Writer\\RTF', '', get_class($this)); if (!$element instanceof $elementClass) { return; }