@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function &__get($tagName) |
| 151 | 151 | {
|
| 152 | - $getDocument[ $tagName ] = null; |
|
| 152 | + $getDocument[$tagName] = null; |
|
| 153 | 153 | |
| 154 | 154 | if (in_array($tagName, ['html', 'head', 'body', 'title'])) {
|
| 155 | - $getDocument[ $tagName ] = $this->getElementsByTagName($tagName)->item(0); |
|
| 155 | + $getDocument[$tagName] = $this->getElementsByTagName($tagName)->item(0); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - return $getDocument[ $tagName ]; |
|
| 158 | + return $getDocument[$tagName]; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // ------------------------------------------------------------------------ |
@@ -443,10 +443,10 @@ discard block |
||
| 443 | 443 | |
| 444 | 444 | // Has inline script element |
| 445 | 445 | if (preg_match_all('/<script((?:(?!src=).)*?)>(.*?)<\/script>/smix', $source, $matches)) {
|
| 446 | - if (isset($matches[ 2 ])) {
|
|
| 447 | - foreach ($matches[ 2 ] as $match) {
|
|
| 446 | + if (isset($matches[2])) {
|
|
| 447 | + foreach ($matches[2] as $match) {
|
|
| 448 | 448 | $script = trim($match); |
| 449 | - $this->bodyScriptContent[ md5($script) ] = $script . PHP_EOL; |
|
| 449 | + $this->bodyScriptContent[md5($script)] = $script . PHP_EOL; |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | foreach ($metas as $meta) {
|
| 462 | 462 | $attributes = []; |
| 463 | 463 | foreach ($meta->attributes as $name => $attribute) {
|
| 464 | - $attributes[ $name ] = $attribute->nodeValue; |
|
| 464 | + $attributes[$name] = $attribute->nodeValue; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $this->metaNodes->createElement($attributes); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | foreach ($links as $link) {
|
| 474 | 474 | $attributes = []; |
| 475 | 475 | foreach ($link->attributes as $name => $attribute) {
|
| 476 | - $attributes[ $name ] = $attribute->nodeValue; |
|
| 476 | + $attributes[$name] = $attribute->nodeValue; |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | $this->linkNodes->createElement($attributes); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | foreach ($scripts as $script) {
|
| 486 | 486 | $attributes = []; |
| 487 | 487 | foreach ($script->attributes as $name => $attribute) {
|
| 488 | - $attributes[ $name ] = $attribute->nodeValue; |
|
| 488 | + $attributes[$name] = $attribute->nodeValue; |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | foreach ($scripts as $script) {
|
| 494 | 494 | $attributes = []; |
| 495 | 495 | foreach ($script->attributes as $name => $attribute) {
|
| 496 | - $attributes[ $name ] = $attribute->nodeValue; |
|
| 496 | + $attributes[$name] = $attribute->nodeValue; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | if ($script->textContent == '') {
|
@@ -505,10 +505,10 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | // Has inline style Element |
| 507 | 507 | if (preg_match_all('/((<[\\s\\/]*style\\b[^>]*>)([^>]*)(<\\/style>))/i', $source, $matches)) {
|
| 508 | - if (isset($matches[ 3 ])) {
|
|
| 509 | - foreach ($matches[ 3 ] as $match) {
|
|
| 508 | + if (isset($matches[3])) {
|
|
| 509 | + foreach ($matches[3] as $match) {
|
|
| 510 | 510 | $style = trim($match); |
| 511 | - $this->styleContent[ md5($style) ] = $style . PHP_EOL; |
|
| 511 | + $this->styleContent[md5($style)] = $style . PHP_EOL; |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | foreach ($value as $style) { |
| 62 | 62 | if (preg_match_all("/(.*)(: )(.*)/", $style, $match)) { |
| 63 | - $this->addAttributeStyle($match[ 1 ][ 0 ], $match[ 3 ][ 0 ]); |
|
| 63 | + $this->addAttributeStyle($match[1][0], $match[3][0]); |
|
| 64 | 64 | } elseif (preg_match_all("/(.*)(:)(.*)/", $style, $match)) { |
| 65 | - $this->addAttributeStyle($match[ 1 ][ 0 ], $match[ 3 ][ 0 ]); |
|
| 65 | + $this->addAttributeStyle($match[1][0], $match[3][0]); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } elseif (is_string($value)) { |
| 69 | - $this->storage[ $name ] = trim($value); |
|
| 69 | + $this->storage[$name] = trim($value); |
|
| 70 | 70 | } else { |
| 71 | - $this->storage[ $name ] = $value; |
|
| 71 | + $this->storage[$name] = $value; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $this; |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | $classes = array_filter($classes); |
| 94 | 94 | |
| 95 | 95 | if ( ! $this->offsetExists('class')) { |
| 96 | - $this->storage[ 'class' ] = []; |
|
| 96 | + $this->storage['class'] = []; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $this->storage[ 'class' ] = array_merge($this->storage[ 'class' ], $classes); |
|
| 100 | - $this->storage[ 'class' ] = array_unique($this->storage[ 'class' ]); |
|
| 99 | + $this->storage['class'] = array_merge($this->storage['class'], $classes); |
|
| 100 | + $this->storage['class'] = array_unique($this->storage['class']); |
|
| 101 | 101 | |
| 102 | - if (in_array('disabled', $this->storage[ 'class' ])) { |
|
| 102 | + if (in_array('disabled', $this->storage['class'])) { |
|
| 103 | 103 | $this->removeAttributeClass('active'); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | $classes = array_filter($classes); |
| 125 | 125 | |
| 126 | 126 | foreach ($classes as $class) { |
| 127 | - if (false !== ($key = array_search($class, $this->storage[ 'class' ]))) { |
|
| 128 | - unset($this->storage[ 'class' ][ $key ]); |
|
| 127 | + if (false !== ($key = array_search($class, $this->storage['class']))) { |
|
| 128 | + unset($this->storage['class'][$key]); |
|
| 129 | 129 | } elseif (strpos($class, '*') !== false) { |
| 130 | 130 | $class = str_replace('*', '', $class); |
| 131 | - foreach ($this->storage[ 'class' ] as $key => $value) { |
|
| 131 | + foreach ($this->storage['class'] as $key => $value) { |
|
| 132 | 132 | if (preg_match("/\b$class\b/i", $value)) { |
| 133 | - unset($this->storage[ 'class' ][ $key ]); |
|
| 133 | + unset($this->storage['class'][$key]); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if (count($this->storage[ 'class' ]) == 0) { |
|
| 140 | - unset($this->storage[ 'class' ]); |
|
| 139 | + if (count($this->storage['class']) == 0) { |
|
| 140 | + unset($this->storage['class']); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -159,17 +159,17 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | if ( ! $this->offsetExists('style')) { |
| 162 | - $this->storage[ 'style' ] = []; |
|
| 162 | + $this->storage['style'] = []; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | foreach ($styles as $key => $value) { |
| 166 | 166 | if (empty($value)) { |
| 167 | 167 | continue; |
| 168 | 168 | } |
| 169 | - $styles[ trim($key) ] = trim($value); |
|
| 169 | + $styles[trim($key)] = trim($value); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - $this->storage[ 'style' ] = array_merge($this->storage[ 'style' ], $styles); |
|
| 172 | + $this->storage['style'] = array_merge($this->storage['style'], $styles); |
|
| 173 | 173 | |
| 174 | 174 | return $this; |
| 175 | 175 | } |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | public function hasAttribute($name) |
| 187 | 187 | { |
| 188 | 188 | if ($name === 'id') { |
| 189 | - return empty($this->storage[ 'id' ]) ? false : true; |
|
| 189 | + return empty($this->storage['id']) ? false : true; |
|
| 190 | 190 | } elseif ($name === 'class') { |
| 191 | - return empty($this->storage[ 'class' ]) ? false : true; |
|
| 191 | + return empty($this->storage['class']) ? false : true; |
|
| 192 | 192 | } else { |
| 193 | - return isset($this->storage[ $name ]); |
|
| 193 | + return isset($this->storage[$name]); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | if (empty($name)) { |
| 209 | 209 | return $this->storage; |
| 210 | - } elseif (isset($this->storage[ $name ])) { |
|
| 211 | - return $this->storage[ $name ]; |
|
| 210 | + } elseif (isset($this->storage[$name])) { |
|
| 211 | + return $this->storage[$name]; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return false; |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | foreach ($attributes as $attribute) { |
| 234 | 234 | if (array_key_exists($attribute, $this->storage)) { |
| 235 | - unset($this->storage[ $attribute ]); |
|
| 235 | + unset($this->storage[$attribute]); |
|
| 236 | 236 | } elseif (strpos($attribute, '*') !== false) { |
| 237 | 237 | $attribute = str_replace('*', '', $attribute); |
| 238 | 238 | foreach ($this->storage as $key => $value) { |
| 239 | 239 | if (preg_match("/\b$attribute\b/i", $key)) { |
| 240 | - unset($this->storage[ $key ]); |
|
| 240 | + unset($this->storage[$key]); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | public function getAttributeId() |
| 255 | 255 | { |
| 256 | 256 | if ($this->hasAttributeId()) { |
| 257 | - return $this->storage[ 'id' ]; |
|
| 257 | + return $this->storage['id']; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return false; |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | */ |
| 270 | 270 | public function hasAttributeId() |
| 271 | 271 | { |
| 272 | - return (bool)empty($this->storage[ 'id' ]) ? false : true; |
|
| 272 | + return (bool)empty($this->storage['id']) ? false : true; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // ------------------------------------------------------------------------ |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | public function hasAttributeClass($className) |
| 285 | 285 | { |
| 286 | 286 | if ( ! $this->offsetExists('class')) { |
| 287 | - $this->storage[ 'class' ] = []; |
|
| 287 | + $this->storage['class'] = []; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - return in_array($className, $this->storage[ 'class' ]); |
|
| 290 | + return in_array($className, $this->storage['class']); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // ------------------------------------------------------------------------ |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | public function getAttributeClass() |
| 301 | 301 | { |
| 302 | 302 | if ( ! $this->offsetExists('class')) { |
| 303 | - $this->storage[ 'class' ] = []; |
|
| 303 | + $this->storage['class'] = []; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - return implode(', ', $this->storage[ 'class' ]); |
|
| 306 | + return implode(', ', $this->storage['class']); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // ------------------------------------------------------------------------ |
@@ -317,14 +317,14 @@ discard block |
||
| 317 | 317 | public function replaceAttributeClass($class, $replace) |
| 318 | 318 | { |
| 319 | 319 | if ($this->offsetExists('class')) { |
| 320 | - foreach ($this->storage[ 'class' ] as $key => $value) { |
|
| 320 | + foreach ($this->storage['class'] as $key => $value) { |
|
| 321 | 321 | if (preg_match("/\b$class\b/i", $value)) { |
| 322 | - $this->storage[ 'class' ][ $key ] = str_replace($class, $replace, $value); |
|
| 322 | + $this->storage['class'][$key] = str_replace($class, $replace, $value); |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if (count($this->storage[ 'class' ]) == 0) { |
|
| 327 | - unset($this->storage[ 'class' ]); |
|
| 326 | + if (count($this->storage['class']) == 0) { |
|
| 327 | + unset($this->storage['class']); |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | if ($this->offsetExists('class')) { |
| 344 | 344 | $matches = []; |
| 345 | 345 | |
| 346 | - foreach ($this->storage[ 'class' ] as $key => $value) { |
|
| 346 | + foreach ($this->storage['class'] as $key => $value) { |
|
| 347 | 347 | if (preg_match("/\b$class\b/i", $value)) { |
| 348 | 348 | $matches[] = $value; |
| 349 | 349 | } |