@@ -36,7 +36,7 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function __construct(Document $ownerDocument) |
| 38 | 38 | {
|
| 39 | - $this->ownerDocument =& $ownerDocument; |
|
| 39 | + $this->ownerDocument = & $ownerDocument; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // ------------------------------------------------------------------------ |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct(Document $ownerDocument) |
| 40 | 40 | { |
| 41 | - $this->ownerDocument =& $ownerDocument; |
|
| 41 | + $this->ownerDocument = & $ownerDocument; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // ------------------------------------------------------------------------ |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | $selector = trim($selector); |
| 84 | 84 | |
| 85 | 85 | if (array_key_exists($selector, $this->compiledExpressions)) {
|
| 86 | - $paths[] = $this->compiledExpressions[ $selector ]; |
|
| 86 | + $paths[] = $this->compiledExpressions[$selector]; |
|
| 87 | 87 | |
| 88 | 88 | continue; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $this->compiledExpressions[ $selector ] = $this->fetchCssExpression($selector); |
|
| 91 | + $this->compiledExpressions[$selector] = $this->fetchCssExpression($selector); |
|
| 92 | 92 | |
| 93 | - $paths[] = $this->compiledExpressions[ $selector ]; |
|
| 93 | + $paths[] = $this->compiledExpressions[$selector]; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | return implode('|', $paths);
|
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | if ($pos !== false) {
|
| 116 | 116 | $property = substr($selector, $pos + 2); |
| 117 | 117 | $property = $this->fetchCssProperty($property); |
| 118 | - $property = $this->parseCssProperty($property[ 'name' ], $property[ 'args' ]); |
|
| 118 | + $property = $this->parseCssProperty($property['name'], $property['args']); |
|
| 119 | 119 | |
| 120 | 120 | $selector = substr($selector, 0, $pos); |
| 121 | 121 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | while (count($segments) > 0) {
|
| 133 | 133 | $expression .= $this->generateExpression($segments, $prefix); |
| 134 | 134 | |
| 135 | - $selector = trim(substr($selector, strlen($segments[ 'selector' ]))); |
|
| 136 | - $prefix = isset($segments[ 'rel' ]) ? '/' : '//'; |
|
| 135 | + $selector = trim(substr($selector, strlen($segments['selector']))); |
|
| 136 | + $prefix = isset($segments['rel']) ? '/' : '//'; |
|
| 137 | 137 | |
| 138 | 138 | if ($selector === '') {
|
| 139 | 139 | break; |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | if (preg_match($regexp, $property, $segments)) {
|
| 168 | 168 | $result = []; |
| 169 | 169 | |
| 170 | - $result[ 'name' ] = $segments[ 'name' ]; |
|
| 171 | - $result[ 'args' ] = isset($segments[ 'args' ]) ? explode('|', $segments[ 'args' ]) : [];
|
|
| 170 | + $result['name'] = $segments['name']; |
|
| 171 | + $result['args'] = isset($segments['args']) ? explode('|', $segments['args']) : [];
|
|
| 172 | 172 | |
| 173 | 173 | return $result; |
| 174 | 174 | } |
@@ -239,21 +239,21 @@ discard block |
||
| 239 | 239 | $regexp = '/' . $tag . $id . $classes . $attrs . $pseudo . $rel . '/is'; |
| 240 | 240 | |
| 241 | 241 | if (preg_match($regexp, $selector, $segments)) {
|
| 242 | - if ($segments[ 0 ] === '') {
|
|
| 242 | + if ($segments[0] === '') {
|
|
| 243 | 243 | throw new RuntimeException('HTML_E_INVALID_SELECTOR');
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $result[ 'selector' ] = $segments[ 0 ]; |
|
| 247 | - $result[ 'tag' ] = (isset($segments[ 'tag' ]) and $segments[ 'tag' ] !== '') ? $segments[ 'tag' ] : '*'; |
|
| 246 | + $result['selector'] = $segments[0]; |
|
| 247 | + $result['tag'] = (isset($segments['tag']) and $segments['tag'] !== '') ? $segments['tag'] : '*'; |
|
| 248 | 248 | |
| 249 | 249 | // if the id attribute specified |
| 250 | - if (isset($segments[ 'id' ]) and $segments[ 'id' ] !== '') {
|
|
| 251 | - $result[ 'id' ] = $segments[ 'id' ]; |
|
| 250 | + if (isset($segments['id']) and $segments['id'] !== '') {
|
|
| 251 | + $result['id'] = $segments['id']; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // if the attributes specified |
| 255 | - if (isset($segments[ 'attrs' ])) {
|
|
| 256 | - $attributes = trim($segments[ 'attrs' ], '[]'); |
|
| 255 | + if (isset($segments['attrs'])) {
|
|
| 256 | + $attributes = trim($segments['attrs'], '[]'); |
|
| 257 | 257 | $attributes = explode('][', $attributes);
|
| 258 | 258 | |
| 259 | 259 | foreach ($attributes as $attribute) {
|
@@ -261,35 +261,35 @@ discard block |
||
| 261 | 261 | list($name, $value) = array_pad(explode('=', $attribute, 2), 2, null);
|
| 262 | 262 | |
| 263 | 263 | // equal null if specified only the attribute name |
| 264 | - $result[ 'attributes' ][ $name ] = is_string($value) ? trim($value, '\'"') : null; |
|
| 264 | + $result['attributes'][$name] = is_string($value) ? trim($value, '\'"') : null; |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // if the class attribute specified |
| 270 | - if (isset($segments[ 'classes' ])) {
|
|
| 271 | - $classes = trim($segments[ 'classes' ], '.'); |
|
| 270 | + if (isset($segments['classes'])) {
|
|
| 271 | + $classes = trim($segments['classes'], '.'); |
|
| 272 | 272 | $classes = explode('.', $classes);
|
| 273 | 273 | |
| 274 | 274 | foreach ($classes as $class) {
|
| 275 | 275 | if ($class !== '') {
|
| 276 | - $result[ 'classes' ][] = $class; |
|
| 276 | + $result['classes'][] = $class; |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // if the pseudo class specified |
| 282 | - if (isset($segments[ 'pseudo' ]) and $segments[ 'pseudo' ] !== '') {
|
|
| 283 | - $result[ 'pseudo' ] = $segments[ 'pseudo' ]; |
|
| 282 | + if (isset($segments['pseudo']) and $segments['pseudo'] !== '') {
|
|
| 283 | + $result['pseudo'] = $segments['pseudo']; |
|
| 284 | 284 | |
| 285 | - if (isset($segments[ 'expr' ]) and $segments[ 'expr' ] !== '') {
|
|
| 286 | - $result[ 'expr' ] = $segments[ 'expr' ]; |
|
| 285 | + if (isset($segments['expr']) and $segments['expr'] !== '') {
|
|
| 286 | + $result['expr'] = $segments['expr']; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // if it is a direct descendant |
| 291 | - if (isset($segments[ 'rel' ])) {
|
|
| 292 | - $result[ 'rel' ] = $segments[ 'rel' ]; |
|
| 291 | + if (isset($segments['rel'])) {
|
|
| 292 | + $result['rel'] = $segments['rel']; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | return $result; |
@@ -312,39 +312,39 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | private function generateExpression($segments, $prefix = '//') |
| 314 | 314 | {
|
| 315 | - $tagName = isset($segments[ 'tag' ]) ? $segments[ 'tag' ] : '*'; |
|
| 315 | + $tagName = isset($segments['tag']) ? $segments['tag'] : '*'; |
|
| 316 | 316 | |
| 317 | 317 | $attributes = []; |
| 318 | 318 | |
| 319 | 319 | // if the id attribute specified |
| 320 | - if (isset($segments[ 'id' ])) {
|
|
| 321 | - $attributes[] = sprintf('@id="%s"', $segments[ 'id' ]);
|
|
| 320 | + if (isset($segments['id'])) {
|
|
| 321 | + $attributes[] = sprintf('@id="%s"', $segments['id']);
|
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // if the class attribute specified |
| 325 | - if (isset($segments[ 'classes' ])) {
|
|
| 326 | - foreach ($segments[ 'classes' ] as $class) {
|
|
| 325 | + if (isset($segments['classes'])) {
|
|
| 326 | + foreach ($segments['classes'] as $class) {
|
|
| 327 | 327 | $attributes[] = sprintf('contains(concat(" ", normalize-space(@class), " "), " %s ")', $class);
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // if the attributes specified |
| 332 | - if (isset($segments[ 'attributes' ])) {
|
|
| 333 | - foreach ($segments[ 'attributes' ] as $name => $value) {
|
|
| 332 | + if (isset($segments['attributes'])) {
|
|
| 333 | + foreach ($segments['attributes'] as $name => $value) {
|
|
| 334 | 334 | $attributes[] = $this->fetchCssAttributeSelector($name, $value); |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // if the pseudo class specified |
| 339 | - if (isset($segments[ 'pseudo' ])) {
|
|
| 340 | - $expression = isset($segments[ 'expr' ]) ? trim($segments[ 'expr' ]) : ''; |
|
| 339 | + if (isset($segments['pseudo'])) {
|
|
| 340 | + $expression = isset($segments['expr']) ? trim($segments['expr']) : ''; |
|
| 341 | 341 | |
| 342 | 342 | $parameters = explode(',', $expression);
|
| 343 | 343 | |
| 344 | - $attributes[] = $this->fetchCssPseudoSelector($segments[ 'pseudo' ], $parameters, $tagName); |
|
| 344 | + $attributes[] = $this->fetchCssPseudoSelector($segments['pseudo'], $parameters, $tagName); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if (count($attributes) === 0 and ! isset($segments[ 'tag' ])) {
|
|
| 347 | + if (count($attributes) === 0 and ! isset($segments['tag'])) {
|
|
| 348 | 348 | throw new InvalidArgumentException( |
| 349 | 349 | 'The array of segments should contain the name of the tag or at least one attribute' |
| 350 | 350 | ); |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | ? sprintf('[(%s)]', implode(') and (', $attributes))
|
| 358 | 358 | : sprintf( |
| 359 | 359 | '[%s]', |
| 360 | - $attributes[ 0 ] |
|
| 360 | + $attributes[0] |
|
| 361 | 361 | ); |
| 362 | 362 | } |
| 363 | 363 | |
@@ -449,26 +449,26 @@ discard block |
||
| 449 | 449 | $xpath = sprintf( |
| 450 | 450 | '(name()="%s") and (%s)', |
| 451 | 451 | $tagName, |
| 452 | - $this->fetchCssPseudoNthSelector($parameters[ 0 ]) |
|
| 452 | + $this->fetchCssPseudoNthSelector($parameters[0]) |
|
| 453 | 453 | ); |
| 454 | 454 | $tagName = '*'; |
| 455 | 455 | |
| 456 | 456 | return $xpath; |
| 457 | 457 | break; |
| 458 | 458 | case 'contains': |
| 459 | - $string = trim($parameters[ 0 ], ' \'"'); |
|
| 460 | - $caseSensitive = isset($parameters[ 1 ]) and (trim($parameters[ 1 ]) === 'true'); |
|
| 459 | + $string = trim($parameters[0], ' \'"'); |
|
| 460 | + $caseSensitive = isset($parameters[1]) and (trim($parameters[1]) === 'true'); |
|
| 461 | 461 | |
| 462 | 462 | return $this->fetchCssPseudoContainsSelector($string, $caseSensitive); |
| 463 | 463 | break; |
| 464 | 464 | case 'has': |
| 465 | - return $this->fetchCssExpression($parameters[ 0 ], './/'); |
|
| 465 | + return $this->fetchCssExpression($parameters[0], './/'); |
|
| 466 | 466 | break; |
| 467 | 467 | case 'not': |
| 468 | - return sprintf('not($this->%s)', $this->fetchCssExpression($parameters[ 0 ], ''));
|
|
| 468 | + return sprintf('not($this->%s)', $this->fetchCssExpression($parameters[0], ''));
|
|
| 469 | 469 | break; |
| 470 | 470 | case 'nth-of-type': |
| 471 | - return $this->fetchCssPseudoNthSelector($parameters[ 0 ]); |
|
| 471 | + return $this->fetchCssPseudoNthSelector($parameters[0]); |
|
| 472 | 472 | break; |
| 473 | 473 | case 'empty': |
| 474 | 474 | return 'count(descendant::*) = 0'; |
@@ -516,10 +516,10 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | if (preg_match("/^(?P<mul>[0-9]?n)(?:(?P<sign>\+|\-)(?P<pos>[0-9]+))?$/is", $expression, $segments)) {
|
| 519 | - if (isset($segments[ 'mul' ])) {
|
|
| 520 | - $multiplier = $segments[ 'mul' ] === 'n' ? 1 : trim($segments[ 'mul' ], 'n'); |
|
| 521 | - $sign = (isset($segments[ 'sign' ]) and $segments[ 'sign' ] === '+') ? '-' : '+'; |
|
| 522 | - $position = isset($segments[ 'pos' ]) ? $segments[ 'pos' ] : 0; |
|
| 519 | + if (isset($segments['mul'])) {
|
|
| 520 | + $multiplier = $segments['mul'] === 'n' ? 1 : trim($segments['mul'], 'n'); |
|
| 521 | + $sign = (isset($segments['sign']) and $segments['sign'] === '+') ? '-' : '+'; |
|
| 522 | + $position = isset($segments['pos']) ? $segments['pos'] : 0; |
|
| 523 | 523 | |
| 524 | 524 | return sprintf( |
| 525 | 525 | '(position() %s %d) mod %d = 0 and position() >= %d', |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | $tempScriptElements = []; |
| 140 | 140 | |
| 141 | 141 | if (preg_match_all('/<script\b[^>]*>([\s\S]*?)<\/script>/mi', $source, $matches)) {
|
| 142 | - $tempScriptElements = $matches[ 0 ]; |
|
| 142 | + $tempScriptElements = $matches[0]; |
|
| 143 | 143 | |
| 144 | - foreach ($matches[ 0 ] as $i => $match) {
|
|
| 144 | + foreach ($matches[0] as $i => $match) {
|
|
| 145 | 145 | $source = str_replace($match, '<script>' . ($i + 1) . '</script>', $source); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | $source, |
| 161 | 161 | $matches |
| 162 | 162 | )) {
|
| 163 | - $tempInlineElements = $matches[ 0 ]; |
|
| 163 | + $tempInlineElements = $matches[0]; |
|
| 164 | 164 | |
| 165 | - foreach ($matches[ 0 ] as $i => $match) {
|
|
| 165 | + foreach ($matches[0] as $i => $match) {
|
|
| 166 | 166 | $source = str_replace($match, 'ᐃ' . ($i + 1) . 'ᐃ', $source); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | foreach ($patterns as $pattern => $rule) {
|
| 197 | 197 | if ($match = preg_match($pattern, $source, $matches)) {
|
| 198 | 198 | if (function_exists('mb_substr')) {
|
| 199 | - $source = mb_substr($source, mb_strlen($matches[ 0 ])); |
|
| 199 | + $source = mb_substr($source, mb_strlen($matches[0])); |
|
| 200 | 200 | } else {
|
| 201 | - $source = substr($source, strlen($matches[ 0 ])); |
|
| 201 | + $source = substr($source, strlen($matches[0])); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | if ($rule === static::MATCH_DISCARD) {
|
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $indentationLevel = 0; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - $output .= str_repeat($this->indentCharacter, $indentationLevel) . $matches[ 0 ] . "\n"; |
|
| 223 | + $output .= str_repeat($this->indentCharacter, $indentationLevel) . $matches[0] . "\n"; |
|
| 224 | 224 | |
| 225 | 225 | break; |
| 226 | 226 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | if (in_array($this->tagName, $selfClosingTags)) { |
| 102 | 102 | $attr = $this->attributes; |
| 103 | - unset($attr[ 'realpath' ]); |
|
| 103 | + unset($attr['realpath']); |
|
| 104 | 104 | |
| 105 | 105 | if ($this->hasAttributes()) { |
| 106 | 106 | return '<' . $this->tagName . ' ' . trim($this->attributes->__toString()) . '>'; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function open() |
| 146 | 146 | { |
| 147 | 147 | $attr = $this->attributes; |
| 148 | - unset($attr[ 'realpath' ]); |
|
| 148 | + unset($attr['realpath']); |
|
| 149 | 149 | |
| 150 | 150 | if ($this->hasAttributes()) { |
| 151 | 151 | return '<' . $this->tagName . ' ' . trim($this->attributes->__toString()) . '>'; |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * @param $className |
| 17 | 17 | */ |
| 18 | 18 | spl_autoload_register( |
| 19 | - function ($className) {
|
|
| 19 | + function($className) {
|
|
| 20 | 20 | if (strpos($className, 'O2System\Html\\') === false) {
|
| 21 | 21 | return; |
| 22 | 22 | } |
@@ -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 | } |