@@ -1175,8 +1175,8 @@ |
||
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | /** |
| 1178 | - * @param $html |
|
| 1179 | - * @param $decodeUtf8Specials |
|
| 1178 | + * @param string $html |
|
| 1179 | + * @param boolean $decodeUtf8Specials |
|
| 1180 | 1180 | * |
| 1181 | 1181 | * @return string |
| 1182 | 1182 | */ |
@@ -736,184 +736,184 @@ discard block |
||
| 736 | 736 | return \in_array($tag_name, self::$optional_end_tags, true) |
| 737 | 737 | || |
| 738 | 738 | ( |
| 739 | - $tag_name === 'li' |
|
| 739 | + $tag_name === 'li' |
|
| 740 | 740 | && |
| 741 | 741 | ( |
| 742 | - $nextSibling === null |
|
| 742 | + $nextSibling === null |
|
| 743 | 743 | || |
| 744 | 744 | ( |
| 745 | - $nextSibling instanceof \DOMElement |
|
| 745 | + $nextSibling instanceof \DOMElement |
|
| 746 | 746 | && |
| 747 | 747 | $nextSibling->tagName === 'li' |
| 748 | - ) |
|
| 749 | - ) |
|
| 750 | - ) |
|
| 748 | + ) |
|
| 749 | + ) |
|
| 750 | + ) |
|
| 751 | 751 | || |
| 752 | 752 | ( |
| 753 | - ( |
|
| 754 | - $tag_name === 'rp' |
|
| 755 | - ) |
|
| 753 | + ( |
|
| 754 | + $tag_name === 'rp' |
|
| 755 | + ) |
|
| 756 | 756 | && |
| 757 | 757 | ( |
| 758 | - $nextSibling === null |
|
| 758 | + $nextSibling === null |
|
| 759 | 759 | || |
| 760 | 760 | ( |
| 761 | - $nextSibling instanceof \DOMElement |
|
| 761 | + $nextSibling instanceof \DOMElement |
|
| 762 | 762 | && |
| 763 | 763 | ( |
| 764 | - $nextSibling->tagName === 'rp' |
|
| 764 | + $nextSibling->tagName === 'rp' |
|
| 765 | 765 | || |
| 766 | 766 | $nextSibling->tagName === 'rt' |
| 767 | - ) |
|
| 768 | - ) |
|
| 769 | - ) |
|
| 770 | - ) |
|
| 767 | + ) |
|
| 768 | + ) |
|
| 769 | + ) |
|
| 770 | + ) |
|
| 771 | 771 | || |
| 772 | 772 | ( |
| 773 | - $tag_name === 'tr' |
|
| 773 | + $tag_name === 'tr' |
|
| 774 | 774 | && |
| 775 | 775 | ( |
| 776 | - $nextSibling === null |
|
| 776 | + $nextSibling === null |
|
| 777 | 777 | || |
| 778 | 778 | ( |
| 779 | - $nextSibling instanceof \DOMElement |
|
| 779 | + $nextSibling instanceof \DOMElement |
|
| 780 | 780 | && |
| 781 | 781 | $nextSibling->tagName === 'tr' |
| 782 | - ) |
|
| 783 | - ) |
|
| 784 | - ) |
|
| 782 | + ) |
|
| 783 | + ) |
|
| 784 | + ) |
|
| 785 | 785 | || |
| 786 | 786 | ( |
| 787 | - ( |
|
| 788 | - $tag_name === 'td' |
|
| 787 | + ( |
|
| 788 | + $tag_name === 'td' |
|
| 789 | 789 | || |
| 790 | 790 | $tag_name === 'th' |
| 791 | - ) |
|
| 791 | + ) |
|
| 792 | 792 | && |
| 793 | 793 | ( |
| 794 | - $nextSibling === null |
|
| 794 | + $nextSibling === null |
|
| 795 | 795 | || |
| 796 | 796 | ( |
| 797 | - $nextSibling instanceof \DOMElement |
|
| 797 | + $nextSibling instanceof \DOMElement |
|
| 798 | 798 | && |
| 799 | 799 | ( |
| 800 | - $nextSibling->tagName === 'td' |
|
| 800 | + $nextSibling->tagName === 'td' |
|
| 801 | 801 | || |
| 802 | 802 | $nextSibling->tagName === 'th' |
| 803 | - ) |
|
| 804 | - ) |
|
| 805 | - ) |
|
| 806 | - ) |
|
| 803 | + ) |
|
| 804 | + ) |
|
| 805 | + ) |
|
| 806 | + ) |
|
| 807 | 807 | || |
| 808 | 808 | ( |
| 809 | - ( |
|
| 810 | - $tag_name === 'dd' |
|
| 809 | + ( |
|
| 810 | + $tag_name === 'dd' |
|
| 811 | 811 | || |
| 812 | 812 | $tag_name === 'dt' |
| 813 | - ) |
|
| 813 | + ) |
|
| 814 | 814 | && |
| 815 | 815 | ( |
| 816 | - ( |
|
| 817 | - $nextSibling === null |
|
| 816 | + ( |
|
| 817 | + $nextSibling === null |
|
| 818 | 818 | && |
| 819 | 819 | $tag_name === 'dd' |
| 820 | - ) |
|
| 820 | + ) |
|
| 821 | 821 | || |
| 822 | 822 | ( |
| 823 | - $nextSibling instanceof \DOMElement |
|
| 823 | + $nextSibling instanceof \DOMElement |
|
| 824 | 824 | && |
| 825 | 825 | ( |
| 826 | - $nextSibling->tagName === 'dd' |
|
| 826 | + $nextSibling->tagName === 'dd' |
|
| 827 | 827 | || |
| 828 | 828 | $nextSibling->tagName === 'dt' |
| 829 | - ) |
|
| 830 | - ) |
|
| 831 | - ) |
|
| 832 | - ) |
|
| 829 | + ) |
|
| 830 | + ) |
|
| 831 | + ) |
|
| 832 | + ) |
|
| 833 | 833 | || |
| 834 | 834 | ( |
| 835 | - $tag_name === 'option' |
|
| 835 | + $tag_name === 'option' |
|
| 836 | 836 | && |
| 837 | 837 | ( |
| 838 | - $nextSibling === null |
|
| 838 | + $nextSibling === null |
|
| 839 | 839 | || |
| 840 | 840 | ( |
| 841 | - $nextSibling instanceof \DOMElement |
|
| 841 | + $nextSibling instanceof \DOMElement |
|
| 842 | 842 | && |
| 843 | 843 | ( |
| 844 | - $nextSibling->tagName === 'option' |
|
| 844 | + $nextSibling->tagName === 'option' |
|
| 845 | 845 | || |
| 846 | 846 | $nextSibling->tagName === 'optgroup' |
| 847 | - ) |
|
| 848 | - ) |
|
| 849 | - ) |
|
| 850 | - ) |
|
| 847 | + ) |
|
| 848 | + ) |
|
| 849 | + ) |
|
| 850 | + ) |
|
| 851 | 851 | || |
| 852 | 852 | ( |
| 853 | - $tag_name === 'p' |
|
| 853 | + $tag_name === 'p' |
|
| 854 | 854 | && |
| 855 | 855 | ( |
| 856 | - ( |
|
| 857 | - $nextSibling === null |
|
| 856 | + ( |
|
| 857 | + $nextSibling === null |
|
| 858 | 858 | && |
| 859 | 859 | ( |
| 860 | - $node->parentNode !== null |
|
| 860 | + $node->parentNode !== null |
|
| 861 | 861 | && |
| 862 | 862 | !\in_array( |
| 863 | - $node->parentNode->nodeName, |
|
| 864 | - [ |
|
| 865 | - 'a', |
|
| 866 | - 'audio', |
|
| 867 | - 'del', |
|
| 868 | - 'ins', |
|
| 869 | - 'map', |
|
| 870 | - 'noscript', |
|
| 871 | - 'video', |
|
| 872 | - ], |
|
| 873 | - true |
|
| 874 | - ) |
|
| 875 | - ) |
|
| 876 | - ) |
|
| 863 | + $node->parentNode->nodeName, |
|
| 864 | + [ |
|
| 865 | + 'a', |
|
| 866 | + 'audio', |
|
| 867 | + 'del', |
|
| 868 | + 'ins', |
|
| 869 | + 'map', |
|
| 870 | + 'noscript', |
|
| 871 | + 'video', |
|
| 872 | + ], |
|
| 873 | + true |
|
| 874 | + ) |
|
| 875 | + ) |
|
| 876 | + ) |
|
| 877 | 877 | || |
| 878 | 878 | ( |
| 879 | - $nextSibling instanceof \DOMElement |
|
| 879 | + $nextSibling instanceof \DOMElement |
|
| 880 | 880 | && |
| 881 | 881 | \in_array( |
| 882 | - $nextSibling->tagName, |
|
| 883 | - [ |
|
| 884 | - 'address', |
|
| 885 | - 'article', |
|
| 886 | - 'aside', |
|
| 887 | - 'blockquote', |
|
| 888 | - 'dir', |
|
| 889 | - 'div', |
|
| 890 | - 'dl', |
|
| 891 | - 'fieldset', |
|
| 892 | - 'footer', |
|
| 893 | - 'form', |
|
| 894 | - 'h1', |
|
| 895 | - 'h2', |
|
| 896 | - 'h3', |
|
| 897 | - 'h4', |
|
| 898 | - 'h5', |
|
| 899 | - 'h6', |
|
| 900 | - 'header', |
|
| 901 | - 'hgroup', |
|
| 902 | - 'hr', |
|
| 903 | - 'menu', |
|
| 904 | - 'nav', |
|
| 905 | - 'ol', |
|
| 906 | - 'p', |
|
| 907 | - 'pre', |
|
| 908 | - 'section', |
|
| 909 | - 'table', |
|
| 910 | - 'ul', |
|
| 911 | - ], |
|
| 912 | - true |
|
| 913 | - ) |
|
| 914 | - ) |
|
| 915 | - ) |
|
| 916 | - ); |
|
| 882 | + $nextSibling->tagName, |
|
| 883 | + [ |
|
| 884 | + 'address', |
|
| 885 | + 'article', |
|
| 886 | + 'aside', |
|
| 887 | + 'blockquote', |
|
| 888 | + 'dir', |
|
| 889 | + 'div', |
|
| 890 | + 'dl', |
|
| 891 | + 'fieldset', |
|
| 892 | + 'footer', |
|
| 893 | + 'form', |
|
| 894 | + 'h1', |
|
| 895 | + 'h2', |
|
| 896 | + 'h3', |
|
| 897 | + 'h4', |
|
| 898 | + 'h5', |
|
| 899 | + 'h6', |
|
| 900 | + 'header', |
|
| 901 | + 'hgroup', |
|
| 902 | + 'hr', |
|
| 903 | + 'menu', |
|
| 904 | + 'nav', |
|
| 905 | + 'ol', |
|
| 906 | + 'p', |
|
| 907 | + 'pre', |
|
| 908 | + 'section', |
|
| 909 | + 'table', |
|
| 910 | + 'ul', |
|
| 911 | + ], |
|
| 912 | + true |
|
| 913 | + ) |
|
| 914 | + ) |
|
| 915 | + ) |
|
| 916 | + ); |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | protected function domNodeToString(\DOMNode $node): string |
@@ -945,9 +945,9 @@ discard block |
||
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | $html .= '<!DOCTYPE ' . $child->name . '' |
| 948 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
| 949 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
| 950 | - . '>'; |
|
| 948 | + . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
| 949 | + . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
| 950 | + . '>'; |
|
| 951 | 951 | } |
| 952 | 952 | } elseif ($child instanceof \DOMElement) { |
| 953 | 953 | $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $attr_val = $attribute->value; |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - $attr_str .= ($omit_quotes ? '' : $quoteTmp) . $attr_val . ($omit_quotes ? '' : $quoteTmp); |
|
| 708 | + $attr_str .= ($omit_quotes ? '' : $quoteTmp).$attr_val.($omit_quotes ? '' : $quoteTmp); |
|
| 709 | 709 | $attr_str .= ' '; |
| 710 | 710 | } |
| 711 | 711 | } |
@@ -966,21 +966,21 @@ discard block |
||
| 966 | 966 | $tmpTypePublic = 'PUBLIC'; |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - $html .= '<!DOCTYPE ' . $child->name . '' |
|
| 970 | - . ($child->publicId ? ' ' . $tmpTypePublic . ' "' . $child->publicId . '"' : '') |
|
| 971 | - . ($child->systemId ? ' ' . $tmpTypeSystem . ' "' . $child->systemId . '"' : '') |
|
| 969 | + $html .= '<!DOCTYPE '.$child->name.'' |
|
| 970 | + . ($child->publicId ? ' '.$tmpTypePublic.' "'.$child->publicId.'"' : '') |
|
| 971 | + . ($child->systemId ? ' '.$tmpTypeSystem.' "'.$child->systemId.'"' : '') |
|
| 972 | 972 | . '>'; |
| 973 | 973 | } |
| 974 | 974 | } elseif ($child instanceof \DOMElement) { |
| 975 | - $html .= \rtrim('<' . $child->tagName . ' ' . $this->domNodeAttributesToString($child)); |
|
| 976 | - $html .= '>' . $this->domNodeToString($child); |
|
| 975 | + $html .= \rtrim('<'.$child->tagName.' '.$this->domNodeAttributesToString($child)); |
|
| 976 | + $html .= '>'.$this->domNodeToString($child); |
|
| 977 | 977 | |
| 978 | 978 | if ( |
| 979 | 979 | !$this->doRemoveOmittedHtmlTags |
| 980 | 980 | || |
| 981 | 981 | !$this->domNodeClosingTagOptional($child) |
| 982 | 982 | ) { |
| 983 | - $html .= '</' . $child->tagName . '>'; |
|
| 983 | + $html .= '</'.$child->tagName.'>'; |
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | 986 | if (!$this->doRemoveWhitespaceAroundTags) { |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | $html .= $child->wholeText; |
| 1020 | 1020 | } |
| 1021 | 1021 | } elseif ($child instanceof \DOMComment) { |
| 1022 | - $html .= '<!--' . $child->textContent . '-->'; |
|
| 1022 | + $html .= '<!--'.$child->textContent.'-->'; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | 1025 | |
@@ -1111,8 +1111,8 @@ discard block |
||
| 1111 | 1111 | // Remove extra white-space(s) between HTML attribute(s) |
| 1112 | 1112 | $html = (string) \preg_replace_callback( |
| 1113 | 1113 | '#<([^/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(/?)>#', |
| 1114 | - function ($matches) { |
|
| 1115 | - return '<' . $matches[1] . (string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; |
|
| 1114 | + function($matches) { |
|
| 1115 | + return '<'.$matches[1].(string) \preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]).$matches[3].'>'; |
|
| 1116 | 1116 | }, |
| 1117 | 1117 | $html |
| 1118 | 1118 | ); |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | // ------------------------------------------------------------------------- |
| 1128 | 1128 | |
| 1129 | 1129 | $html = (string) \preg_replace_callback( |
| 1130 | - '/<(?<element>' . $this->protectedChildNodesHelper . ')(?<attributes> [^>]*)?>(?<value>.*?)<\/' . $this->protectedChildNodesHelper . '>/', |
|
| 1130 | + '/<(?<element>'.$this->protectedChildNodesHelper.')(?<attributes> [^>]*)?>(?<value>.*?)<\/'.$this->protectedChildNodesHelper.'>/', |
|
| 1131 | 1131 | [$this, 'restoreProtectedHtml'], |
| 1132 | 1132 | $html |
| 1133 | 1133 | ); |
@@ -1146,14 +1146,14 @@ discard block |
||
| 1146 | 1146 | |
| 1147 | 1147 | $html = \str_replace( |
| 1148 | 1148 | [ |
| 1149 | - 'html>' . "\n", |
|
| 1150 | - "\n" . '<html', |
|
| 1151 | - 'html/>' . "\n", |
|
| 1152 | - "\n" . '</html', |
|
| 1153 | - 'head>' . "\n", |
|
| 1154 | - "\n" . '<head', |
|
| 1155 | - 'head/>' . "\n", |
|
| 1156 | - "\n" . '</head', |
|
| 1149 | + 'html>'."\n", |
|
| 1150 | + "\n".'<html', |
|
| 1151 | + 'html/>'."\n", |
|
| 1152 | + "\n".'</html', |
|
| 1153 | + 'head>'."\n", |
|
| 1154 | + "\n".'<head', |
|
| 1155 | + 'head/>'."\n", |
|
| 1156 | + "\n".'</head', |
|
| 1157 | 1157 | ], |
| 1158 | 1158 | [ |
| 1159 | 1159 | 'html>', |
@@ -1172,10 +1172,10 @@ discard block |
||
| 1172 | 1172 | $replace = []; |
| 1173 | 1173 | $replacement = []; |
| 1174 | 1174 | foreach (self::$selfClosingTags as $selfClosingTag) { |
| 1175 | - $replace[] = '<' . $selfClosingTag . '/>'; |
|
| 1176 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
| 1177 | - $replace[] = '<' . $selfClosingTag . ' />'; |
|
| 1178 | - $replacement[] = '<' . $selfClosingTag . '>'; |
|
| 1175 | + $replace[] = '<'.$selfClosingTag.'/>'; |
|
| 1176 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
| 1177 | + $replace[] = '<'.$selfClosingTag.' />'; |
|
| 1178 | + $replacement[] = '<'.$selfClosingTag.'>'; |
|
| 1179 | 1179 | } |
| 1180 | 1180 | $html = \str_replace( |
| 1181 | 1181 | $replace, |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $html |
| 1184 | 1184 | ); |
| 1185 | 1185 | |
| 1186 | - $html = (string) \preg_replace('#<\b(' . $CACHE_SELF_CLOSING_TAGS . ')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html); |
|
| 1186 | + $html = (string) \preg_replace('#<\b('.$CACHE_SELF_CLOSING_TAGS.')([^>]*+)><\/\b\1>#', '<\\1\\2>', $html); |
|
| 1187 | 1187 | |
| 1188 | 1188 | // ------------------------------------ |
| 1189 | 1189 | // check if compression worked |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | $this->protectedChildNodes[$counter] = $element->text(); |
| 1293 | - $element->getNode()->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
| 1293 | + $element->getNode()->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
| 1294 | 1294 | |
| 1295 | 1295 | ++$counter; |
| 1296 | 1296 | } |
@@ -1301,7 +1301,7 @@ discard block |
||
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | $this->protectedChildNodes[$counter] = $element->parentNode()->innerHtml(); |
| 1304 | - $element->getNode()->parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'; |
|
| 1304 | + $element->getNode()->parentNode->nodeValue = '<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'; |
|
| 1305 | 1305 | |
| 1306 | 1306 | ++$counter; |
| 1307 | 1307 | } |
@@ -1314,11 +1314,11 @@ discard block |
||
| 1314 | 1314 | continue; |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | - $this->protectedChildNodes[$counter] = '<!--' . $text . '-->'; |
|
| 1317 | + $this->protectedChildNodes[$counter] = '<!--'.$text.'-->'; |
|
| 1318 | 1318 | |
| 1319 | 1319 | /* @var $node \DOMComment */ |
| 1320 | 1320 | $node = $element->getNode(); |
| 1321 | - $child = new \DOMText('<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $counter . '"></' . $this->protectedChildNodesHelper . '>'); |
|
| 1321 | + $child = new \DOMText('<'.$this->protectedChildNodesHelper.' data-'.$this->protectedChildNodesHelper.'="'.$counter.'"></'.$this->protectedChildNodesHelper.'>'); |
|
| 1322 | 1322 | /** @noinspection UnusedFunctionResultInspection */ |
| 1323 | 1323 | $element->getNode()->parentNode->replaceChild($child, $node); |
| 1324 | 1324 | |
@@ -202,7 +202,7 @@ |
||
| 202 | 202 | continue; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $attrValue .= \trim($class) . ' '; |
|
| 205 | + $attrValue .= \trim($class).' '; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return \trim($attrValue); |