GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( d6ed85...1d3946 )
by
unknown
06:08 queued 18s
created
src/DirectChildElementMatcher.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -10,64 +10,64 @@
 block discarded – undo
10 10
 
11 11
 class DirectChildElementMatcher extends TypeSafeDiagnosingMatcher {
12 12
 
13
-	/**
14
-	 * @var Matcher|null
15
-	 */
16
-	private $matcher;
17
-
18
-	public static function havingDirectChild( ?Matcher $elementMatcher = null ) {
19
-		return new static( $elementMatcher );
20
-	}
21
-
22
-	public function __construct( ?Matcher $matcher = null ) {
23
-		parent::__construct( DOMNode::class );
24
-		$this->matcher = $matcher;
25
-	}
26
-
27
-	public function describeTo( Description $description ) {
28
-		$description->appendText( 'having direct child ' );
29
-		if ( $this->matcher ) {
30
-			$description->appendDescriptionOf( $this->matcher );
31
-		}
32
-	}
33
-
34
-	/**
35
-	 * @param DOMDocument|DOMNode $item
36
-	 * @param Description $mismatchDescription
37
-	 *
38
-	 * @return bool
39
-	 */
40
-	protected function matchesSafelyWithDiagnosticDescription(
41
-		$item, Description $mismatchDescription
42
-	) {
43
-		if ( $item instanceof DOMDocument ) {
44
-			$item = $item->documentElement->childNodes->item( 0 );
45
-		}
46
-		$directChildren = $item->childNodes;
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 $directChildren->length !== 0;
59
-		}
60
-
61
-		$child = null;
62
-		foreach ( $directChildren as $child ) {
63
-			if ( $this->matcher->matches( $child ) ) {
64
-				return true;
65
-			}
66
-		}
67
-
68
-		$this->matcher->describeMismatch( $child, $mismatchDescription );
69
-
70
-		return false;
71
-	}
13
+    /**
14
+     * @var Matcher|null
15
+     */
16
+    private $matcher;
17
+
18
+    public static function havingDirectChild( ?Matcher $elementMatcher = null ) {
19
+        return new static( $elementMatcher );
20
+    }
21
+
22
+    public function __construct( ?Matcher $matcher = null ) {
23
+        parent::__construct( DOMNode::class );
24
+        $this->matcher = $matcher;
25
+    }
26
+
27
+    public function describeTo( Description $description ) {
28
+        $description->appendText( 'having direct child ' );
29
+        if ( $this->matcher ) {
30
+            $description->appendDescriptionOf( $this->matcher );
31
+        }
32
+    }
33
+
34
+    /**
35
+     * @param DOMDocument|DOMNode $item
36
+     * @param Description $mismatchDescription
37
+     *
38
+     * @return bool
39
+     */
40
+    protected function matchesSafelyWithDiagnosticDescription(
41
+        $item, Description $mismatchDescription
42
+    ) {
43
+        if ( $item instanceof DOMDocument ) {
44
+            $item = $item->documentElement->childNodes->item( 0 );
45
+        }
46
+        $directChildren = $item->childNodes;
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 $directChildren->length !== 0;
59
+        }
60
+
61
+        $child = null;
62
+        foreach ( $directChildren as $child ) {
63
+            if ( $this->matcher->matches( $child ) ) {
64
+                return true;
65
+            }
66
+        }
67
+
68
+        $this->matcher->describeMismatch( $child, $mismatchDescription );
69
+
70
+        return false;
71
+    }
72 72
 
73 73
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	private $matcher;
17 17
 
