@@ -148,7 +148,7 @@ public function add($node)
148
148
public function addContent ($ content , $ type = null )
149
149
{
150
150
if (empty ($ type )) {
151
- $ type = 0 === strpos ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
151
+ $ type = str_starts_with ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
152
152
}
153
153
154
154
// DOM only for HTML/XML content
@@ -1001,11 +1001,11 @@ public function registerNamespace($prefix, $namespace)
1001
1001
*/
1002
1002
public static function xpathLiteral ($ s )
1003
1003
{
1004
- if (false === strpos ($ s , "' " )) {
1004
+ if (! str_contains ($ s , "' " )) {
1005
1005
return sprintf ("'%s' " , $ s );
1006
1006
}
1007
1007
1008
- if (false === strpos ($ s , '" ' )) {
1008
+ if (! str_contains ($ s , '" ' )) {
1009
1009
return sprintf ('"%s" ' , $ s );
1010
1010
}
1011
1011
@@ -1098,29 +1098,29 @@ private function relativize(string $xpath): string
1098
1098
}
1099
1099
$ expression = rtrim (substr ($ xpath , $ startPosition , $ i - $ startPosition ));
1100
1100
1101
- if (0 === strpos ($ expression , 'self::*/ ' )) {
1101
+ if (str_starts_with ($ expression , 'self::*/ ' )) {
1102
1102
$ expression = './ ' .substr ($ expression , 8 );
1103
1103
}
1104
1104
1105
1105
// add prefix before absolute element selector
1106
1106
if ('' === $ expression ) {
1107
1107
$ expression = $ nonMatchingExpression ;
1108
- } elseif (0 === strpos ($ expression , '// ' )) {
1108
+ } elseif (str_starts_with ($ expression , '// ' )) {
1109
1109
$ expression = 'descendant-or-self:: ' .substr ($ expression , 2 );
1110
- } elseif (0 === strpos ($ expression , '.// ' )) {
1110
+ } elseif (str_starts_with ($ expression , '.// ' )) {
1111
1111
$ expression = 'descendant-or-self:: ' .substr ($ expression , 3 );
1112
- } elseif (0 === strpos ($ expression , './ ' )) {
1112
+ } elseif (str_starts_with ($ expression , './ ' )) {
1113
1113
$ expression = 'self:: ' .substr ($ expression , 2 );
1114
- } elseif (0 === strpos ($ expression , 'child:: ' )) {
1114
+ } elseif (str_starts_with ($ expression , 'child:: ' )) {
1115
1115
$ expression = 'self:: ' .substr ($ expression , 7 );
1116
- } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || 0 === strpos ($ expression , 'self:: ' )) {
1116
+ } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || str_starts_with ($ expression , 'self:: ' )) {
1117
1117
$ expression = $ nonMatchingExpression ;
1118
- } elseif (0 === strpos ($ expression , 'descendant:: ' )) {
1118
+ } elseif (str_starts_with ($ expression , 'descendant:: ' )) {
1119
1119
$ expression = 'descendant-or-self:: ' .substr ($ expression , 12 );
1120
1120
} elseif (preg_match ('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/ ' , $ expression )) {
1121
1121
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
1122
1122
$ expression = $ nonMatchingExpression ;
1123
- } elseif (0 !== strpos ($ expression , 'descendant-or-self:: ' )) {
1123
+ } elseif (! str_starts_with ($ expression , 'descendant-or-self:: ' )) {
1124
1124
$ expression = 'self:: ' .$ expression ;
1125
1125
}
1126
1126
$ expressions [] = $ parenthesis .$ expression ;
0 commit comments