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