@@ -482,8 +482,8 @@ |
||
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
485 | - * @param $html |
|
486 | - * @param $decodeUtf8Specials |
|
485 | + * @param string $html |
|
486 | + * @param boolean $decodeUtf8Specials |
|
487 | 487 | * |
488 | 488 | * @return string |
489 | 489 | */ |
@@ -552,184 +552,184 @@ discard block |
||
552 | 552 | return \in_array($tag_name, self::$optional_end_tags, true) |
553 | 553 | || |
554 | 554 | ( |
555 | - $tag_name == 'li' |
|
555 | + $tag_name == 'li' |
|
556 | 556 | && |
557 | 557 | ( |
558 | - $nextSibling === null |
|
558 | + $nextSibling === null |
|
559 | 559 | || |
560 | 560 | ( |
561 | - $nextSibling instanceof \DOMElement |
|
561 | + $nextSibling instanceof \DOMElement |
|
562 | 562 | && |
563 | 563 | $nextSibling->tagName == 'li' |
564 | - ) |
|
565 | - ) |
|
566 | - ) |
|
564 | + ) |
|
565 | + ) |
|
566 | + ) |
|
567 | 567 | || |
568 | 568 | ( |
569 | - ( |
|
570 | - $tag_name == 'rp' |
|
571 | - ) |
|
569 | + ( |
|
570 | + $tag_name == 'rp' |
|
571 | + ) |
|
572 | 572 | && |
573 | 573 | ( |
574 | - $nextSibling === null |
|
574 | + $nextSibling === null |
|
575 | 575 | || |
576 | 576 | ( |
577 | - $nextSibling instanceof \DOMElement |
|
577 | + $nextSibling instanceof \DOMElement |
|
578 | 578 | && |
579 | 579 | ( |
580 | - $nextSibling->tagName == 'rp' |
|
580 | + $nextSibling->tagName == 'rp' |
|
581 | 581 | || |
582 | 582 | $nextSibling->tagName == 'rt' |
583 | - ) |
|
584 | - ) |
|
585 | - ) |
|
586 | - ) |
|
583 | + ) |
|
584 | + ) |
|
585 | + ) |
|
586 | + ) |
|
587 | 587 | || |
588 | 588 | ( |
589 | - $tag_name == 'tr' |
|
589 | + $tag_name == 'tr' |
|
590 | 590 | && |
591 | 591 | ( |
592 | - $nextSibling === null |
|
592 | + $nextSibling === null |
|
593 | 593 | || |
594 | 594 | ( |
595 | - $nextSibling instanceof \DOMElement |
|
595 | + $nextSibling instanceof \DOMElement |
|
596 | 596 | && |
597 | 597 | $nextSibling->tagName == 'tr' |
598 | - ) |
|
599 | - ) |
|
600 | - ) |
|
598 | + ) |
|
599 | + ) |
|
600 | + ) |
|
601 | 601 | || |
602 | 602 | ( |
603 | - ( |
|
604 | - $tag_name == 'td' |
|
603 | + ( |
|
604 | + $tag_name == 'td' |
|
605 | 605 | || |
606 | 606 | $tag_name == 'th' |
607 | - ) |
|
607 | + ) |
|
608 | 608 | && |
609 | 609 | ( |
610 | - $nextSibling === null |
|
610 | + $nextSibling === null |
|
611 | 611 | || |
612 | 612 | ( |
613 | - $nextSibling instanceof \DOMElement |
|
613 | + $nextSibling instanceof \DOMElement |
|
614 | 614 | && |
615 | 615 | ( |
616 | - $nextSibling->tagName == 'td' |
|
616 | + $nextSibling->tagName == 'td' |
|
617 | 617 | || |
618 | 618 | $nextSibling->tagName == 'th' |
619 | - ) |
|
620 | - ) |
|
621 | - ) |
|
622 | - ) |
|
619 | + ) |
|
620 | + ) |
|
621 | + ) |
|
622 | + ) |
|
623 | 623 | || |
624 | 624 | ( |
625 | - ( |
|
626 | - $tag_name == 'dd' |
|
625 | + ( |
|
626 | + $tag_name == 'dd' |
|
627 | 627 | || |
628 | 628 | $tag_name == 'dt' |
629 | - ) |
|
629 | + ) |
|
630 | 630 | && |
631 | 631 | ( |
632 | - ( |
|
633 | - $nextSibling === null |
|
632 | + ( |
|
633 | + $nextSibling === null |
|
634 | 634 | && |
635 | 635 | $tag_name == 'dd' |
636 | - ) |
|
636 | + ) |
|
637 | 637 | || |
638 | 638 | ( |
639 | - $nextSibling instanceof \DOMElement |
|
639 | + $nextSibling instanceof \DOMElement |
|
640 | 640 | && |
641 | 641 | ( |
642 | - $nextSibling->tagName == 'dd' |
|
642 | + $nextSibling->tagName == 'dd' |
|
643 | 643 | || |
644 | 644 | $nextSibling->tagName == 'dt' |
645 | - ) |
|
646 | - ) |
|
647 | - ) |
|
648 | - ) |
|
645 | + ) |
|
646 | + ) |
|
647 | + ) |
|
648 | + ) |
|
649 | 649 | || |
650 | 650 | ( |
651 | - $tag_name == 'option' |
|
651 | + $tag_name == 'option' |
|
652 | 652 | && |
653 | 653 | ( |
654 | - $nextSibling === null |
|
654 | + $nextSibling === null |
|
655 | 655 | || |
656 | 656 | ( |
657 | - $nextSibling instanceof \DOMElement |
|
657 | + $nextSibling instanceof \DOMElement |
|
658 | 658 | && |
659 | 659 | ( |
660 | - $nextSibling->tagName == 'option' |
|
660 | + $nextSibling->tagName == 'option' |
|
661 | 661 | || |
662 | 662 | $nextSibling->tagName == 'optgroup' |
663 | - ) |
|
664 | - ) |
|
665 | - ) |
|
666 | - ) |
|
663 | + ) |
|
664 | + ) |
|
665 | + ) |
|
666 | + ) |
|
667 | 667 | || |
668 | 668 | ( |
669 | - $tag_name == 'p' |
|
669 | + $tag_name == 'p' |
|
670 | 670 | && |
671 | 671 | ( |
672 | - ( |
|
673 | - $nextSibling === null |
|
672 | + ( |
|
673 | + $nextSibling === null |
|
674 | 674 | && |
675 | 675 | ( |
676 | - $node->parentNode !== null |
|
676 | + $node->parentNode !== null |
|
677 | 677 | && |
678 | 678 | !\in_array( |
679 | - $node->parentNode->tagName, |
|
680 | - [ |
|
681 | - 'a', |
|
682 | - 'audio', |
|
683 | - 'del', |
|
684 | - 'ins', |
|
685 | - 'map', |
|
686 | - 'noscript', |
|
687 | - 'video', |
|
688 | - ], |
|
689 | - true |
|
690 | - ) |
|
691 | - ) |
|
692 | - ) |
|
679 | + $node->parentNode->tagName, |
|
680 | + [ |
|
681 | + 'a', |
|
682 | + 'audio', |
|
683 | + 'del', |
|
684 | + 'ins', |
|
685 | + 'map', |
|
686 | + 'noscript', |
|
687 | + 'video', |
|
688 | + ], |
|
689 | + true |
|
690 | + ) |
|
691 | + ) |
|
692 | + ) |
|
693 | 693 | || |
694 | 694 | ( |
695 | - $nextSibling instanceof \DOMElement |
|
695 | + $nextSibling instanceof \DOMElement |
|
696 | 696 | && |
697 | 697 | \in_array( |
698 | - $nextSibling->tagName, |
|
699 | - [ |
|
700 | - 'address', |
|
701 | - 'article', |
|
702 | - 'aside', |
|
703 | - 'blockquote', |
|
704 | - 'dir', |
|
705 | - 'div', |
|
706 | - 'dl', |
|
707 | - 'fieldset', |
|
708 | - 'footer', |
|
709 | - 'form', |
|
710 | - 'h1', |
|
711 | - 'h2', |
|
712 | - 'h3', |
|
713 | - 'h4', |
|
714 | - 'h5', |
|
715 | - 'h6', |
|
716 | - 'header', |
|
717 | - 'hgroup', |
|
718 | - 'hr', |
|
719 | - 'menu', |
|
720 | - 'nav', |
|
721 | - 'ol', |
|
722 | - 'p', |
|
723 | - 'pre', |
|
724 | - 'section', |
|
725 | - 'table', |
|
726 | - 'ul', |
|
727 | - ], |
|
728 | - true |
|
729 | - ) |
|
730 | - ) |
|
731 | - ) |
|
732 | - ); |
|
698 | + $nextSibling->tagName, |
|
699 | + [ |
|
700 | + 'address', |
|
701 | + 'article', |
|
702 | + 'aside', |
|
703 | + 'blockquote', |
|
704 | + 'dir', |
|
705 | + 'div', |
|
706 | + 'dl', |
|
707 | + 'fieldset', |
|
708 | + 'footer', |
|
709 | + 'form', |
|
710 | + 'h1', |
|
711 | + 'h2', |
|
712 | + 'h3', |
|
713 | + 'h4', |
|
714 | + 'h5', |
|
715 | + 'h6', |
|
716 | + 'header', |
|
717 | + 'hgroup', |
|
718 | + 'hr', |
|
719 | + 'menu', |
|
720 | + 'nav', |
|
721 | + 'ol', |
|
722 | + 'p', |
|
723 | + 'pre', |
|
724 | + 'section', |
|
725 | + 'table', |
|
726 | + 'ul', |
|
727 | + ], |
|
728 | + true |
|
729 | + ) |
|
730 | + ) |
|
731 | + ) |
|
732 | + ); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | protected function domNodeToString(\DOMNode $node): string |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | } |
758 | 758 | |
759 | 759 | $html .= '<!DOCTYPE ' . $child->name . '' |
760 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
761 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
762 | - . '>'; |
|
760 | + . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
761 | + . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
762 | + . '>'; |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | } elseif ($child instanceof \DOMElement) { |
@@ -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 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 0 == \preg_match('/["\'=<>` \t\r\n\f]+/', $attribute->value); |
505 | 505 | |
506 | 506 | $attr_val = $attribute->value; |
507 | - $attrstr .= ($omitquotes ? '' : '"') . $attr_val . ($omitquotes ? '' : '"'); |
|
507 | + $attrstr .= ($omitquotes ? '' : '"').$attr_val.($omitquotes ? '' : '"'); |
|
508 | 508 | $attrstr .= ' '; |
509 | 509 | } |
510 | 510 | } |
@@ -756,23 +756,23 @@ discard block |
||
756 | 756 | $tmpTypePublic = 'PUBLIC'; |
757 | 757 | } |
758 | 758 | |
759 | - $html .= '<!DOCTYPE ' . $child->name . '' |
|
760 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
761 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
759 | + $html .= '<!DOCTYPE '.$child->name.'' |
|
760 | + . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '') |
|
761 | + . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '') |
|
762 | 762 | . '>'; |
763 | 763 | } |
764 | 764 | |
765 | 765 | } elseif ($child instanceof \DOMElement) { |
766 | 766 | |
767 | - $html .= trim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
|
768 | - $html .= '>' . $this->domNodeToString($child); |
|
767 | + $html .= trim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child)); |
|
768 | + $html .= '>'.$this->domNodeToString($child); |
|
769 | 769 | |
770 | 770 | if ( |
771 | 771 | $this->doRemoveOmittedHtmlTags === false |
772 | 772 | || |
773 | 773 | !$this->domNodeClosingTagOptional($child) |
774 | 774 | ) { |
775 | - $html .= '</' . $child->tagName . '>'; |
|
775 | + $html .= '</'.$child->tagName.'>'; |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | if ($this->doRemoveWhitespaceAroundTags === false) { |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | */ |
853 | 853 | public function minify($html, $decodeUtf8Specials = false): string |
854 | 854 | { |
855 | - $html = (string)$html; |
|
855 | + $html = (string) $html; |
|
856 | 856 | if (!isset($html[0])) { |
857 | 857 | return ''; |
858 | 858 | } |
@@ -888,10 +888,10 @@ discard block |
||
888 | 888 | // ------------------------------------------------------------------------- |
889 | 889 | |
890 | 890 | // Remove extra white-space(s) between HTML attribute(s) |
891 | - $html = (string)\preg_replace_callback( |
|
891 | + $html = (string) \preg_replace_callback( |
|
892 | 892 | '#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#', |
893 | - function ($matches) { |
|
894 | - return '<' . $matches[1] . (string)\preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; |
|
893 | + function($matches) { |
|
894 | + return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>'; |
|
895 | 895 | }, |
896 | 896 | $html |
897 | 897 | ); |
@@ -899,15 +899,15 @@ discard block |
||
899 | 899 | |
900 | 900 | if ($this->doRemoveSpacesBetweenTags === true) { |
901 | 901 | // Remove spaces that are between > and < |
902 | - $html = (string)\preg_replace('/(>) (<)/', '>$2', $html); |
|
902 | + $html = (string) \preg_replace('/(>) (<)/', '>$2', $html); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | // ------------------------------------------------------------------------- |
906 | 906 | // Restore protected HTML-code. |
907 | 907 | // ------------------------------------------------------------------------- |
908 | 908 | |
909 | - $html = (string)\preg_replace_callback( |
|
910 | - '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/', |
|
909 | + $html = (string) \preg_replace_callback( |
|
910 | + '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/', |
|
911 | 911 | [$this, 'restoreProtectedHtml'], |
912 | 912 | $html |
913 | 913 | ); |
@@ -928,14 +928,14 @@ discard block |
||
928 | 928 | |
929 | 929 | $html = \str_replace( |
930 | 930 | [ |
931 | - 'html>' . "\n", |
|
932 | - "\n" . '<html', |
|
933 | - 'html/>' . "\n", |
|
934 | - "\n" . '</html', |
|
935 | - 'head>' . "\n", |
|
936 | - "\n" . '<head', |
|
937 | - 'head/>' . "\n", |
|
938 | - "\n" . '</head', |
|
931 | + 'html>'."\n", |
|
932 | + "\n".'<html', |
|
933 | + 'html/>'."\n", |
|
934 | + "\n".'</html', |
|
935 | + 'head>'."\n", |
|
936 | + "\n".'<head', |
|
937 | + 'head/>'."\n", |
|
938 | + "\n".'</head', |
|
939 | 939 | ], |
940 | 940 | [ |
941 | 941 | 'html>', |
@@ -954,10 +954,10 @@ discard block |
||
954 | 954 | $replace = []; |
955 | 955 | $replacement = []; |
956 | 956 | foreach (self::$selfClosingTags as $selfClosingTag) { |
957 | - $replace[] = '<' . $selfClosingTag . '/>'; |
|
958 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
959 | - $replace[] = '<' . $selfClosingTag . ' />'; |
|
960 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
957 | + $replace[] = '<'.$selfClosingTag.'/>'; |
|
958 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
959 | + $replace[] = '<'.$selfClosingTag.' />'; |
|
960 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
961 | 961 | } |
962 | 962 | $html = \str_replace( |
963 | 963 | $replace, |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | $html |
966 | 966 | ); |
967 | 967 | |
968 | - $html = (string)\preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]+)><\/\b\1>#', '<\\1\\2>', $html); |
|
968 | + $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]+)><\/\b\1>#', '<\\1\\2>', $html); |
|
969 | 969 | |
970 | 970 | // ------------------------------------ |
971 | 971 | // check if compression worked |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | $attrs = []; |
1067 | - foreach ((array)$attributes as $attrName => $attrValue) { |
|
1067 | + foreach ((array) $attributes as $attrName => $attrValue) { |
|
1068 | 1068 | |
1069 | 1069 | // ------------------------------------------------------------------------- |
1070 | 1070 | // Remove optional "http:"-prefix from attributes. |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | $this->protectedChildNodes[$counter] = $element->text(); |
1142 | - $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
1142 | + $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
1143 | 1143 | |
1144 | 1144 | ++$counter; |
1145 | 1145 | } |
@@ -1154,11 +1154,11 @@ discard block |
||
1154 | 1154 | continue; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - $this->protectedChildNodes[$counter] = '<!--' . $text . '-->'; |
|
1157 | + $this->protectedChildNodes[$counter] = '<!--'.$text.'-->'; |
|
1158 | 1158 | |
1159 | 1159 | /* @var $node \DOMComment */ |
1160 | 1160 | $node = $element->getNode(); |
1161 | - $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'); |
|
1161 | + $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'); |
|
1162 | 1162 | $element->getNode()->parentNode->replaceChild($child, $node); |
1163 | 1163 | |
1164 | 1164 | ++$counter; |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | continue; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | - $attrValue .= \trim($class) . ' '; |
|
1358 | + $attrValue .= \trim($class).' '; |
|
1359 | 1359 | } |
1360 | 1360 | $attrValue = \trim($attrValue); |
1361 | 1361 |