@@ -152,7 +152,7 @@ public function add($node)
152
152
public function addContent (string $ content , string $ type = null )
153
153
{
154
154
if (empty ($ type )) {
155
- $ type = 0 === strpos ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
155
+ $ type = str_starts_with ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
156
156
}
157
157
158
158
// DOM only for HTML/XML content
@@ -964,11 +964,11 @@ public function registerNamespace(string $prefix, string $namespace)
964
964
*/
965
965
public static function xpathLiteral (string $ s )
966
966
{
967
- if (false === strpos ($ s , "' " )) {
967
+ if (! str_contains ($ s , "' " )) {
968
968
return sprintf ("'%s' " , $ s );
969
969
}
970
970
971
- if (false === strpos ($ s , '" ' )) {
971
+ if (! str_contains ($ s , '" ' )) {
972
972
return sprintf ('"%s" ' , $ s );
973
973
}
974
974
@@ -1063,29 +1063,29 @@ private function relativize(string $xpath): string
1063
1063
}
1064
1064
$ expression = rtrim (substr ($ xpath , $ startPosition , $ i - $ startPosition ));
1065
1065
1066
- if (0 === strpos ($ expression , 'self::*/ ' )) {
1066
+ if (str_starts_with ($ expression , 'self::*/ ' )) {
1067
1067
$ expression = './ ' .substr ($ expression , 8 );
1068
1068
}
1069
1069
1070
1070
// add prefix before absolute element selector
1071
1071
if ('' === $ expression ) {
1072
1072
$ expression = $ nonMatchingExpression ;
1073
- } elseif (0 === strpos ($ expression , '// ' )) {
1073
+ } elseif (str_starts_with ($ expression , '// ' )) {
1074
1074
$ expression = 'descendant-or-self:: ' .substr ($ expression , 2 );
1075
- } elseif (0 === strpos ($ expression , '.// ' )) {
1075
+ } elseif (str_starts_with ($ expression , '.// ' )) {
1076
1076
$ expression = 'descendant-or-self:: ' .substr ($ expression , 3 );
1077
- } elseif (0 === strpos ($ expression , './ ' )) {
1077
+ } elseif (str_starts_with ($ expression , './ ' )) {
1078
1078
$ expression = 'self:: ' .substr ($ expression , 2 );
1079
- } elseif (0 === strpos ($ expression , 'child:: ' )) {
1079
+ } elseif (str_starts_with ($ expression , 'child:: ' )) {
1080
1080
$ expression = 'self:: ' .substr ($ expression , 7 );
1081
- } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || 0 === strpos ($ expression , 'self:: ' )) {
1081
+ } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || str_starts_with ($ expression , 'self:: ' )) {
1082
1082
$ expression = $ nonMatchingExpression ;
1083
- } elseif (0 === strpos ($ expression , 'descendant:: ' )) {
1083
+ } elseif (str_starts_with ($ expression , 'descendant:: ' )) {
1084
1084
$ expression = 'descendant-or-self:: ' .substr ($ expression , 12 );
1085
1085
} elseif (preg_match ('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/ ' , $ expression )) {
1086
1086
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
1087
1087
$ expression = $ nonMatchingExpression ;
1088
- } elseif (0 !== strpos ($ expression , 'descendant-or-self:: ' )) {
1088
+ } elseif (! str_starts_with ($ expression , 'descendant-or-self:: ' )) {
1089
1089
$ expression = 'self:: ' .$ expression ;
1090
1090
}
1091
1091
$ expressions [] = $ parenthesis .$ expression ;
0 commit comments