18
-	public static function havingDirectChild( ?Matcher $elementMatcher = null ) {
19
-		return new static( $elementMatcher );
18
+	public static function havingDirectChild(?Matcher $elementMatcher = null) {
19
+		return new static($elementMatcher);
20 20
 	}
21 21
 
22
-	public function __construct( ?Matcher $matcher = null ) {
23
-		parent::__construct( DOMNode::class );
22
+	public function __construct(?Matcher $matcher = null) {
23
+		parent::__construct(DOMNode::class);
24 24
 		$this->matcher = $matcher;
25 25
 	}
26 26
 
27
-	public function describeTo( Description $description ) {
28
-		$description->appendText( 'having direct child ' );
29
-		if ( $this->matcher ) {
30
-			$description->appendDescriptionOf( $this->matcher );
27
+	public function describeTo(Description $description) {
28
+		$description->appendText('having direct child ');
29
+		if ($this->matcher) {
30
+			$description->appendDescriptionOf($this->matcher);
31 31
 		}
32 32
 	}
33 33
 
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
 	protected function matchesSafelyWithDiagnosticDescription(
41 41
 		$item, Description $mismatchDescription
42 42
 	) {
43
-		if ( $item instanceof DOMDocument ) {
44
-			$item = $item->documentElement->childNodes->item( 0 );
43
+		if ($item instanceof DOMDocument) {
44
+			$item = $item->documentElement->childNodes->item(0);
45 45
 		}
46 46
 		$directChildren = $item->childNodes;
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 ) {
57
+		if (!$this->matcher) {
58 58
 			return $directChildren->length !== 0;
59 59
 		}
60 60
 
61 61
 		$child = null;
62
-		foreach ( $directChildren as $child ) {
63
-			if ( $this->matcher->matches( $child ) ) {
62
+		foreach ($directChildren as $child) {
63
+			if ($this->matcher->matches($child)) {
64 64
 				return true;
65 65
 			}
66 66
 		}
67 67
 
68
-		$this->matcher->describeMismatch( $child, $mismatchDescription );
68
+		$this->matcher->describeMismatch($child, $mismatchDescription);
69 69
 
70 70
 		return false;
71 71
 	}
Please login to merge, or discard this patch.
src/HtmlMatcher.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -10,106 +10,106 @@
 block discarded – undo
10 10
 
11 11
 class HtmlMatcher extends DiagnosingMatcher {
12 12
 
13
-	/**
14
-	 * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
15
-	 * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257
16
-	 */
17
-	private const XML_UNKNOWN_TAG_ERROR_CODE = 801;
18
-
19
-	/**
20
-	 * @var Matcher|null
21
-	 */
22
-	private $elementMatcher;
23
-
24
-	/**
25
-	 * @param Matcher|null $elementMatcher
26
-	 *
27
-	 * @return self
28
-	 */
29
-	public static function htmlPiece( ?Matcher $elementMatcher = null ) {
30
-		return new static( $elementMatcher );
31
-	}
32
-
33
-	private function __construct( ?Matcher $elementMatcher = null ) {
34
-		$this->elementMatcher = $elementMatcher;
35
-	}
36
-
37
-	public function describeTo( Description $description ) {
38
-		$description->appendText( 'valid html piece ' );
39
-		if ( $this->elementMatcher ) {
40
-			$description->appendDescriptionOf( $this->elementMatcher );
41
-		}
42
-	}
43
-
44
-	/**
45
-	 * @param string $html
46
-	 * @param Description $mismatchDescription
47
-	 *
48
-	 * @return bool
49
-	 */
50
-	protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
51
-		$internalErrors = libxml_use_internal_errors( true );
52
-		libxml_clear_errors();
53
-		$document = new DOMDocument();
54
-
55
-		$html = $this->escapeScriptTagContents( $html );
56
-
57
-		// phpcs:ignore Generic.PHP.NoSilencedErrors
58
-		if ( !@$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
59
-			$mismatchDescription->appendText( 'there was some parsing error' );
60
-			return false;
61
-		}
62
-
63
-		$errors = libxml_get_errors();
64
-		libxml_clear_errors();
65
-		libxml_use_internal_errors( $internalErrors );
66
-
67
-		$result = true;
68
-		foreach ( $errors as $error ) {
69
-			if ( $this->isUnknownTagError( $error ) ) {
70
-				continue;
71
-			}
72
-
73
-			$mismatchDescription->appendText( 'there was parsing error: ' )
74
-				->appendText( trim( $error->message ) )
75
-				->appendText( ' on line ' )
76
-				->appendText( (string)$error->line );
77
-			$result = false;
78
-		}
79
-
80
-		if ( !$result ) {
81
-			return false;
82
-		}
83
-		$mismatchDescription->appendText( 'valid html piece ' );
84
-
85
-		if ( $this->elementMatcher ) {
86
-			$result = $this->elementMatcher->matches( $document );
87
-			$this->elementMatcher->describeMismatch( $document, $mismatchDescription );
88
-		}
89
-
90
-		$mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
91
-
92
-		return $result;
93
-	}
94
-
95
-	/**
96
-	 * @param LibXMLError $error
97
-	 *
98
-	 * @return bool
99
-	 */
100
-	private function isUnknownTagError( LibXMLError $error ) {
101
-		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
102
-	}
103
-
104
-	/**
105
-	 * @param string $html
106
-	 *
107
-	 * @return string HTML
108
-	 */
109
-	private function escapeScriptTagContents( $html ) {
110
-		return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', static function ( $matches ) {
111
-			return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
112
-		}, $html );
113
-	}
13
+    /**
14
+     * @link http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors
15
+     * @link https://github.com/Chronic-Dev/libxml2/blob/683f296a905710ff285c28b8644ef3a3d8be9486/include/libxml/xmlerror.h#L257
16
+     */
17
+    private const XML_UNKNOWN_TAG_ERROR_CODE = 801;
18
+
19
+    /**
20
+     * @var Matcher|null
21
+     */
22
+    private $elementMatcher;
23
+
24
+    /**
25
+     * @param Matcher|null $elementMatcher
26
+     *
27
+     * @return self
28
+     */
29
+    public static function htmlPiece( ?Matcher $elementMatcher = null ) {
30
+        return new static( $elementMatcher );
31
+    }
32
+
33
+    private function __construct( ?Matcher $elementMatcher = null ) {
34
+        $this->elementMatcher = $elementMatcher;
35
+    }
36
+
37
+    public function describeTo( Description $description ) {
38
+        $description->appendText( 'valid html piece ' );
39
+        if ( $this->elementMatcher ) {
40
+            $description->appendDescriptionOf( $this->elementMatcher );
41
+        }
42
+    }
43
+
44
+    /**
45
+     * @param string $html
46
+     * @param Description $mismatchDescription
47
+     *
48
+     * @return bool
49
+     */
50
+    protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
51
+        $internalErrors = libxml_use_internal_errors( true );
52
+        libxml_clear_errors();
53
+        $document = new DOMDocument();
54
+
55
+        $html = $this->escapeScriptTagContents( $html );
56
+
57
+        // phpcs:ignore Generic.PHP.NoSilencedErrors
58
+        if ( !@$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
59
+            $mismatchDescription->appendText( 'there was some parsing error' );
60
+            return false;
61
+        }
62
+
63
+        $errors = libxml_get_errors();
64
+        libxml_clear_errors();
65
+        libxml_use_internal_errors( $internalErrors );
66
+
67
+        $result = true;
68
+        foreach ( $errors as $error ) {
69
+            if ( $this->isUnknownTagError( $error ) ) {
70
+                continue;
71
+            }
72
+
73
+            $mismatchDescription->appendText( 'there was parsing error: ' )
74
+                ->appendText( trim( $error->message ) )
75
+                ->appendText( ' on line ' )
76
+                ->appendText( (string)$error->line );
77
+            $result = false;
78
+        }
79
+
80
+        if ( !$result ) {
81
+            return false;
82
+        }
83
+        $mismatchDescription->appendText( 'valid html piece ' );
84
+
85
+        if ( $this->elementMatcher ) {
86
+            $result = $this->elementMatcher->matches( $document );
87
+            $this->elementMatcher->describeMismatch( $document, $mismatchDescription );
88
+        }
89
+
90
+        $mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
91
+
92
+        return $result;
93
+    }
94
+
95
+    /**
96
+     * @param LibXMLError $error
97
+     *
98
+     * @return bool
99
+     */
100
+    private function isUnknownTagError( LibXMLError $error ) {
101
+        return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
102
+    }
103
+
104
+    /**
105
+     * @param string $html
106
+     *
107
+     * @return string HTML
108
+     */
109
+    private function escapeScriptTagContents( $html ) {
110
+        return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', static function ( $matches ) {
111
+            return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
112
+        }, $html );
113
+    }
114 114
 
115 115
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return self
28 28
 	 */
29
-	public static function htmlPiece( ?Matcher $elementMatcher = null ) {
30
-		return new static( $elementMatcher );
29
+	public static function htmlPiece(?Matcher $elementMatcher = null) {
30
+		return new static($elementMatcher);
31 31
 	}
32 32
 
33
-	private function __construct( ?Matcher $elementMatcher = null ) {
33
+	private function __construct(?Matcher $elementMatcher = null) {
34 34
 		$this->elementMatcher = $elementMatcher;
35 35
 	}
36 36
 
37
-	public function describeTo( Description $description ) {
38
-		$description->appendText( 'valid html piece ' );
39
-		if ( $this->elementMatcher ) {
40
-			$description->appendDescriptionOf( $this->elementMatcher );
37
+	public function describeTo(Description $description) {
38
+		$description->appendText('valid html piece ');
39
+		if ($this->elementMatcher) {
40
+			$description->appendDescriptionOf($this->elementMatcher);
41 41
 		}
42 42
 	}
43 43
 
@@ -47,47 +47,47 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @return bool
49 49
 	 */
50
-	protected function matchesWithDiagnosticDescription( $html, Description $mismatchDescription ) {
51
-		$internalErrors = libxml_use_internal_errors( true );
50
+	protected function matchesWithDiagnosticDescription($html, Description $mismatchDescription) {
51
+		$internalErrors = libxml_use_internal_errors(true);
52 52
 		libxml_clear_errors();
53 53
 		$document = new DOMDocument();
54 54
 
55
-		$html = $this->escapeScriptTagContents( $html );
55
+		$html = $this->escapeScriptTagContents($html);
56 56
 
57 57
 		// phpcs:ignore Generic.PHP.NoSilencedErrors
58
-		if ( !@$document->loadHTML( mb_convert_encoding( $html, 'HTML-ENTITIES', 'UTF-8' ) ) ) {
59
-			$mismatchDescription->appendText( 'there was some parsing error' );
58
+		if (!@$document->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'))) {
59
+			$mismatchDescription->appendText('there was some parsing error');
60 60
 			return false;
61 61
 		}
62 62
 
63 63
 		$errors = libxml_get_errors();
64 64
 		libxml_clear_errors();
65
-		libxml_use_internal_errors( $internalErrors );
65
+		libxml_use_internal_errors($internalErrors);
66 66
 
67 67
 		$result = true;
68
-		foreach ( $errors as $error ) {
69
-			if ( $this->isUnknownTagError( $error ) ) {
68
+		foreach ($errors as $error) {
69
+			if ($this->isUnknownTagError($error)) {
70 70
 				continue;
71 71
 			}
72 72
 
73
-			$mismatchDescription->appendText( 'there was parsing error: ' )
74
-				->appendText( trim( $error->message ) )
75
-				->appendText( ' on line ' )
76
-				->appendText( (string)$error->line );
73
+			$mismatchDescription->appendText('there was parsing error: ')
74
+				->appendText(trim($error->message))
75
+				->appendText(' on line ')
76
+				->appendText((string)$error->line);
77 77
 			$result = false;
78 78
 		}
79 79
 
80
-		if ( !$result ) {
80
+		if (!$result) {
81 81
 			return false;
82 82
 		}
83
-		$mismatchDescription->appendText( 'valid html piece ' );
83
+		$mismatchDescription->appendText('valid html piece ');
84 84
 
85
-		if ( $this->elementMatcher ) {
86
-			$result = $this->elementMatcher->matches( $document );
87
-			$this->elementMatcher->describeMismatch( $document, $mismatchDescription );
85
+		if ($this->elementMatcher) {
86
+			$result = $this->elementMatcher->matches($document);
87
+			$this->elementMatcher->describeMismatch($document, $mismatchDescription);
88 88
 		}
89 89
 
90
-		$mismatchDescription->appendText( "\nActual html:\n" )->appendText( $html );
90
+		$mismatchDescription->appendText("\nActual html:\n")->appendText($html);
91 91
 
92 92
 		return $result;
93 93
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return bool
99 99
 	 */
100
-	private function isUnknownTagError( LibXMLError $error ) {
100
+	private function isUnknownTagError(LibXMLError $error) {
101 101
 		return $error->code === self::XML_UNKNOWN_TAG_ERROR_CODE;
102 102
 	}
103 103
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return string HTML
108 108
 	 */
109
-	private function escapeScriptTagContents( $html ) {
110
-		return preg_replace_callback( '#(<script.*>)(.*)(</script>)#isU', static function ( $matches ) {
111
-			return $matches[1] . str_replace( '</', '<\/', $matches[2] ) . $matches[3];
112
-		}, $html );
109
+	private function escapeScriptTagContents($html) {
110
+		return preg_replace_callback('#(<script.*>)(.*)(</script>)#isU', static function($matches) {
111
+			return $matches[1] . str_replace('</', '<\/', $matches[2]) . $matches[3];
112
+		}, $html);
113 113
 	}
114 114
 
115 115
 }
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
@@ -9,62 +9,62 @@
 block discarded – undo
9 9
 
10 10
 class RootElementMatcher extends TypeSafeDiagnosingMatcher {
11 11
 
12
-	/**
13
-	 * @var Matcher|null
14
-	 */
15
-	private $tagMatcher;
12
+    /**
13
+     * @var Matcher|null
14
+     */
15
+    private $tagMatcher;
16 16
 
17
-	/**
18
-	 * @param Matcher|null $tagMatcher
19
-	 *
20
-	 * @return static
21
-	 */
22
-	public static function havingRootElement( ?Matcher $tagMatcher = null ) {
23
-		return new static( $tagMatcher );
24
-	}
17
+    /**
18
+     * @param Matcher|null $tagMatcher
19
+     *
20
+     * @return static
21
+     */
22
+    public static function havingRootElement( ?Matcher $tagMatcher = null ) {
23
+        return new static( $tagMatcher );
24
+    }
25 25
 
26
-	public function __construct( ?Matcher $tagMatcher = null ) {
27
-		parent::__construct( self::TYPE_OBJECT, DOMDocument::class );
28
-		$this->tagMatcher = $tagMatcher;
29
-	}
26
+    public function __construct( ?Matcher $tagMatcher = null ) {
27
+        parent::__construct( self::TYPE_OBJECT, DOMDocument::class );
28
+        $this->tagMatcher = $tagMatcher;
29
+    }
30 30
 
31
-	public function describeTo( Description $description ) {
32
-		$description->appendText( 'having root element ' );
33
-		if ( $this->tagMatcher ) {
34
-			$description->appendDescriptionOf( $this->tagMatcher );
35
-		}
36
-	}
31
+    public function describeTo( Description $description ) {
32
+        $description->appendText( 'having root element ' );
33
+        if ( $this->tagMatcher ) {
34
+            $description->appendDescriptionOf( $this->tagMatcher );
35
+        }
36
+    }
37 37
 
38
-	/**
39
-	 * @param DOMDocument $item
40
-	 * @param Description $mismatchDescription
41
-	 *
42
-	 * @return bool
43
-	 */
44
-	protected function matchesSafelyWithDiagnosticDescription(
45
-		$item, Description $mismatchDescription
46
-	) {
47
-		$DOMNodeList = $item->documentElement->childNodes->item( 0 )->childNodes;
48
-		if ( $DOMNodeList->length > 1 ) {
49
-			// TODO Test this description
50
-			$mismatchDescription->appendText( 'having ' . $DOMNodeList->length . ' root elements ' );
51
-			return false;
52
-		}
38
+    /**
39
+     * @param DOMDocument $item
40
+     * @param Description $mismatchDescription
41
+     *
42
+     * @return bool
43
+     */
44
+    protected function matchesSafelyWithDiagnosticDescription(
45
+        $item, Description $mismatchDescription
46
+    ) {
47
+        $DOMNodeList = $item->documentElement->childNodes->item( 0 )->childNodes;
48
+        if ( $DOMNodeList->length > 1 ) {
49
+            // TODO Test this description
50
+            $mismatchDescription->appendText( 'having ' . $DOMNodeList->length . ' root elements ' );
51
+            return false;
52
+        }
53 53
 
54
-		$target = $DOMNodeList->item( 0 );
55
-		if ( !$target ) {
56
-			// TODO Reproduce?
57
-			$mismatchDescription->appendText( 'having no root elements ' );
58
-			return false;
59
-		}
54
+        $target = $DOMNodeList->item( 0 );
55
+        if ( !$target ) {
56
+            // TODO Reproduce?
57
+            $mismatchDescription->appendText( 'having no root elements ' );
58
+            return false;
59
+        }
60 60
 
61
-		if ( $this->tagMatcher ) {
62
-			$mismatchDescription->appendText( 'root element ' );
63
-			$this->tagMatcher->describeMismatch( $target, $mismatchDescription );
64
-			return $this->tagMatcher->matches( $target );
65
-		}
61
+        if ( $this->tagMatcher ) {
62
+            $mismatchDescription->appendText( 'root element ' );
63
+            $this->tagMatcher->describeMismatch( $target, $mismatchDescription );
64
+            return $this->tagMatcher->matches( $target );
65
+        }
66 66
 
67
-		return true;
68
-	}
67
+        return true;
68
+    }
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return static
21 21
 	 */
22
-	public static function havingRootElement( ?Matcher $tagMatcher = null ) {
23
-		return new static( $tagMatcher );
22
+	public static function havingRootElement(?Matcher $tagMatcher = null) {
23
+		return new static($tagMatcher);
24 24
 	}
25 25
 
26
-	public function __construct( ?Matcher $tagMatcher = null ) {
27
-		parent::__construct( self::TYPE_OBJECT, DOMDocument::class );
26
+	public function __construct(?Matcher $tagMatcher = null) {
27
+		parent::__construct(self::TYPE_OBJECT, DOMDocument::class);
28 28
 		$this->tagMatcher = $tagMatcher;
29 29
 	}
30 30
 
31
-	public function describeTo( Description $description ) {
32
-		$description->appendText( 'having root element ' );
33
-		if ( $this->tagMatcher ) {
34
-			$description->appendDescriptionOf( $this->tagMatcher );
31
+	public function describeTo(Description $description) {
32
+		$description->appendText('having root element ');
33
+		if ($this->tagMatcher) {
34
+			$description->appendDescriptionOf($this->tagMatcher);
35 35
 		}
36 36
 	}
37 37
 
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
 	protected function matchesSafelyWithDiagnosticDescription(
45 45
 		$item, Description $mismatchDescription
46 46
 	) {
47
-		$DOMNodeList = $item->documentElement->childNodes->item( 0 )->childNodes;
48
-		if ( $DOMNodeList->length > 1 ) {
47
+		$DOMNodeList = $item->documentElement->childNodes->item(0)->childNodes;
48
+		if ($DOMNodeList->length > 1) {
49 49
 			// TODO Test this description
50
-			$mismatchDescription->appendText( 'having ' . $DOMNodeList->length . ' root elements ' );
50
+			$mismatchDescription->appendText('having ' . $DOMNodeList->length . ' root elements ');
51 51
 			return false;
52 52
 		}
53 53
 
54
-		$target = $DOMNodeList->item( 0 );
55
-		if ( !$target ) {
54
+		$target = $DOMNodeList->item(0);
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 60
 
61
-		if ( $this->tagMatcher ) {
62
-			$mismatchDescription->appendText( 'root element ' );
63
-			$this->tagMatcher->describeMismatch( $target, $mismatchDescription );
64
-			return $this->tagMatcher->matches( $target );
61
+		if ($this->tagMatcher) {
62
+			$mismatchDescription->appendText('root element ');
63
+			$this->tagMatcher->describeMismatch($target, $mismatchDescription);
64
+			return $this->tagMatcher->matches($target);
65 65
 		}
66 66
 
67 67
 		return true;
Please login to merge, or discard this patch.
src/functions.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,87 +12,87 @@
 block discarded – undo
12 12
 use WMDE\HamcrestHtml\TextContentsMatcher;
13 13
 
14 14
 if ( !function_exists( 'htmlPiece' ) ) {
15
-	/**
16
-	 * @param Matcher|null $elementMatcher
17
-	 *
18
-	 * @return HtmlMatcher
19
-	 */
20
-	function htmlPiece( ?Matcher $elementMatcher = null ) {
21
-		return HtmlMatcher::htmlPiece( $elementMatcher );
22
-	}
15
+    /**
16
+     * @param Matcher|null $elementMatcher
17
+     *
18
+     * @return HtmlMatcher
19
+     */
20
+    function htmlPiece( ?Matcher $elementMatcher = null ) {
21
+        return HtmlMatcher::htmlPiece( $elementMatcher );
22
+    }
23 23
 }
24 24
 
25 25
 if ( !function_exists( 'havingRootElement' ) ) {
26
-	function havingRootElement( ?Matcher $matcher = null ) {
27
-		return RootElementMatcher::havingRootElement( $matcher );
28
-	}
26
+    function havingRootElement( ?Matcher $matcher = null ) {
27
+        return RootElementMatcher::havingRootElement( $matcher );
28
+    }
29 29
 }
30 30
 
31 31
 if ( !function_exists( 'havingDirectChild' ) ) {
32
-	function havingDirectChild( ?Matcher $elementMatcher = null ) {
33
-		return DirectChildElementMatcher::havingDirectChild( $elementMatcher );
34
-	}
32
+    function havingDirectChild( ?Matcher $elementMatcher = null ) {
33
+        return DirectChildElementMatcher::havingDirectChild( $elementMatcher );
34
+    }
35 35
 }
36 36
 
37 37
 if ( !function_exists( 'havingChild' ) ) {
38
-	function havingChild( ?Matcher $elementMatcher = null ) {
39
-		return ChildElementMatcher::havingChild( $elementMatcher );
40
-	}
38
+    function havingChild( ?Matcher $elementMatcher = null ) {
39
+        return ChildElementMatcher::havingChild( $elementMatcher );
40
+    }
41 41
 }
42 42
 
43 43
 if ( !function_exists( 'withTagName' ) ) {
44
-	/**
45
-	 * @param Matcher|string $tagName
46
-	 *
47
-	 * @return TagNameMatcher
48
-	 */
49
-	function withTagName( $tagName ) {
50
-		return TagNameMatcher::withTagName( $tagName );
51
-	}
44
+    /**
45
+     * @param Matcher|string $tagName
46
+     *
47
+     * @return TagNameMatcher
48
+     */
49
+    function withTagName( $tagName ) {
50
+        return TagNameMatcher::withTagName( $tagName );
51
+    }
52 52
 }
53 53
 
54 54
 if ( !function_exists( 'withAttribute' ) ) {
55
-	/**
56
-	 * @param Matcher|string $attributeName
57
-	 *
58
-	 * @return AttributeMatcher
59
-	 */
60
-	function withAttribute( $attributeName ) {
61
-		return AttributeMatcher::withAttribute( $attributeName );
62
-	}
55
+    /**
56
+     * @param Matcher|string $attributeName
57
+     *
58
+     * @return AttributeMatcher
59
+     */
60
+    function withAttribute( $attributeName ) {
61
+        return AttributeMatcher::withAttribute( $attributeName );
62
+    }
63 63
 }
64 64
 
65 65
 if ( !function_exists( 'withClass' ) ) {
66
-	/**
67
-	 * @param Matcher|string $class
68
-	 *
69
-	 * @return ClassMatcher
70
-	 */
71
-	function withClass( $class ) {
72
-		// TODO don't allow to call with empty string
66
+    /**
67
+     * @param Matcher|string $class
68
+     *
69
+     * @return ClassMatcher
70
+     */
71
+    function withClass( $class ) {
72
+        // TODO don't allow to call with empty string
73 73
 
74
-		return ClassMatcher::withClass( $class );
75
-	}
74
+        return ClassMatcher::withClass( $class );
75
+    }
76 76
 }
77 77
 
78 78
 if ( !function_exists( 'havingTextContents' ) ) {
79
-	/**
80
-	 * @param Matcher|string $text
81
-	 *
82
-	 * @return TextContentsMatcher
83
-	 */
84
-	function havingTextContents( $text ) {
85
-		return TextContentsMatcher::havingTextContents( $text );
86
-	}
79
+    /**
80
+     * @param Matcher|string $text
81
+     *
82
+     * @return TextContentsMatcher
83
+     */
84
+    function havingTextContents( $text ) {
85
+        return TextContentsMatcher::havingTextContents( $text );
86
+    }
87 87
 }
88 88
 
89 89
 if ( !function_exists( 'tagMatchingOutline' ) ) {
90
-	/**
91
-	 * @param string $htmlOutline
92
-	 *
93
-	 * @return ComplexTagMatcher
94
-	 */
95
-	function tagMatchingOutline( $htmlOutline ) {
96
-		return ComplexTagMatcher::tagMatchingOutline( $htmlOutline );
97
-	}
90
+    /**
91
+     * @param string $htmlOutline
92
+     *
93
+     * @return ComplexTagMatcher
94
+     */
95
+    function tagMatchingOutline( $htmlOutline ) {
96
+        return ComplexTagMatcher::tagMatchingOutline( $htmlOutline );
97
+    }
98 98
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,88 +11,88 @@
 block discarded – undo
11 11
 use WMDE\HamcrestHtml\TagNameMatcher;
12 12
 use WMDE\HamcrestHtml\TextContentsMatcher;
13 13
 
14
-if ( !function_exists( 'htmlPiece' ) ) {
14
+if (!function_exists('htmlPiece')) {
15 15
 	/**
16 16
 	 * @param Matcher|null $elementMatcher
17 17
 	 *
18 18
 	 * @return HtmlMatcher
19 19
 	 */
20
-	function htmlPiece( ?Matcher $elementMatcher = null ) {
21
-		return HtmlMatcher::htmlPiece( $elementMatcher );
20
+	function htmlPiece(?Matcher $elementMatcher = null) {
21
+		return HtmlMatcher::htmlPiece($elementMatcher);
22 22
 	}
23 23
 }
24 24
 
25
-if ( !function_exists( 'havingRootElement' ) ) {
26
-	function havingRootElement( ?Matcher $matcher = null ) {
27
-		return RootElementMatcher::havingRootElement( $matcher );
25
+if (!function_exists('havingRootElement')) {
26
+	function havingRootElement(?Matcher $matcher = null) {
27
+		return RootElementMatcher::havingRootElement($matcher);
28 28
 	}
29 29
 }
30 30
 
31
-if ( !function_exists( 'havingDirectChild' ) ) {
32
-	function havingDirectChild( ?Matcher $elementMatcher = null ) {
33
-		return DirectChildElementMatcher::havingDirectChild( $elementMatcher );
31
+if (!function_exists('havingDirectChild')) {
32
+	function havingDirectChild(?Matcher $elementMatcher = null) {
33
+		return DirectChildElementMatcher::havingDirectChild($elementMatcher);
34 34
 	}
35 35
 }
36 36
 
37
-if ( !function_exists( 'havingChild' ) ) {
38
-	function havingChild( ?Matcher $elementMatcher = null ) {
39
-		return ChildElementMatcher::havingChild( $elementMatcher );
37
+if (!function_exists('havingChild')) {
38
+	function havingChild(?Matcher $elementMatcher = null) {
39
+		return ChildElementMatcher::havingChild($elementMatcher);
40 40
 	}
41 41
 }
42 42
 
43
-if ( !function_exists( 'withTagName' ) ) {
43
+if (!function_exists('withTagName')) {
44 44
 	/**
45 45
 	 * @param Matcher|string $tagName
46 46
 	 *
47 47
 	 * @return TagNameMatcher
48 48
 	 */
49
-	function withTagName( $tagName ) {
50
-		return TagNameMatcher::withTagName( $tagName );
49
+	function withTagName($tagName) {
50
+		return TagNameMatcher::withTagName($tagName);
51 51
 	}
52 52
 }
53 53
 
54
-if ( !function_exists( 'withAttribute' ) ) {
54
+if (!function_exists('withAttribute')) {
55 55
 	/**
56 56
 	 * @param Matcher|string $attributeName
57 57
 	 *
58 58
 	 * @return AttributeMatcher
59 59
 	 */
60
-	function withAttribute( $attributeName ) {
61
-		return AttributeMatcher::withAttribute( $attributeName );
60
+	function withAttribute($attributeName) {
61
+		return AttributeMatcher::withAttribute($attributeName);
62 62
 	}
63 63
 }
64 64
 
65
-if ( !function_exists( 'withClass' ) ) {
65
+if (!function_exists('withClass')) {
66 66
 	/**
67 67
 	 * @param Matcher|string $class
68 68
 	 *
69 69
 	 * @return ClassMatcher
70 70
 	 */
71
-	function withClass( $class ) {
71
+	function withClass($class) {
72 72
 		// TODO don't allow to call with empty string
73 73
 
74
-		return ClassMatcher::withClass( $class );
74
+		return ClassMatcher::withClass($class);
75 75
 	}
76 76
 }
77 77
 
78
-if ( !function_exists( 'havingTextContents' ) ) {
78
+if (!function_exists('havingTextContents')) {
79 79
 	/**
80 80
 	 * @param Matcher|string $text
81 81
 	 *
82 82
 	 * @return TextContentsMatcher
83 83
 	 */
84
-	function havingTextContents( $text ) {
85
-		return TextContentsMatcher::havingTextContents( $text );
84
+	function havingTextContents($text) {
85
+		return TextContentsMatcher::havingTextContents($text);
86 86
 	}
87 87
 }
88 88
 
89
-if ( !function_exists( 'tagMatchingOutline' ) ) {
89
+if (!function_exists('tagMatchingOutline')) {
90 90
 	/**
91 91
 	 * @param string $htmlOutline
92 92
 	 *
93 93
 	 * @return ComplexTagMatcher
94 94
 	 */
95
-	function tagMatchingOutline( $htmlOutline ) {
96
-		return ComplexTagMatcher::tagMatchingOutline( $htmlOutline );
95
+	function tagMatchingOutline($htmlOutline) {
96
+		return ComplexTagMatcher::tagMatchingOutline($htmlOutline);
97 97
 	}
98 98
 }
Please login to merge, or discard this patch.
src/ChildElementMatcher.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,59 +10,59 @@
 block discarded – undo
10 10
 
11 11
 class ChildElementMatcher extends TypeSafeDiagnosingMatcher {
12 12
 
13
-	/**
14
-	 * @var Matcher|null
15
-	 */
16
-	private $matcher;
13
+    /**
14
+     * @var Matcher|null
15
+     */
16
+    private $matcher;
17 17
 
18
-	public static function havingChild( ?Matcher $elementMatcher = null ) {
19
-		return new static( $elementMatcher );
20
-	}
18
+    public static function havingChild( ?Matcher $elementMatcher = null ) {
19
+        return new static( $elementMatcher );
20
+    }
21 21
 
22
-	public function __construct( ?Matcher $matcher = null ) {
23
-		parent::__construct( DOMNode::class );
24
-		$this->matcher = $matcher;
25
-	}
22
+    public function __construct( ?Matcher $matcher = null ) {
23
+        parent::__construct( DOMNode::class );
24
+        $this->matcher = $matcher;
25
+    }
26 26
 
27
-	public function describeTo( Description $description ) {
28
-		$description->appendText( 'having child ' );
29
-		if ( $this->matcher ) {
30
-			$description->appendDescriptionOf( $this->matcher );
31
-		}
32
-	}
27
+    public function describeTo( Description $description ) {
28
+        $description->appendText( 'having child ' );
29
+        if ( $this->matcher ) {
30
+            $description->appendDescriptionOf( $this->matcher );
31
+        }
32
+    }
33 33
 
34
-	/**
35
-	 * @param DOMDocument|DOMNode $item
36
-	 * @param Description $mismatchDescription
37
-	 *
38
-	 * @return bool
39
-	 */
40
-	protected function matchesSafelyWithDiagnosticDescription(
41
-		$item, Description $mismatchDescription
42
-	) {
43
-		if ( $item instanceof DOMDocument ) {
44
-			$directChildren = $item->documentElement->childNodes->item( 0 )->childNodes;
45
-		} else {
46
-			$directChildren = $item->childNodes;
47
-		}
34
+    /**
35
+     * @param DOMDocument|DOMNode $item
36
+     * @param Description $mismatchDescription
37
+     *
38
+     * @return bool
39
+     */
40
+    protected function matchesSafelyWithDiagnosticDescription(
41
+        $item, Description $mismatchDescription
42
+    ) {
43
+        if ( $item instanceof DOMDocument ) {
44
+            $directChildren = $item->documentElement->childNodes->item( 0 )->childNodes;
45
+        } else {
46
+            $directChildren = $item->childNodes;
47
+        }
48 48
 
49
-		if ( $directChildren->length === 0 ) {
50
-			$mismatchDescription->appendText( 'having no children' );
51
-			return false;
52
-		}
49
+        if ( $directChildren->length === 0 ) {
50
+            $mismatchDescription->appendText( 'having no children' );
51
+            return false;
52
+        }
53 53
 
54
-		if ( !$this->matcher ) {
55
-			return $directChildren->length > 0;
56
-		}
54
+        if ( !$this->matcher ) {
55
+            return $directChildren->length > 0;
56
+        }
57 57
 
58
-		foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
59
-			if ( $this->matcher->matches( $child ) ) {
60
-				return true;
61
-			}
62
-		}
58
+        foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
59
+            if ( $this->matcher->matches( $child ) ) {
60
+                return true;
61
+            }
62
+        }
63 63
 
64
-		$mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
65
-		return false;
66
-	}
64
+        $mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
65
+        return false;
66
+    }
67 67
 
68 68
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	private $matcher;
17 17
 
18
-	public static function havingChild( ?Matcher $elementMatcher = null ) {
19
-		return new static( $elementMatcher );
18
+	public static function havingChild(?Matcher $elementMatcher = null) {
19
+		return new static($elementMatcher);
20 20
 	}
21 21
 
22
-	public function __construct( ?Matcher $matcher = null ) {
23
-		parent::__construct( DOMNode::class );
22
+	public function __construct(?Matcher $matcher = null) {
23
+		parent::__construct(DOMNode::class);
24 24
 		$this->matcher = $matcher;
25 25
 	}
26 26
 
27
-	public function describeTo( Description $description ) {
28
-		$description->appendText( 'having child ' );
29
-		if ( $this->matcher ) {
30
-			$description->appendDescriptionOf( $this->matcher );
27
+	public function describeTo(Description $description) {
28
+		$description->appendText('having child ');
29
+		if ($this->matcher) {
30
+			$description->appendDescriptionOf($this->matcher);
31 31
 		}
32 32
 	}
33 33
 
@@ -40,28 +40,28 @@  discard block
 block discarded – undo
40 40
 	protected function matchesSafelyWithDiagnosticDescription(
41 41
 		$item, Description $mismatchDescription
42 42
 	) {
43
-		if ( $item instanceof DOMDocument ) {
44
-			$directChildren = $item->documentElement->childNodes->item( 0 )->childNodes;
43
+		if ($item instanceof DOMDocument) {
44
+			$directChildren = $item->documentElement->childNodes->item(0)->childNodes;
45 45
 		} else {
46 46
 			$directChildren = $item->childNodes;
47 47
 		}
48 48
 
49
-		if ( $directChildren->length === 0 ) {
50
-			$mismatchDescription->appendText( 'having no children' );
49
+		if ($directChildren->length === 0) {
50
+			$mismatchDescription->appendText('having no children');
51 51
 			return false;
52 52
 		}
53 53
 
54
-		if ( !$this->matcher ) {
54
+		if (!$this->matcher) {
55 55
 			return $directChildren->length > 0;
56 56
 		}
57 57
 
58
-		foreach ( new XmlNodeRecursiveIterator( $directChildren ) as $child ) {
59
-			if ( $this->matcher->matches( $child ) ) {
58
+		foreach (new XmlNodeRecursiveIterator($directChildren) as $child) {
59
+			if ($this->matcher->matches($child)) {
60 60
 				return true;
61 61
 			}
62 62
 		}
63 63
 
64
-		$mismatchDescription->appendText( 'having no children ' )->appendDescriptionOf( $this->matcher );
64
+		$mismatchDescription->appendText('having no children ')->appendDescriptionOf($this->matcher);
65 65
 		return false;
66 66
 	}
67 67
 
Please login to merge, or discard this patch.