Skip to content

Commit 6ba6ed4

Browse files
committed
Reactivate php_sim in Scrutinizer and fix some minor issues
1 parent e03e121 commit 6ba6ed4

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

.scrutinizer.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ tools:
1818
enabled: true
1919
timeout: 900
2020
php_sim:
21-
min_mass: 16
21+
enabled: true
22+
min_mass: 30
2223
php_pdepend: true
2324
php_analyzer: true
2425
sensiolabs_security_checker: true

src/PhpWord/Shared/XMLReader.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function getElements($path, \DOMElement $contextNode = null)
9696
* @param string $path
9797
* @return \DOMElement|null
9898
*/
99-
public function getElement($path, \DOMElement $contextNode)
99+
public function getElement($path, \DOMElement $contextNode = null)
100100
{
101101
$elements = $this->getElements($path, $contextNode);
102102
if ($elements->length > 0) {
@@ -113,16 +113,17 @@ public function getElement($path, \DOMElement $contextNode)
113113
* @param string $path
114114
* @return string|null
115115
*/
116-
public function getAttribute($attribute, \DOMElement $contextNode, $path = null)
116+
public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null)
117117
{
118-
if (is_null($path)) {
119-
$return = $contextNode->getAttribute($attribute);
120-
} else {
118+
$return = null;
119+
if ($path !== null) {
121120
$elements = $this->getElements($path, $contextNode);
122121
if ($elements->length > 0) {
123122
$return = $elements->item(0)->getAttribute($attribute);
124-
} else {
125-
$return = null;
123+
}
124+
} else {
125+
if ($contextNode !== null) {
126+
$return = $contextNode->getAttribute($attribute);
126127
}
127128
}
128129

@@ -135,7 +136,7 @@ public function getAttribute($attribute, \DOMElement $contextNode, $path = null)
135136
* @param string $path
136137
* @return string|null
137138
*/
138-
public function getValue($path, \DOMElement $contextNode)
139+
public function getValue($path, \DOMElement $contextNode = null)
139140
{
140141
$elements = $this->getElements($path, $contextNode);
141142
if ($elements->length > 0) {
@@ -151,7 +152,7 @@ public function getValue($path, \DOMElement $contextNode)
151152
* @param string $path
152153
* @return integer
153154
*/
154-
public function countElements($path, \DOMElement $contextNode)
155+
public function countElements($path, \DOMElement $contextNode = null)
155156
{
156157
$elements = $this->getElements($path, $contextNode);
157158

@@ -164,7 +165,7 @@ public function countElements($path, \DOMElement $contextNode)
164165
* @param string $path
165166
* @return boolean
166167
*/
167-
public function elementExists($path, \DOMElement $contextNode)
168+
public function elementExists($path, \DOMElement $contextNode = null)
168169
{
169170
return $this->getElements($path, $contextNode)->length > 0;
170171
}

src/PhpWord/Writer/RTF/Element/AbstractElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ class AbstractElement extends \PhpOffice\PhpWord\Writer\HTML\Element\AbstractEle
5151
protected function getStyles()
5252
{
5353
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Scrutinizer type hint */
54-
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
55-
5654
$parentWriter = $this->parentWriter;
55+
56+
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
5757
$element = $this->element;
5858

5959
// Font style

src/PhpWord/Writer/RTF/Element/Text.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class Text extends AbstractElement
3232
public function write()
3333
{
3434
/** @var \PhpOffice\PhpWord\Element\Text $element Scrutinizer type hint */
35-
36-
$elementClass = str_replace('\\Writer\\RTF', '', get_class($this));
3735
$element = $this->element;
36+
$elementClass = str_replace('\\Writer\\RTF', '', get_class($this));
3837
if (!$element instanceof $elementClass) {
3938
return;
4039
}

0 commit comments

Comments
 (0)