Passed
Push — master ( e6bf3a...6c6503 )
by Marius
40s
created
src/ChildElementMatcher.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -8,60 +8,60 @@
 block discarded – undo
8 8
 
9 9
 class ChildElementMatcher extends TypeSafeDiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher|null
13
-	 */
14
-	private $matcher;
11
+    /**
12
+     * @var Matcher|null
13
+     */
14
+    private $matcher;
15 15
 
16
-	public static function havingChild( Matcher $elementMatcher = null ) {
17
-		return new static( $elementMatcher );
18
-	}
16
+    public static function havingChild( Matcher $elementMatcher = null ) {
17
+        return new static( $elementMatcher );
18
+    }
19 19
 
20
-	public function __construct( Matcher $matcher = null ) {
21
-		parent::__construct( \DOMNode::class );
22
-		$this->matcher = $matcher;
23
-	}
20
+    public function __construct( Matcher $matcher = null ) {
21
+        parent::__construct( \DOMNode::class );
22
+        $this->matcher = $matcher;
23
+    }
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'having child ' );
27
-		if ( $this->matcher ) {
28
-			$description->appendDescriptionOf( $this->matcher );
29
-		}
30
-	}
25
+    public function describeTo( Description $description ) {
26
+        $description->appendText( 'having child ' );
27
+        if ( $this->matcher ) {
28
+            $description->appendDescriptionOf( $this->matcher );
29
+        }
30
+    }
31 31
 
32
-	/**
33
-	 * @param \DOMDocument|\DOMNode $item
34
-	 * @param Description $mismatchDescription
35
-	 *
36
-	 * @return bool
37
-	 */
38
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
-		if ( $item instanceof \DOMDocument ) {
40
-			$directChildren = iterator_to_array( $item->documentElement->childNodes );
32
+    /**
33
+     * @param \DOMDocument|\DOMNode $item
34
+     * @param Description $mismatchDescription
35
+     *
36
+     * @return bool
37
+     */
38
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
+        if ( $item instanceof \DOMDocument ) {
40
+            $directChildren = iterator_to_array( $item->documentElement->childNodes );
41 41
 
42
-			$body = array_shift( $directChildren );
43
-			$directChildren = $body->childNodes;
44
-		} else {
45
-			$directChildren = $item->childNodes;
46
-		}
42
+            $body = array_shift( $directChildren );
43
+            $directChildren = $body->childNodes;
44
+        } else {
45
+            $directChildren = $item->childNodes;
46
+        }
47 47
 
48
-		if ( $directChildren->length === 0 ) {
49
-			$mismatchDescription->appendText( 'having no children' );
50
-			return false;
51
-		}
48
+        if ( $directChildren->length === 0 ) {
49
+            $mismatchDescription->appendText( 'having no children' );
50
+            return false;
51
+        }
52 52
 
53
-		if ( !$this->matcher ) {
54
-			return $directChildren->length > 0;
55
-		}
53
+        if ( !$this->matcher ) {
54
+            return $directChildren->length > 0;
55
+        }
56 56
 
57
-		foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
58
-			if ( $this->matcher && $this->matcher->matches( $child ) ) {
59
-				return true;
60
-			}
61
-		}
57
+        foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
58
+            if ( $this->matcher && $this->matcher->matches( $child ) ) {
59
+                return true;
60
+            }
61
+        }
62 62
 
63
-		$mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
64
-		return false;
65
-	}
63
+        $mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
64
+        return false;
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	private $matcher;
15 15
 
