Completed
Push — master ( 5fc62b...e9a6b5 )
by Josh
02:38
created
src/Element.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@
 block discarded – undo
164 164
 
165 165
 		return preg_replace_callback(
166 166
 			'(<([-\\w]++):[^>]*?\\K\\s*/?>)',
167
-			function ($m) use ($prefixes)
167
+			function($m) use ($prefixes)
168 168
 			{
169 169
 				$return = $m[0];
170 170
 				$prefix = $m[1];
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -107,34 +107,34 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 
109 109
 	/**
110
-	* Evaluate and return the result of a given XPath expression using this element as context node
111
-	*
112
-	* @param  string  $expr XPath expression
113
-	* @return mixed
114
-	*/
110
+	 * Evaluate and return the result of a given XPath expression using this element as context node
111
+	 *
112
+	 * @param  string  $expr XPath expression
113
+	 * @return mixed
114
+	 */
115 115
 	public function evaluate(string $expr)
116 116
 	{
117 117
 		return $this->ownerDocument->evaluate($expr, $this);
118 118
 	}
119 119
 
120 120
 	/**
121
-	* Evaluate and return the first element of a given XPath query using this element as context node
122
-	*
123
-	* @param  string       $expr XPath expression
124
-	* @return DOMNode|null
125
-	*/
121
+	 * Evaluate and return the first element of a given XPath query using this element as context node
122
+	 *
123
+	 * @param  string       $expr XPath expression
124
+	 * @return DOMNode|null
125
+	 */
126 126
 	public function firstOf(string $expr): ?DOMNode
127 127
 	{
128 128
 		return $this->ownerDocument->firstOf($expr, $this);
129 129
 	}
130 130
 
131 131
 	/**
132
-	* Insert given element relative to this element's position
133
-	*
134
-	* @param  string $where   One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
135
-	* @param  self   $element
136
-	* @return self
137
-	*/
132
+	 * Insert given element relative to this element's position
133
+	 *
134
+	 * @param  string $where   One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
135
+	 * @param  self   $element
136
+	 * @return self
137
+	 */
138 138
 	public function insertAdjacentElement(string $where, self $element): self
139 139
 	{
140 140
 		$this->insertAdjacentNode($where, $element);
@@ -143,24 +143,24 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 
145 145
 	/**
146
-	* Insert given text relative to this element's position
147
-	*
148
-	* @param  string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
149
-	* @param  string $text
150
-	* @return void
151
-	*/
146
+	 * Insert given text relative to this element's position
147
+	 *
148
+	 * @param  string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
149
+	 * @param  string $text
150
+	 * @return void
151
+	 */
152 152
 	public function insertAdjacentText(string $where, string $text): void
153 153
 	{
154 154
 		$this->insertText($where, $text);
155 155
 	}
156 156
 
157 157
 	/**
158
-	* Insert given XML relative to this element's position
159
-	*
160
-	* @param  string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
161
-	* @param  string $xml
162
-	* @return void
163
-	*/
158
+	 * Insert given XML relative to this element's position
159
+	 *
160
+	 * @param  string $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
161
+	 * @param  string $xml
162
+	 * @return void
163
+	 */
164 164
 	public function insertAdjacentXML(string $where, string $xml): void
165 165
 	{
166 166
 		$fragment = $this->ownerDocument->createDocumentFragment();
@@ -170,32 +170,32 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Evaluate and return the result of a given XPath query using this element as context node
174
-	*
175
-	* @param  string      $expr XPath expression
176
-	* @return DOMNodeList
177
-	*/
173
+	 * Evaluate and return the result of a given XPath query using this element as context node
174
+	 *
175
+	 * @param  string      $expr XPath expression
176
+	 * @return DOMNodeList
177
+	 */
178 178
 	public function query(string $expr): DOMNodeList
179 179
 	{
180 180
 		return $this->ownerDocument->query($expr, $this);
181 181
 	}
182 182
 
183 183
 	/**
184
-	* Remove this element from the document
185
-	*
186
-	* @return void
187
-	*/
184
+	 * Remove this element from the document
185
+	 *
186
+	 * @return void
187
+	 */
188 188
 	public function remove(): void
189 189
 	{
190 190
 		$this->parentNode->removeChild($this);
191 191
 	}
192 192
 
193 193
 	/**
194
-	* Replace this element with given nodes/text
195
-	*
196
-	* @param  DOMNode|string $nodes
197
-	* @return void
198
-	*/
194
+	 * Replace this element with given nodes/text
195
+	 *
196
+	 * @param  DOMNode|string $nodes
197
+	 * @return void
198
+	 */
199 199
 	public function replaceWith(...$nodes): void
200 200
 	{
201 201
 		foreach ($nodes as $node)
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 	}
211 211
 
212 212
 	/**
213
-	* Add namespace declarations that may be missing in given XML
214
-	*
215
-	* @param  string $xml Original XML
216
-	* @return string      Modified XML
217
-	*/
213
+	 * Add namespace declarations that may be missing in given XML
214
+	 *
215
+	 * @param  string $xml Original XML
216
+	 * @return string      Modified XML
217
+	 */
218 218
 	protected function addMissingNamespaceDeclarations(string $xml): string
219 219
 	{
220 220
 		preg_match_all('(xmlns:\\K[-\\w]++(?==))', $xml, $m);
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Insert given node relative to this element's position
243
-	*
244
-	* @param  string  $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
245
-	* @param  DOMNode $node
246
-	* @return void
247
-	*/
242
+	 * Insert given node relative to this element's position
243
+	 *
244
+	 * @param  string  $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
245
+	 * @param  DOMNode $node
246
+	 * @return void
247
+	 */
248 248
 	protected function insertAdjacentNode(string $where, DOMNode $node): void
249 249
 	{
250 250
 		$where = strtolower($where);
@@ -271,13 +271,13 @@  discard block
 block discarded – undo
271 271
 	}
272 272
 
273 273
 	/**
274
-	* Create and insert an element at given position
275
-	*
276
-	* @param  string $where    One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
277
-	* @param  string $nodeName Element's nodeName
278
-	* @param  string $text     Text content
279
-	* @return self
280
-	*/
274
+	 * Create and insert an element at given position
275
+	 *
276
+	 * @param  string $where    One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
277
+	 * @param  string $nodeName Element's nodeName
278
+	 * @param  string $text     Text content
279
+	 * @return self
280
+	 */
281 281
 	protected function insertElement(string $where, string $nodeName, string $text): self
282 282
 	{
283 283
 		$text = htmlspecialchars($text, ENT_NOQUOTES);
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 
299 299
 	/**
300
-	* Insert given text relative to this element's position
301
-	*
302
-	* @param  string  $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
303
-	* @param  string  $text
304
-	* @return DOMText
305
-	*/
300
+	 * Insert given text relative to this element's position
301
+	 *
302
+	 * @param  string  $where One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
303
+	 * @param  string  $text
304
+	 * @return DOMText
305
+	 */
306 306
 	protected function insertText(string $where, string $text): DOMText
307 307
 	{
308 308
 		$node = $this->ownerDocument->createTextNode($text);
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
 	}
313 313
 
314 314
 	/**
315
-	* Create and insert an XSL element at given position
316
-	*
317
-	* @param  string $where     One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
318
-	* @param  string $localName Element's localName
319
-	* @param  array  $arguments Arguments passed to the Document::create* function
320
-	* @return self
321
-	*/
315
+	 * Create and insert an XSL element at given position
316
+	 *
317
+	 * @param  string $where     One of 'beforebegin', 'afterbegin', 'beforeend', 'afterend'
318
+	 * @param  string $localName Element's localName
319
+	 * @param  array  $arguments Arguments passed to the Document::create* function
320
+	 * @return self
321
+	 */
322 322
 	protected function insertXslElement(string $where, string $localName, array $arguments): self
323 323
 	{
324 324
 		$callback = [$this->ownerDocument, 'createXsl' . ucfirst($localName)];
Please login to merge, or discard this patch.
src/Document.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 class Document extends DOMDocument
16 16
 {
17 17
 	/**
18
-	* @link https://www.php.net/manual/domdocument.construct.php
19
-	*
20
-	* @param string $version  Version number of the document
21
-	* @param string $encoding Encoding of the document
22
-	*/
18
+	 * @link https://www.php.net/manual/domdocument.construct.php
19
+	 *
20
+	 * @param string $version  Version number of the document
21
+	 * @param string $encoding Encoding of the document
22
+	 */
23 23
 	public function __construct(string $version = '1.0', string $encoding = 'utf-8')
24 24
 	{
25 25
 		parent::__construct($version, $encoding);
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 	}
29 29
 
30 30
 	/**
31
-	* Create and return an xsl:apply-templates element
32
-	*
33
-	* @param  string  $select XPath expression for the "select" attribute
34
-	* @return Element
35
-	*/
31
+	 * Create and return an xsl:apply-templates element
32
+	 *
33
+	 * @param  string  $select XPath expression for the "select" attribute
34
+	 * @return Element
35
+	 */
36 36
 	public function createXslApplyTemplates(string $select = null): Element
37 37
 	{
38 38
 		$element = $this->createElementXSL('apply-templates');
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	/**
48
-	* Create and return an xsl:attribute element
49
-	*
50
-	* @param  string  $name Attribute's name
51
-	* @param  string  $text Text content for the element
52
-	* @return Element
53
-	*/
48
+	 * Create and return an xsl:attribute element
49
+	 *
50
+	 * @param  string  $name Attribute's name
51
+	 * @param  string  $text Text content for the element
52
+	 * @return Element
53
+	 */
54 54
 	public function createXslAttribute(string $name, string $text = ''): Element
55 55
 	{
56 56
 		$element = $this->createElementXSL('attribute', $text);
@@ -60,32 +60,32 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Create and return an xsl:choose element
64
-	*
65
-	* @return Element
66
-	*/
63
+	 * Create and return an xsl:choose element
64
+	 *
65
+	 * @return Element
66
+	 */
67 67
 	public function createXslChoose(): Element
68 68
 	{
69 69
 		return $this->createElementXSL('choose');
70 70
 	}
71 71
 
72 72
 	/**
73
-	* Create and return an xsl:comment element
74
-	*
75
-	* @param  string  $text Text content for the comment
76
-	* @return Element
77
-	*/
73
+	 * Create and return an xsl:comment element
74
+	 *
75
+	 * @param  string  $text Text content for the comment
76
+	 * @return Element
77
+	 */
78 78
 	public function createXslComment(string $text = ''): Element
79 79
 	{
80 80
 		return $this->createElementXSL('comment', $text);
81 81
 	}
82 82
 
83 83
 	/**
84
-	* Create and return an xsl:copy-of element
85
-	*
86
-	* @param  string  $select XPath expression for the "select" attribute
87
-	* @return Element
88
-	*/
84
+	 * Create and return an xsl:copy-of element
85
+	 *
86
+	 * @param  string  $select XPath expression for the "select" attribute
87
+	 * @return Element
88
+	 */
89 89
 	public function createXslCopyOf(string $select): Element
90 90
 	{
91 91
 		$element = $this->createElementXSL('copy-of');
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	/**
98
-	* Create and return an xsl:if element
99
-	*
100
-	* @param  string  $test XPath expression for the "test" attribute
101
-	* @param  string  $text Text content for the element
102
-	* @return Element
103
-	*/
98
+	 * Create and return an xsl:if element
99
+	 *
100
+	 * @param  string  $test XPath expression for the "test" attribute
101
+	 * @param  string  $text Text content for the element
102
+	 * @return Element
103
+	 */
104 104
 	public function createXslIf(string $test, string $text = ''): Element
105 105
 	{
106 106
 		$element = $this->createElementXSL('if', $text);
@@ -110,33 +110,33 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 	/**
113
-	* Create and return an xsl:otherwise element
114
-	*
115
-	* @param  string  $text Text content for the element
116
-	* @return Element
117
-	*/
113
+	 * Create and return an xsl:otherwise element
114
+	 *
115
+	 * @param  string  $text Text content for the element
116
+	 * @return Element
117
+	 */
118 118
 	public function createXslOtherwise(string $text = ''): Element
119 119
 	{
120 120
 		return $this->createElementXSL('otherwise', $text);
121 121
 	}
122 122
 
123 123
 	/**
124
-	* Create and return an xsl:text element
125
-	*
126
-	* @param  string  $text Text content for the element
127
-	* @return Element
128
-	*/
124
+	 * Create and return an xsl:text element
125
+	 *
126
+	 * @param  string  $text Text content for the element
127
+	 * @return Element
128
+	 */
129 129
 	public function createXslText(string $text = ''): Element
130 130
 	{
131 131
 		return $this->createElementXSL('text', $text);
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Create and return an xsl:value-of element
136
-	*
137
-	* @param  string  $select XPath expression for the "select" attribute
138
-	* @return Element
139
-	*/
135
+	 * Create and return an xsl:value-of element
136
+	 *
137
+	 * @param  string  $select XPath expression for the "select" attribute
138
+	 * @return Element
139
+	 */
140 140
 	public function createXslValueOf(string $select): Element
141 141
 	{
142 142
 		$element = $this->createElementXSL('value-of');
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 	}
147 147
 
148 148
 	/**
149
-	* Create and return an xsl:variable element
150
-	*
151
-	* @param  string  $name   Name of the variable
152
-	* @param  string  $select XPath expression
153
-	* @return Element
154
-	*/
149
+	 * Create and return an xsl:variable element
150
+	 *
151
+	 * @param  string  $name   Name of the variable
152
+	 * @param  string  $select XPath expression
153
+	 * @return Element
154
+	 */
155 155
 	public function createXslVariable(string $name, string $select = null): Element
156 156
 	{
157 157
 		$element = $this->createElementXSL('variable');
@@ -165,12 +165,12 @@  discard block
 block discarded – undo
165 165
 	}
166 166
 
167 167
 	/**
168
-	* Create and return an xsl:when element
169
-	*
170
-	* @param  string  $test XPath expression for the "test" attribute
171
-	* @param  string  $text Text content for the element
172
-	* @return Element
173
-	*/
168
+	 * Create and return an xsl:when element
169
+	 *
170
+	 * @param  string  $test XPath expression for the "test" attribute
171
+	 * @param  string  $text Text content for the element
172
+	 * @return Element
173
+	 */
174 174
 	public function createXslWhen(string $test, string $text = ''): Element
175 175
 	{
176 176
 		$element = $this->createElementXSL('when', $text);
@@ -180,51 +180,51 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	/**
183
-	* Evaluate and return the result of a given XPath expression
184
-	*
185
-	* @param  string  $expr           XPath expression
186
-	* @param  DOMNode $node           Context node
187
-	* @param  bool    $registerNodeNS Whether to register the node's namespace
188
-	* @return mixed
189
-	*/
183
+	 * Evaluate and return the result of a given XPath expression
184
+	 *
185
+	 * @param  string  $expr           XPath expression
186
+	 * @param  DOMNode $node           Context node
187
+	 * @param  bool    $registerNodeNS Whether to register the node's namespace
188
+	 * @return mixed
189
+	 */
190 190
 	public function evaluate(string $expr, DOMNode $node = null, bool $registerNodeNS = true)
191 191
 	{
192 192
 		return $this->xpath('evaluate', func_get_args());
193 193
 	}
194 194
 
195 195
 	/**
196
-	* Evaluate and return the first element of a given XPath query
197
-	*
198
-	* @param  string      $expr           XPath expression
199
-	* @param  DOMNode     $node           Context node
200
-	* @param  bool        $registerNodeNS Whether to register the node's namespace
201
-	* @return DOMNode|null
202
-	*/
196
+	 * Evaluate and return the first element of a given XPath query
197
+	 *
198
+	 * @param  string      $expr           XPath expression
199
+	 * @param  DOMNode     $node           Context node
200
+	 * @param  bool        $registerNodeNS Whether to register the node's namespace
201
+	 * @return DOMNode|null
202
+	 */
203 203
 	public function firstOf(string $expr, DOMNode $node = null, bool $registerNodeNS = true): ?DOMNode
204 204
 	{
205 205
 		return $this->xpath('query', func_get_args())->item(0);
206 206
 	}
207 207
 
208 208
 	/**
209
-	* Evaluate and return the result of a given XPath query
210
-	*
211
-	* @param  string      $expr           XPath expression
212
-	* @param  DOMNode     $node           Context node
213
-	* @param  bool        $registerNodeNS Whether to register the node's namespace
214
-	* @return DOMNodeList
215
-	*/
209
+	 * Evaluate and return the result of a given XPath query
210
+	 *
211
+	 * @param  string      $expr           XPath expression
212
+	 * @param  DOMNode     $node           Context node
213
+	 * @param  bool        $registerNodeNS Whether to register the node's namespace
214
+	 * @return DOMNodeList
215
+	 */
216 216
 	public function query(string $expr, DOMNode $node = null, bool $registerNodeNS = true): DOMNodeList
217 217
 	{
218 218
 		return $this->xpath('query', func_get_args());
219 219
 	}
220 220
 
221 221
 	/**
222
-	* Create and return an XSL element
223
-	*
224
-	* @param  string  $name Element's local name
225
-	* @param  string  $text Text content for the element
226
-	* @return Element
227
-	*/
222
+	 * Create and return an XSL element
223
+	 *
224
+	 * @param  string  $name Element's local name
225
+	 * @param  string  $text Text content for the element
226
+	 * @return Element
227
+	 */
228 228
 	protected function createElementXSL(string $localName, string $text = ''): Element
229 229
 	{
230 230
 		return $this->createElementNS(
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	}
236 236
 
237 237
 	/**
238
-	* Execute a DOMXPath method and return the result
239
-	*
240
-	* @param  string $methodName
241
-	* @param  array  $args
242
-	* @return mixed
243
-	*/
238
+	 * Execute a DOMXPath method and return the result
239
+	 *
240
+	 * @param  string $methodName
241
+	 * @param  array  $args
242
+	 * @return mixed
243
+	 */
244 244
 	protected function xpath(string $methodName, array $args)
245 245
 	{
246 246
 		$xpath = new DOMXPath($this);
Please login to merge, or discard this patch.