Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.

Commit e522f82

Browse files
committed
Fix CS
1 parent 148f847 commit e522f82

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

lib/Document.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use DOMNodeList;
1616
use RuntimeException;
1717

18-
1918
/**
2019
* Wrapper for the \DOMDocument class.
2120
*/
@@ -41,19 +40,18 @@ public function __construct($version = '1.0', $encoding = null)
4140
*
4241
* @param string $name
4342
*
44-
* @return Element
4543
*/
4644
public function createRoot($name): Element
4745
{
4846
$element = $this->appendChild(new Element($name));
4947
assert($element instanceof Element);
48+
5049
return $element;
5150
}
5251

5352
/**
5453
* Return the XPath object bound to this document.
5554
*
56-
* @return XPath
5755
*/
5856
public function xpath(): XPath
5957
{
@@ -85,15 +83,14 @@ public function queryOne($query, DOMNode $context = null)
8583
/**
8684
* {@inheritdoc}
8785
*/
88-
public function evaluate($expression, \DOMNode $context = null)
86+
public function evaluate($expression, DOMNode $context = null)
8987
{
9088
return $this->xpath()->evaluate($expression, $context);
9189
}
9290

9391
/**
9492
* Return a formatted string representation of the document.
9593
*
96-
* @return string
9794
*/
9895
public function dump(): string
9996
{

lib/Element.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use DOMNode;
1515
use DOMNodeList;
1616

17-
1817
/**
1918
* Wrapper for the \DOMElement class.
2019
*/
@@ -32,26 +31,27 @@ public function appendElement($name, $value = null)
3231
{
3332
$element = $this->appendChild(new self($name, $value));
3433
assert($element instanceof Element);
34+
3535
return $element;
3636
}
3737

3838
/**
3939
* @return DOMNodeList<DOMNode>
4040
*/
41-
public function query($xpath, \DOMNode $context = null): DOMNodeList
41+
public function query($xpath, DOMNode $context = null): DOMNodeList
4242
{
4343
return $this->owner()->xpath()->query($xpath, $context ?: $this);
4444
}
4545

46-
public function queryOne($xpath, \DOMNode $context = null)
46+
public function queryOne($xpath, DOMNode $context = null)
4747
{
4848
return $this->owner()->xpath()->queryOne($xpath, $context ?: $this);
4949
}
5050

5151
/**
5252
* {@inheritdoc}
5353
*/
54-
public function evaluate($expression, \DOMNode $context = null)
54+
public function evaluate($expression, DOMNode $context = null)
5555
{
5656
return $this->owner()->xpath()->evaluate($expression, $context ?: $this);
5757
}
@@ -71,6 +71,7 @@ private function owner(): Document
7171
{
7272
$owner = $this->ownerDocument;
7373
assert($owner instanceof Document);
74-
return $owner;
74+
75+
return $owner;
7576
}
7677
}

lib/XPath.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use DOMNodeList;
1616
use RuntimeException;
1717

18-
1918
/**
2019
* Wrapper for the \DOMXPath class.
2120
*/
@@ -24,7 +23,7 @@ class XPath extends \DOMXPath
2423
/**
2524
* {@inheritdoc}
2625
*/
27-
public function evaluate ($expression, $contextnode = null, $registerNodeNS = true)
26+
public function evaluate($expression, $contextnode = null, $registerNodeNS = true)
2827
{
2928
$result = $this->execute('evaluate', 'expression', $expression, $contextnode, $registerNodeNS);
3029

@@ -34,7 +33,7 @@ public function evaluate ($expression, $contextnode = null, $registerNodeNS = tr
3433
/**
3534
* @return DOMNodeList<DOMNode>
3635
*/
37-
public function query ($expression, $contextnode = null, $registerNodeNS = true)
36+
public function query($expression, $contextnode = null, $registerNodeNS = true)
3837
{
3938
return $this->execute('query', 'query', $expression, $contextnode, $registerNodeNS);
4039
}
@@ -62,6 +61,7 @@ public function queryOne(string $expr, DOMNode $contextEl = null, bool $register
6261

6362
/**
6463
* Execute the given xpath method and cactch any errors.
64+
*
6565
* @return mixed
6666
*/
6767
private function execute(string $method, string $context, string $query, DOMNode $contextEl = null, bool $registerNodeNs = false)
@@ -71,8 +71,10 @@ private function execute(string $method, string $context, string $query, DOMNode
7171
$value = @parent::$method($query, $contextEl, $registerNodeNs);
7272

7373
$xmlErrors = libxml_get_errors();
74+
7475
if ($xmlErrors) {
7576
$errors = [];
77+
7678
foreach ($xmlErrors as $xmlError) {
7779
$errors[] = sprintf('[%s] %s', $xmlError->code, $xmlError->message);
7880
}

lib/XPathAware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface XPathAware
2828
*
2929
* @return DOMNodeList<DOMNode>
3030
*/
31-
public function query($query, \DOMNode $context = null);
31+
public function query($query, DOMNode $context = null);
3232

3333
/**
3434
* As with XPathAware::query but return a single node or NULL if no node was found.
@@ -38,7 +38,7 @@ public function query($query, \DOMNode $context = null);
3838
*
3939
* @return Element|null
4040
*/
41-
public function queryOne($query, \DOMNode $context = null);
41+
public function queryOne($query, DOMNode $context = null);
4242

4343
/**
4444
* Evaluate an XPath expression on this document, optionally
@@ -52,5 +52,5 @@ public function queryOne($query, \DOMNode $context = null);
5252
*
5353
* @return mixed
5454
*/
55-
public function evaluate($expression, \DOMNode $context = null);
55+
public function evaluate($expression, DOMNode $context = null);
5656
}

tests/Unit/DocumentTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace PhpBench\Dom\Tests\Unit;
1313

14-
use PHPUnit\Framework\TestCase;
1514
use PhpBench\Dom\Document;
15+
use PHPUnit\Framework\TestCase;
1616

1717
class DocumentTest extends TestCase
1818
{
@@ -21,15 +21,15 @@ class DocumentTest extends TestCase
2121
*/
2222
private $document;
2323

24-
public function setUp(): void
24+
protected function setUp(): void
2525
{
2626
$this->document = new Document(1.0);
2727
}
2828

2929
/**
3030
* It should perform an XPath query.
3131
*/
32-
public function testQuery()
32+
public function testQuery(): void
3333
{
3434
$this->document->loadXml($this->getXml());
3535
$nodeList = $this->document->query('//record');
@@ -40,7 +40,7 @@ public function testQuery()
4040
/**
4141
* It should evaluate an XPath expression.
4242
*/
43-
public function testEvaluate()
43+
public function testEvaluate(): void
4444
{
4545
$this->document->loadXml($this->getXml());
4646
$result = $this->document->evaluate('count(//record)');
@@ -50,7 +50,7 @@ public function testEvaluate()
5050
/**
5151
* It should create a root element.
5252
*/
53-
public function testCreateRoot()
53+
public function testCreateRoot(): void
5454
{
5555
$this->document->createRoot('hello');
5656
$this->assertStringContainsString('<hello/>', $this->document->saveXml());
@@ -59,7 +59,7 @@ public function testCreateRoot()
5959
/**
6060
* It should return a formatted string representation of the document.
6161
*/
62-
public function testDump()
62+
public function testDump(): void
6363
{
6464
$this->document->loadXml($this->getXml());
6565
$this->assertEquals(
@@ -71,7 +71,7 @@ public function testDump()
7171
/**
7272
* It should provide a duplicate version of itself.
7373
*/
74-
public function testDuplicate()
74+
public function testDuplicate(): void
7575
{
7676
$this->document->loadXml($this->getXml());
7777
$duplicate = $this->document->duplicate();

tests/Unit/ElementTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
namespace PhpBench\Dom\Tests\Unit;
1313

14-
use PHPUnit\Framework\TestCase;
1514
use PhpBench\Dom\Document;
15+
use PHPUnit\Framework\TestCase;
1616

1717
class ElementTest extends TestCase
1818
{
1919
private $element;
2020
private $document;
2121

22-
public function setUp(): void
22+
protected function setUp(): void
2323
{
2424
$this->document = new Document();
2525
$this->element = $this->document->createRoot('test');
@@ -28,7 +28,7 @@ public function setUp(): void
2828
/**
2929
* It should create and append a child element.
3030
*/
31-
public function testAppendElement()
31+
public function testAppendElement(): void
3232
{
3333
$element = $this->element->appendElement('hello');
3434
$result = $this->document->evaluate('count(//hello)');
@@ -39,7 +39,7 @@ public function testAppendElement()
3939
/**
4040
* It should exeucte an XPath query.
4141
*/
42-
public function testQuery()
42+
public function testQuery(): void
4343
{
4444
$boo = $this->element->appendElement('boo');
4545
$nodeList = $this->element->query('.//*');
@@ -52,7 +52,7 @@ public function testQuery()
5252
/**
5353
* It should evaluate an XPath expression.
5454
*/
55-
public function testEvaluate()
55+
public function testEvaluate(): void
5656
{
5757
$boo = $this->element->appendElement('boo');
5858
$count = $this->element->evaluate('count(.//*)');
@@ -64,7 +64,7 @@ public function testEvaluate()
6464
/**
6565
* It should query for one element.
6666
*/
67-
public function testQueryOne()
67+
public function testQueryOne(): void
6868
{
6969
$boo = $this->element->appendElement('boo');
7070
$node = $this->element->queryOne('./boo');
@@ -74,7 +74,7 @@ public function testQueryOne()
7474
/**
7575
* It should return null if one element is queried for an it none exist.
7676
*/
77-
public function testQueryOneNone()
77+
public function testQueryOneNone(): void
7878
{
7979
$node = $this->element->queryOne('./boo');
8080
$this->assertNull($node);
@@ -83,7 +83,7 @@ public function testQueryOneNone()
8383
/**
8484
* It should return the XML contained in the node.
8585
*/
86-
public function testDumpNode()
86+
public function testDumpNode(): void
8787
{
8888
$this->element->appendElement('boo');
8989
$dump = $this->element->dump();

tests/Unit/XPathTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212
namespace PhpBench\Dom\Tests\Unit;
1313

14-
use PHPUnit\Framework\TestCase;
1514
use PhpBench\Dom\Document;
1615
use PhpBench\Dom\Exception\InvalidQueryException;
16+
use PHPUnit\Framework\TestCase;
1717

1818
class XPathTest extends TestCase
1919
{
2020
/**
2121
* It should throw an exception if the xpath query is invalid.
2222
*/
23-
public function testQueryException()
23+
public function testQueryException(): void
2424
{
2525
$this->expectException(InvalidQueryException::class);
2626
$this->getDocument()->query('//article[noexistfunc() = "as"]');
@@ -29,7 +29,7 @@ public function testQueryException()
2929
/**
3030
* It should NOT throw an exception if the expression evaluates as false.
3131
*/
32-
public function testEvaluateFalse()
32+
public function testEvaluateFalse(): void
3333
{
3434
$result = $this->getDocument()->evaluate('boolean(count(//foo))');
3535
$this->assertFalse($result);

0 commit comments

Comments
 (0)