16
-	public static function havingChild( Matcher $elementMatcher = null ) {
17
-		return new static( $elementMatcher );
16
+	public static function havingChild(Matcher $elementMatcher = null) {
17
+		return new static($elementMatcher);
18 18
 	}
19 19
 
20
-	public function __construct( Matcher $matcher = null ) {
21
-		parent::__construct( \DOMNode::class );
20
+	public function __construct(Matcher $matcher = null) {
21
+		parent::__construct(\DOMNode::class);
22 22
 		$this->matcher = $matcher;
23 23
 	}
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'having child ' );
27
-		if ( $this->matcher ) {
28
-			$description->appendDescriptionOf( $this->matcher );
25
+	public function describeTo(Description $description) {
26
+		$description->appendText('having child ');
27
+		if ($this->matcher) {
28
+			$description->appendDescriptionOf($this->matcher);
29 29
 		}
30 30
 	}
31 31
 
@@ -35,32 +35,32 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return bool
37 37
 	 */
38
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
-		if ( $item instanceof \DOMDocument ) {
40
-			$directChildren = iterator_to_array( $item->documentElement->childNodes );
38
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
39
+		if ($item instanceof \DOMDocument) {
40
+			$directChildren = iterator_to_array($item->documentElement->childNodes);
41 41
 
42
-			$body = array_shift( $directChildren );
42
+			$body = array_shift($directChildren);
43 43
 			$directChildren = $body->childNodes;
44 44
 		} else {
45 45
 			$directChildren = $item->childNodes;
46 46
 		}
47 47
 
48
-		if ( $directChildren->length === 0 ) {
49
-			$mismatchDescription->appendText( 'having no children' );
48
+		if ($directChildren->length === 0) {
49
+			$mismatchDescription->appendText('having no children');
50 50
 			return false;
51 51
 		}
52 52
 
53
-		if ( !$this->matcher ) {
53
+		if (!$this->matcher) {
54 54
 			return $directChildren->length > 0;
55 55
 		}
56 56
 
57
-		foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
58
-			if ( $this->matcher && $this->matcher->matches( $child ) ) {
57
+		foreach (new XmlNodeRecursiveIterator($directChildren) as $child) {
58
+			if ($this->matcher && $this->matcher->matches($child)) {
59 59
 				return true;
60 60
 			}
61 61
 		}
62 62
 
63
-		$mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
63
+		$mismatchDescription->appendText('having no children ')->appendDescriptionOf($this->matcher);
64 64
 		return false;
65 65
 	}
66 66
 
Please login to merge, or discard this patch.
src/TagMatcher.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 abstract class TagMatcher extends TypeSafeDiagnosingMatcher {
8 8
 
9
-	public function __construct() {
10
-		parent::__construct( self::TYPE_OBJECT, \DOMElement::class );
11
-	}
9
+    public function __construct() {
10
+        parent::__construct( self::TYPE_OBJECT, \DOMElement::class );
11
+    }
12 12
 
13 13
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 abstract class TagMatcher extends TypeSafeDiagnosingMatcher {
8 8
 
9 9
 	public function __construct() {
10
-		parent::__construct( self::TYPE_OBJECT, \DOMElement::class );
10
+		parent::__construct(self::TYPE_OBJECT, \DOMElement::class);
11 11
 	}
12 12
 
13 13
 }
Please login to merge, or discard this patch.
src/RootElementMatcher.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -8,62 +8,62 @@
 block discarded – undo
8 8
 
9 9
 class RootElementMatcher extends TypeSafeDiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher
13
-	 */
14
-	private $tagMatcher;
11
+    /**
12
+     * @var Matcher
13
+     */
14
+    private $tagMatcher;
15 15
 
16
-	/**
17
-	 * @param Matcher|null $tagMatcher
18
-	 *
19
-	 * @return static
20
-	 */
21
-	public static function havingRootElement( Matcher $tagMatcher = null ) {
22
-		return new static( $tagMatcher );
23
-	}
16
+    /**
17
+     * @param Matcher|null $tagMatcher
18
+     *
19
+     * @return static
20
+     */
21
+    public static function havingRootElement( Matcher $tagMatcher = null ) {
22
+        return new static( $tagMatcher );
23
+    }
24 24
 
25
-	public function __construct( Matcher $tagMatcher = null ) {
26
-		parent::__construct( self::TYPE_OBJECT, \DOMDocument::class );
27
-		$this->tagMatcher = $tagMatcher;
28
-	}
25
+    public function __construct( Matcher $tagMatcher = null ) {
26
+        parent::__construct( self::TYPE_OBJECT, \DOMDocument::class );
27
+        $this->tagMatcher = $tagMatcher;
28
+    }
29 29
 
30
-	public function describeTo( Description $description ) {
31
-		$description->appendText( 'having root element ' );
32
-		if ( $this->tagMatcher ) {
33
-			$description->appendDescriptionOf( $this->tagMatcher );
34
-		}
35
-	}
30
+    public function describeTo( Description $description ) {
31
+        $description->appendText( 'having root element ' );
32
+        if ( $this->tagMatcher ) {
33
+            $description->appendDescriptionOf( $this->tagMatcher );
34
+        }
35
+    }
36 36
 
37
-	/**
38
-	 * @param \DOMDocument $item
39
-	 * @param Description $mismatchDescription
40
-	 *
41
-	 * @return bool
42
-	 */
43
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
44
-		$DOMNodeList = iterator_to_array( $item->documentElement->childNodes );
37
+    /**
38
+     * @param \DOMDocument $item
39
+     * @param Description $mismatchDescription
40
+     *
41
+     * @return bool
42
+     */
43
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
44
+        $DOMNodeList = iterator_to_array( $item->documentElement->childNodes );
45 45
 
46
-		$body = array_shift( $DOMNodeList );
47
-		$DOMNodeList = iterator_to_array( $body->childNodes );
48
-		if ( count( $DOMNodeList ) > 1 ) {
49
-			// TODO Test this description
50
-			$mismatchDescription->appendText( 'having ' . count( $DOMNodeList ) . ' root elements ' );
51
-			return false;
52
-		}
46
+        $body = array_shift( $DOMNodeList );
47
+        $DOMNodeList = iterator_to_array( $body->childNodes );
48
+        if ( count( $DOMNodeList ) > 1 ) {
49
+            // TODO Test this description
50
+            $mismatchDescription->appendText( 'having ' . count( $DOMNodeList ) . ' root elements ' );
51
+            return false;
52
+        }
53 53
 
54
-		$target = array_shift( $DOMNodeList );
55
-		if ( !$target ) {
56
-			// TODO Reproduce?
57
-			$mismatchDescription->appendText( 'having no root elements ' );
58
-			return false;
59
-		}
60
-		if ( $this->tagMatcher ) {
61
-			$mismatchDescription->appendText( 'root element ' );
62
-			$this->tagMatcher->describeMismatch( $target, $mismatchDescription );
63
-			return $this->tagMatcher->matches( $target );
64
-		}
54
+        $target = array_shift( $DOMNodeList );
55
+        if ( !$target ) {
56
+            // TODO Reproduce?
57
+            $mismatchDescription->appendText( 'having no root elements ' );
58
+            return false;
59
+        }
60
+        if ( $this->tagMatcher ) {
61
+            $mismatchDescription->appendText( 'root element ' );
62
+            $this->tagMatcher->describeMismatch( $target, $mismatchDescription );
63
+            return $this->tagMatcher->matches( $target );
64
+        }
65 65
 
66
-		return (bool)$target;
67
-	}
66
+        return (bool)$target;
67
+    }
68 68
 
69 69
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return static
20 20
 	 */
21
-	public static function havingRootElement( Matcher $tagMatcher = null ) {
22
-		return new static( $tagMatcher );
21
+	public static function havingRootElement(Matcher $tagMatcher = null) {
22
+		return new static($tagMatcher);
23 23
 	}
24 24
 
25
-	public function __construct( Matcher $tagMatcher = null ) {
26
-		parent::__construct( self::TYPE_OBJECT, \DOMDocument::class );
25
+	public function __construct(Matcher $tagMatcher = null) {
26
+		parent::__construct(self::TYPE_OBJECT, \DOMDocument::class);
27 27
 		$this->tagMatcher = $tagMatcher;
28 28
 	}
29 29
 
30
-	public function describeTo( Description $description ) {
31
-		$description->appendText( 'having root element ' );
32
-		if ( $this->tagMatcher ) {
33
-			$description->appendDescriptionOf( $this->tagMatcher );
30
+	public function describeTo(Description $description) {
31
+		$description->appendText('having root element ');
32
+		if ($this->tagMatcher) {
33
+			$description->appendDescriptionOf($this->tagMatcher);
34 34
 		}
35 35
 	}
36 36
 
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return bool
42 42
 	 */
43
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
44
-		$DOMNodeList = iterator_to_array( $item->documentElement->childNodes );
43
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
44
+		$DOMNodeList = iterator_to_array($item->documentElement->childNodes);
45 45
 
46
-		$body = array_shift( $DOMNodeList );
47
-		$DOMNodeList = iterator_to_array( $body->childNodes );
48
-		if ( count( $DOMNodeList ) > 1 ) {
46
+		$body = array_shift($DOMNodeList);
47
+		$DOMNodeList = iterator_to_array($body->childNodes);
48
+		if (count($DOMNodeList) > 1) {
49 49
 			// TODO Test this description
50
-			$mismatchDescription->appendText( 'having ' . count( $DOMNodeList ) . ' root elements ' );
50
+			$mismatchDescription->appendText('having ' . count($DOMNodeList) . ' root elements ');
51 51
 			return false;
52 52
 		}
53 53
 
54
-		$target = array_shift( $DOMNodeList );
55
-		if ( !$target ) {
54
+		$target = array_shift($DOMNodeList);
55
+		if (!$target) {
56 56
 			// TODO Reproduce?
57
-			$mismatchDescription->appendText( 'having no root elements ' );
57
+			$mismatchDescription->appendText('having no root elements ');
58 58
 			return false;
59 59
 		}
60
-		if ( $this->tagMatcher ) {
61
-			$mismatchDescription->appendText( 'root element ' );
62
-			$this->tagMatcher->describeMismatch( $target, $mismatchDescription );
63
-			return $this->tagMatcher->matches( $target );
60
+		if ($this->tagMatcher) {
61
+			$mismatchDescription->appendText('root element ');
62
+			$this->tagMatcher->describeMismatch($target, $mismatchDescription);
63
+			return $this->tagMatcher->matches($target);
64 64
 		}
65 65
 
66 66
 		return (bool)$target;
Please login to merge, or discard this patch.
src/DirectChildElementMatcher.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,65 +8,65 @@
 block discarded – undo
8 8
 
9 9
 class DirectChildElementMatcher extends TypeSafeDiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @var Matcher
13
-	 */
14
-	private $matcher;
15
-
16
-	public static function havingDirectChild( Matcher $elementMatcher = null ) {
17
-		return new static( $elementMatcher );
18
-	}
19
-
20
-	public function __construct( Matcher $matcher = null ) {
21
-		parent::__construct( \DOMNode::class );
22
-		$this->matcher = $matcher;
23
-	}
24
-
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'having direct child ' );
27
-		if ( $this->matcher ) {
28
-			$description->appendDescriptionOf( $this->matcher );
29
-		}
30
-	}
31
-
32
-	/**
33
-	 * @param \DOMDocument|\DOMNode $item
34
-	 * @param Description $mismatchDescription
35
-	 *
36
-	 * @return bool
37
-	 */
38
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
-		if ( $item instanceof \DOMDocument ) {
40
-			$directChildren = iterator_to_array( $item->documentElement->childNodes );
41
-
42
-			$body = array_shift( $directChildren );
43
-			$directChildren = $body->childNodes;
44
-		} else {
45
-			$directChildren = $item->childNodes;
46
-		}
47
-
48
-		if ( $directChildren->length === 0 ) {
49
-			$mismatchDescription->appendText( 'with no direct children' );
50
-			return false;
51
-		}
52
-
53
-		$childWord = $directChildren->length === 1 ? 'child' : 'children';
54
-
55
-		$mismatchDescription->appendText( "with direct {$childWord} " );
56
-
57
-		if ( !$this->matcher ) {
58
-			return count( $directChildren ) !== 0;
59
-		}
60
-
61
-		foreach ( $directChildren as $child ) {
62
-			if ( $this->matcher && $this->matcher->matches( $child ) ) {
63
-				return true;
64
-			}
65
-		}
66
-
67
-		$this->matcher->describeMismatch( $child, $mismatchDescription );
68
-
69
-		return false;
70
-	}
11
+    /**
12
+     * @var Matcher
13
+     */
14
+    private $matcher;
15
+
16
+    public static function havingDirectChild( Matcher $elementMatcher = null ) {
17
+        return new static( $elementMatcher );
18
+    }
19
+
20
+    public function __construct( Matcher $matcher = null ) {
21
+        parent::__construct( \DOMNode::class );
22
+        $this->matcher = $matcher;
23
+    }
24
+
25
+    public function describeTo( Description $description ) {
26
+        $description->appendText( 'having direct child ' );
27
+        if ( $this->matcher ) {
28
+            $description->appendDescriptionOf( $this->matcher );
29
+        }
30
+    }
31
+
32
+    /**
33
+     * @param \DOMDocument|\DOMNode $item
34
+     * @param Description $mismatchDescription
35
+     *
36
+     * @return bool
37
+     */
38
+    protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
+        if ( $item instanceof \DOMDocument ) {
40
+            $directChildren = iterator_to_array( $item->documentElement->childNodes );
41
+
42
+            $body = array_shift( $directChildren );
43
+            $directChildren = $body->childNodes;
44
+        } else {
45
+            $directChildren = $item->childNodes;
46
+        }
47
+
48
+        if ( $directChildren->length === 0 ) {
49
+            $mismatchDescription->appendText( 'with no direct children' );
50
+            return false;
51
+        }
52
+
53
+        $childWord = $directChildren->length === 1 ? 'child' : 'children';
54
+
55
+        $mismatchDescription->appendText( "with direct {$childWord} " );
56
+
57
+        if ( !$this->matcher ) {
58
+            return count( $directChildren ) !== 0;
59
+        }
60
+
61
+        foreach ( $directChildren as $child ) {
62
+            if ( $this->matcher && $this->matcher->matches( $child ) ) {
63
+                return true;
64
+            }
65
+        }
66
+
67
+        $this->matcher->describeMismatch( $child, $mismatchDescription );
68
+
69
+        return false;
70
+    }
71 71
 
72 72
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	private $matcher;
15 15
 
16
-	public static function havingDirectChild( Matcher $elementMatcher = null ) {
17
-		return new static( $elementMatcher );
16
+	public static function havingDirectChild(Matcher $elementMatcher = null) {
17
+		return new static($elementMatcher);
18 18
 	}
19 19
 
20
-	public function __construct( Matcher $matcher = null ) {
21
-		parent::__construct( \DOMNode::class );
20
+	public function __construct(Matcher $matcher = null) {
21
+		parent::__construct(\DOMNode::class);
22 22
 		$this->matcher = $matcher;
23 23
 	}
24 24
 
25
-	public function describeTo( Description $description ) {
26
-		$description->appendText( 'having direct child ' );
27
-		if ( $this->matcher ) {
28
-			$description->appendDescriptionOf( $this->matcher );
25
+	public function describeTo(Description $description) {
26
+		$description->appendText('having direct child ');
27
+		if ($this->matcher) {
28
+			$description->appendDescriptionOf($this->matcher);
29 29
 		}
30 30
 	}
31 31
 
@@ -35,36 +35,36 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return bool
37 37
 	 */
38
-	protected function matchesSafelyWithDiagnosticDescription( $item, Description $mismatchDescription ) {
39
-		if ( $item instanceof \DOMDocument ) {
40
-			$directChildren = iterator_to_array( $item->documentElement->childNodes );
38
+	protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription) {
39
+		if ($item instanceof \DOMDocument) {
40
+			$directChildren = iterator_to_array($item->documentElement->childNodes);
41 41
 
42
-			$body = array_shift( $directChildren );
42
+			$body = array_shift($directChildren);
43 43
 			$directChildren = $body->childNodes;
44 44
 		} else {
45 45
 			$directChildren = $item->childNodes;
46 46
 		}
47 47
 
48
-		if ( $directChildren->length === 0 ) {
49
-			$mismatchDescription->appendText( 'with no direct children' );
48
+		if ($directChildren->length === 0) {
49
+			$mismatchDescription->appendText('with no direct children');
50 50
 			return false;
51 51
 		}
52 52
 
53 53
 		$childWord = $directChildren->length === 1 ? 'child' : 'children';
54 54
 
55
-		$mismatchDescription->appendText( "with direct {$childWord} " );
55
+		$mismatchDescription->appendText("with direct {$childWord} ");
56 56
 
57
-		if ( !$this->matcher ) {
58
-			return count( $directChildren ) !== 0;
57
+		if (!$this->matcher) {
58
+			return count($directChildren) !== 0;
59 59
 		}
60 60
 
61
-		foreach ( $directChildren as $child ) {
62
-			if ( $this->matcher && $this->matcher->matches( $child ) ) {
61
+		foreach ($directChildren as $child) {
62
+			if ($this->matcher && $this->matcher->matches($child)) {
63 63
 				return true;
64 64
 			}
65 65
 		}
66 66
 
67
-		$this->matcher->describeMismatch( $child, $mismatchDescription );
67
+		$this->matcher->describeMismatch($child, $mismatchDescription);
68 68
 
69 69
 		return false;
70 70
 	}
Please login to merge, or discard this patch.
src/XmlNodeRecursiveIterator.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,27 +4,27 @@
 block discarded – undo
4 4
 
5 5
 class XmlNodeRecursiveIterator extends \ArrayIterator {
6 6
 
7
-	public function __construct( \DOMNodeList $nodeList ) {
8
-		$queue = $this->addElementsToQueue( [], $nodeList );
9
-		parent::__construct( $queue );
10
-	}
7
+    public function __construct( \DOMNodeList $nodeList ) {
8
+        $queue = $this->addElementsToQueue( [], $nodeList );
9
+        parent::__construct( $queue );
10
+    }
11 11
 
12
-	/**
13
-	 * @param \DOMNode[] $queue
14
-	 * @param \DOMNodeList $nodeList
15
-	 *
16
-	 * @return \DOMNode[] New queue
17
-	 */
18
-	private function addElementsToQueue( array $queue, \DOMNodeList $nodeList ) {
19
-		/** @var \DOMNode $node */
20
-		foreach ( $nodeList as $node ) {
21
-			$queue[] = $node;
22
-			if ( $node->childNodes !== null ) {
23
-				$queue = $this->addElementsToQueue( $queue, $node->childNodes );
24
-			}
25
-		}
12
+    /**
13
+     * @param \DOMNode[] $queue
14
+     * @param \DOMNodeList $nodeList
15
+     *
16
+     * @return \DOMNode[] New queue
17
+     */
18
+    private function addElementsToQueue( array $queue, \DOMNodeList $nodeList ) {
19
+        /** @var \DOMNode $node */
20
+        foreach ( $nodeList as $node ) {
21
+            $queue[] = $node;
22
+            if ( $node->childNodes !== null ) {
23
+                $queue = $this->addElementsToQueue( $queue, $node->childNodes );
24
+            }
25
+        }
26 26
 
27
-		return $queue;
28
-	}
27
+        return $queue;
28
+    }
29 29
 
30 30
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 
5 5
 class XmlNodeRecursiveIterator extends \ArrayIterator {
6 6
 
7
-	public function __construct( \DOMNodeList $nodeList ) {
8
-		$queue = $this->addElementsToQueue( [], $nodeList );
9
-		parent::__construct( $queue );
7
+	public function __construct(\DOMNodeList $nodeList) {
8
+		$queue = $this->addElementsToQueue([], $nodeList);
9
+		parent::__construct($queue);
10 10
 	}
11 11
 
12 12
 	/**
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @return \DOMNode[] New queue
17 17
 	 */
18
-	private function addElementsToQueue( array $queue, \DOMNodeList $nodeList ) {
18
+	private function addElementsToQueue(array $queue, \DOMNodeList $nodeList) {
19 19
 		/** @var \DOMNode $node */
20
-		foreach ( $nodeList as $node ) {
20
+		foreach ($nodeList as $node) {
21 21
 			$queue[] = $node;
22
-			if ( $node->childNodes !== null ) {
23
-				$queue = $this->addElementsToQueue( $queue, $node->childNodes );
22
+			if ($node->childNodes !== null) {
23
+				$queue = $this->addElementsToQueue($queue, $node->childNodes);
24 24
 			}
25 25
 		}
26 26
 
Please login to merge, or discard this patch.
src/HtmlMatcher.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -8,99 +8,99 @@
 block discarded – undo
8 8
 
9 9
 class HtmlMatcher extends DiagnosingMatcher {
10 10
 
11
-	/**
12
-	 * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
13
-	 * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257
14
-	 */
15
-	const XML_UNKNOWN_TAG_ERROR_CODE = 801;
16
-
17
-	/**
18
-	 * @var Matcher
19
-	 */
20
-	private $elementMatcher;
21
-
22
-	/**
23
-	 * @param Matcher $elementMatcher
24
-	 *
25
-	 * @return self
26
-	 */
27
-	public static function htmlPiece( Matcher $elementMatcher = null ) {
28
-		return new static( $elementMatcher );
29
-	}
30
-
31
-	private function __construct( Matcher $elementMatcher = null ) {
32
-		$this->elementMatcher = $elementMatcher;
33
-	}
34
-
35
-	public function describeTo( Description $description ) {
36
-		$description->appendText( 'valid html piece ' );
37
-		if ( $this->elementMatcher ) {
38
-			$description->appendDescriptionOf( $this->elementMatcher );
39
-		}
40
-	}
41
-
42
-	protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
43
-		$internalErrors = libxml_use_internal_errors( true );
44
-		$document = new \DOMDocument();
45
-
46
-		$html = $this->escapeScriptTagContents( $html );
47
-
48
-		if ( [email protected]$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
49
-			$mismatchDescription->appendText( 'there was some parsing error' );
50
-			return false;
51
-		}
52
-
53
-		$errors = libxml_get_errors();
54
-		libxml_clear_errors();
55
-		libxml_use_internal_errors( $internalErrors );
56
-
57
-		$result = true;
58
-		/** @var \LibXMLError $error */
59
-		foreach ( $errors as $error ) {
60
-			if ( $this->isUnknownTagError( $error ) ) {
61
-				continue;
62
-			}
63
-
64
-			$mismatchDescription->appendText( 'there was parsing error: ' )
65
-				->appendText( trim( $error->message ) )
66
-				->appendText( ' on line ' )
67
-				->appendText( $error->line );
68
-			$result = false;
69
-		}
70
-
71
-		if ( $result === false ) {
72
-			return $result;
73
-		}
74
-		$mismatchDescription->appendText( 'valid html piece ' );
75
-
76
-		if ( $this->elementMatcher ) {
77
-			$result = $this->elementMatcher->matches( $document );
78
-			$this->elementMatcher->describeMismatch( $document, $mismatchDescription );
79
-		}
80
-
81
-		$mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
82
-
83
-		return $result;
84
-	}
85
-
86
-	/**
87
-	 * @param \LibXMLError $error
88
-	 *
89
-	 * @return bool
90
-	 */
91
-	private function isUnknownTagError( \LibXMLError $error ) {
92
-		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
93
-	}
94
-
95
-	/**
96
-	 * @param string $html
97
-	 *
98
-	 * @return string HTML
99
-	 */
100
-	private function escapeScriptTagContents( $html ) {
101
-		return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', function ( $matches ) {
102
-			return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
103
-		}, $html );
104
-	}
11
+    /**
12
+     * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
13
+     * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257
14
+     */
15
+    const XML_UNKNOWN_TAG_ERROR_CODE = 801;
16
+
17
+    /**
18
+     * @var Matcher
19
+     */
20
+    private $elementMatcher;
21
+
22
+    /**
23
+     * @param Matcher $elementMatcher
24
+     *
25
+     * @return self
26
+     */
27
+    public static function htmlPiece( Matcher $elementMatcher = null ) {
28
+        return new static( $elementMatcher );
29
+    }
30
+
31
+    private function __construct( Matcher $elementMatcher = null ) {
32
+        $this->elementMatcher = $elementMatcher;
33
+    }
34
+
35
+    public function describeTo( Description $description ) {
36
+        $description->appendText( 'valid html piece ' );
37
+        if ( $this->elementMatcher ) {
38
+            $description->appendDescriptionOf( $this->elementMatcher );
39
+        }
40
+    }
41
+
42
+    protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
43
+        $internalErrors = libxml_use_internal_errors( true );
44
+        $document = new \DOMDocument();
45
+
46
+        $html = $this->escapeScriptTagContents( $html );
47
+
48
+        if ( [email protected]$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
49
+            $mismatchDescription->appendText( 'there was some parsing error' );
50
+            return false;
51
+        }
52
+
53
+        $errors = libxml_get_errors();
54
+        libxml_clear_errors();
55
+        libxml_use_internal_errors( $internalErrors );
56
+
57
+        $result = true;
58
+        /** @var \LibXMLError $error */
59
+        foreach ( $errors as $error ) {
60
+            if ( $this->isUnknownTagError( $error ) ) {
61
+                continue;
62
+            }
63
+
64
+            $mismatchDescription->appendText( 'there was parsing error: ' )
65
+                ->appendText( trim( $error->message ) )
66
+                ->appendText( ' on line ' )
67
+                ->appendText( $error->line );
68
+            $result = false;
69
+        }
70
+
71
+        if ( $result === false ) {
72
+            return $result;
73
+        }
74
+        $mismatchDescription->appendText( 'valid html piece ' );
75
+
76
+        if ( $this->elementMatcher ) {
77
+            $result = $this->elementMatcher->matches( $document );
78
+            $this->elementMatcher->describeMismatch( $document, $mismatchDescription );
79
+        }
80
+
81
+        $mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
82
+
83
+        return $result;
84
+    }
85
+
86
+    /**
87
+     * @param \LibXMLError $error
88
+     *
89
+     * @return bool
90
+     */
91
+    private function isUnknownTagError( \LibXMLError $error ) {
92
+        return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
93
+    }
94
+
95
+    /**
96
+     * @param string $html
97
+     *
98
+     * @return string HTML
99
+     */
100
+    private function escapeScriptTagContents( $html ) {
101
+        return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', function ( $matches ) {
102
+            return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
103
+        }, $html );
104
+    }
105 105
 
106 106
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,61 +24,61 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @return self
26 26
 	 */
27
-	public static function htmlPiece( Matcher $elementMatcher = null ) {
28
-		return new static( $elementMatcher );
27
+	public static function htmlPiece(Matcher $elementMatcher = null) {
28
+		return new static($elementMatcher);
29 29
 	}
30 30
 
31
-	private function __construct( Matcher $elementMatcher = null ) {
31
+	private function __construct(Matcher $elementMatcher = null) {
32 32
 		$this->elementMatcher = $elementMatcher;
33 33
 	}
34 34
 
35
-	public function describeTo( Description $description ) {
36
-		$description->appendText( 'valid html piece ' );
37
-		if ( $this->elementMatcher ) {
38
-			$description->appendDescriptionOf( $this->elementMatcher );
35
+	public function describeTo(Description $description) {
36
+		$description->appendText('valid html piece ');
37
+		if ($this->elementMatcher) {
38
+			$description->appendDescriptionOf($this->elementMatcher);
39 39
 		}
40 40