@@ -145,7 +145,7 @@ public function add($node)
145
145
public function addContent (string $ content , string $ type = null )
146
146
{
147
147
if (empty ($ type )) {
148
- $ type = 0 === strpos ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
148
+ $ type = str_starts_with ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
149
149
}
150
150
151
151
// DOM only for HTML/XML content
@@ -943,11 +943,11 @@ public function registerNamespace(string $prefix, string $namespace)
943
943
*/
944
944
public static function xpathLiteral (string $ s )
945
945
{
946
- if (false === strpos ($ s , "' " )) {
946
+ if (! str_contains ($ s , "' " )) {
947
947
return sprintf ("'%s' " , $ s );
948
948
}
949
949
950
- if (false === strpos ($ s , '" ' )) {
950
+ if (! str_contains ($ s , '" ' )) {
951
951
return sprintf ('"%s" ' , $ s );
952
952
}
953
953
@@ -1040,29 +1040,29 @@ private function relativize(string $xpath): string
1040
1040
}
1041
1041
$ expression = rtrim (substr ($ xpath , $ startPosition , $ i - $ startPosition ));
1042
1042
1043
- if (0 === strpos ($ expression , 'self::*/ ' )) {
1043
+ if (str_starts_with ($ expression , 'self::*/ ' )) {
1044
1044
$ expression = './ ' .substr ($ expression , 8 );
1045
1045
}
1046
1046
1047
1047
// add prefix before absolute element selector
1048
1048
if ('' === $ expression ) {
1049
1049
$ expression = $ nonMatchingExpression ;
1050
- } elseif (0 === strpos ($ expression , '// ' )) {
1050
+ } elseif (str_starts_with ($ expression , '// ' )) {
1051
1051
$ expression = 'descendant-or-self:: ' .substr ($ expression , 2 );
1052
- } elseif (0 === strpos ($ expression , '.// ' )) {
1052
+ } elseif (str_starts_with ($ expression , '.// ' )) {
1053
1053
$ expression = 'descendant-or-self:: ' .substr ($ expression , 3 );
1054
- } elseif (0 === strpos ($ expression , './ ' )) {
1054
+ } elseif (str_starts_with ($ expression , './ ' )) {
1055
1055
$ expression = 'self:: ' .substr ($ expression , 2 );
1056
- } elseif (0 === strpos ($ expression , 'child:: ' )) {
1056
+ } elseif (str_starts_with ($ expression , 'child:: ' )) {
1057
1057
$ expression = 'self:: ' .substr ($ expression , 7 );
1058
- } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || 0 === strpos ($ expression , 'self:: ' )) {
1058
+ } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || str_starts_with ($ expression , 'self:: ' )) {
1059
1059
$ expression = $ nonMatchingExpression ;
1060
- } elseif (0 === strpos ($ expression , 'descendant:: ' )) {
1060
+ } elseif (str_starts_with ($ expression , 'descendant:: ' )) {
1061
1061
$ expression = 'descendant-or-self:: ' .substr ($ expression , 12 );
1062
1062
} elseif (preg_match ('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/ ' , $ expression )) {
1063
1063
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
1064
1064
$ expression = $ nonMatchingExpression ;
1065
- } elseif (0 !== strpos ($ expression , 'descendant-or-self:: ' )) {
1065
+ } elseif (! str_starts_with ($ expression , 'descendant-or-self:: ' )) {
1066
1066
$ expression = 'self:: ' .$ expression ;
1067
1067
}
1068
1068
$ expressions [] = $ parenthesis .$ expression ;
0 commit comments