@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace voku\helper; |
6 | 6 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | # http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html#attributes-0 |
453 | 453 | $omitquotes = $attribute->value != '' && 0 == \preg_match('/["\'=<>` \t\r\n\f]+/', $attribute->value); |
454 | 454 | $attr_val = $attribute->value; |
455 | - $attrstr .= ($omitquotes ? '' : '"') . $attr_val . ($omitquotes ? '' : '"'); |
|
455 | + $attrstr .= ($omitquotes ? '' : '"').$attr_val.($omitquotes ? '' : '"'); |
|
456 | 456 | $attrstr .= ' '; |
457 | 457 | } |
458 | 458 | } |
@@ -578,11 +578,11 @@ discard block |
||
578 | 578 | |
579 | 579 | } else if ($child instanceof \DOMElement) { |
580 | 580 | |
581 | - $htmlstr .= trim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
|
582 | - $htmlstr .= '>' . $this->domNodeToString($child); |
|
581 | + $htmlstr .= trim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child)); |
|
582 | + $htmlstr .= '>'.$this->domNodeToString($child); |
|
583 | 583 | |
584 | 584 | if (!$this->domNodeClosingTagOptional($child)) { |
585 | - $htmlstr .= '</' . $child->tagName . '>'; |
|
585 | + $htmlstr .= '</'.$child->tagName.'>'; |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | } else if ($child instanceof \DOMText) { |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | |
606 | 606 | } else { |
607 | 607 | |
608 | - throw new \Exception('Error by: ' . print_r($child, true)); |
|
608 | + throw new \Exception('Error by: '.print_r($child, true)); |
|
609 | 609 | |
610 | 610 | } |
611 | 611 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | */ |
656 | 656 | public function minify($html, $decodeUtf8Specials = false): string |
657 | 657 | { |
658 | - $html = (string)$html; |
|
658 | + $html = (string) $html; |
|
659 | 659 | if (!isset($html[0])) { |
660 | 660 | return ''; |
661 | 661 | } |
@@ -691,10 +691,10 @@ discard block |
||
691 | 691 | // ------------------------------------------------------------------------- |
692 | 692 | |
693 | 693 | // Remove extra white-space(s) between HTML attribute(s) |
694 | - $html = (string)\preg_replace_callback( |
|
694 | + $html = (string) \preg_replace_callback( |
|
695 | 695 | '#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#', |
696 | - function ($matches) { |
|
697 | - return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; |
|
696 | + function($matches) { |
|
697 | + return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>'; |
|
698 | 698 | }, |
699 | 699 | $html |
700 | 700 | ); |
@@ -702,15 +702,15 @@ discard block |
||
702 | 702 | |
703 | 703 | if ($this->doRemoveSpacesBetweenTags === true) { |
704 | 704 | // Remove spaces that are between > and < |
705 | - $html = (string)\preg_replace('/(>) (<)/', '>$2', $html); |
|
705 | + $html = (string) \preg_replace('/(>) (<)/', '>$2', $html); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | // ------------------------------------------------------------------------- |
709 | 709 | // Restore protected HTML-code. |
710 | 710 | // ------------------------------------------------------------------------- |
711 | 711 | |
712 | - $html = (string)\preg_replace_callback( |
|
713 | - '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/', |
|
712 | + $html = (string) \preg_replace_callback( |
|
713 | + '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/', |
|
714 | 714 | [$this, 'restoreProtectedHtml'], |
715 | 715 | $html |
716 | 716 | ); |
@@ -731,14 +731,14 @@ discard block |
||
731 | 731 | |
732 | 732 | $html = \str_replace( |
733 | 733 | [ |
734 | - 'html>' . "\n", |
|
735 | - "\n" . '<html', |
|
736 | - 'html/>' . "\n", |
|
737 | - "\n" . '</html', |
|
738 | - 'head>' . "\n", |
|
739 | - "\n" . '<head', |
|
740 | - 'head/>' . "\n", |
|
741 | - "\n" . '</head', |
|
734 | + 'html>'."\n", |
|
735 | + "\n".'<html', |
|
736 | + 'html/>'."\n", |
|
737 | + "\n".'</html', |
|
738 | + 'head>'."\n", |
|
739 | + "\n".'<head', |
|
740 | + 'head/>'."\n", |
|
741 | + "\n".'</head', |
|
742 | 742 | ], |
743 | 743 | [ |
744 | 744 | 'html>', |
@@ -757,10 +757,10 @@ discard block |
||
757 | 757 | $replace = []; |
758 | 758 | $replacement = []; |
759 | 759 | foreach (self::$selfClosingTags as $selfClosingTag) { |
760 | - $replace[] = '<' . $selfClosingTag . '/>'; |
|
761 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
762 | - $replace[] = '<' . $selfClosingTag . ' />'; |
|
763 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
760 | + $replace[] = '<'.$selfClosingTag.'/>'; |
|
761 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
762 | + $replace[] = '<'.$selfClosingTag.' />'; |
|
763 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
764 | 764 | } |
765 | 765 | $html = \str_replace( |
766 | 766 | $replace, |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | } |
864 | 864 | |
865 | 865 | $attrs = []; |
866 | - foreach ((array)$attributes as $attrName => $attrValue) { |
|
866 | + foreach ((array) $attributes as $attrName => $attrValue) { |
|
867 | 867 | |
868 | 868 | if (isset(self::$booleanAttributes[$attrName])) { |
869 | 869 | continue; |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | } |
943 | 943 | |
944 | 944 | $this->protectedChildNodes[$counter] = $element->text(); |
945 | - $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
945 | + $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
946 | 946 | |
947 | 947 | ++$counter; |
948 | 948 | } |
@@ -957,11 +957,11 @@ discard block |
||
957 | 957 | continue; |
958 | 958 | } |
959 | 959 | |
960 | - $this->protectedChildNodes[$counter] = '<!--' . $text . '-->'; |
|
960 | + $this->protectedChildNodes[$counter] = '<!--'.$text.'-->'; |
|
961 | 961 | |
962 | 962 | /* @var $node \DOMComment */ |
963 | 963 | $node = $element->getNode(); |
964 | - $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'); |
|
964 | + $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'); |
|
965 | 965 | $element->getNode()->parentNode->replaceChild($child, $node); |
966 | 966 | |
967 | 967 | ++$counter; |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | continue; |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - $attrValue .= \trim($class) . ' '; |
|
1161 | + $attrValue .= \trim($class).' '; |
|
1162 | 1162 | } |
1163 | 1163 | $attrValue = \trim($attrValue); |
1164 | 1164 |