@@ -136,7 +136,7 @@ public function add(\DOMNodeList|\DOMNode|array|string|null $node)
136
136
public function addContent (string $ content , string $ type = null )
137
137
{
138
138
if (empty ($ type )) {
139
- $ type = 0 === strpos ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
139
+ $ type = str_starts_with ($ content , '<?xml ' ) ? 'application/xml ' : 'text/html ' ;
140
140
}
141
141
142
142
// DOM only for HTML/XML content
@@ -928,11 +928,11 @@ public function registerNamespace(string $prefix, string $namespace)
928
928
*/
929
929
public static function xpathLiteral (string $ s )
930
930
{
931
- if (false === strpos ($ s , "' " )) {
931
+ if (! str_contains ($ s , "' " )) {
932
932
return sprintf ("'%s' " , $ s );
933
933
}
934
934
935
- if (false === strpos ($ s , '" ' )) {
935
+ if (! str_contains ($ s , '" ' )) {
936
936
return sprintf ('"%s" ' , $ s );
937
937
}
938
938
@@ -1027,29 +1027,29 @@ private function relativize(string $xpath): string
1027
1027
}
1028
1028
$ expression = rtrim (substr ($ xpath , $ startPosition , $ i - $ startPosition ));
1029
1029
1030
- if (0 === strpos ($ expression , 'self::*/ ' )) {
1030
+ if (str_starts_with ($ expression , 'self::*/ ' )) {
1031
1031
$ expression = './ ' .substr ($ expression , 8 );
1032
1032
}
1033
1033
1034
1034
// add prefix before absolute element selector
1035
1035
if ('' === $ expression ) {
1036
1036
$ expression = $ nonMatchingExpression ;
1037
- } elseif (0 === strpos ($ expression , '// ' )) {
1037
+ } elseif (str_starts_with ($ expression , '// ' )) {
1038
1038
$ expression = 'descendant-or-self:: ' .substr ($ expression , 2 );
1039
- } elseif (0 === strpos ($ expression , '.// ' )) {
1039
+ } elseif (str_starts_with ($ expression , '.// ' )) {
1040
1040
$ expression = 'descendant-or-self:: ' .substr ($ expression , 3 );
1041
- } elseif (0 === strpos ($ expression , './ ' )) {
1041
+ } elseif (str_starts_with ($ expression , './ ' )) {
1042
1042
$ expression = 'self:: ' .substr ($ expression , 2 );
1043
- } elseif (0 === strpos ($ expression , 'child:: ' )) {
1043
+ } elseif (str_starts_with ($ expression , 'child:: ' )) {
1044
1044
$ expression = 'self:: ' .substr ($ expression , 7 );
1045
- } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || 0 === strpos ($ expression , 'self:: ' )) {
1045
+ } elseif ('/ ' === $ expression [0 ] || '. ' === $ expression [0 ] || str_starts_with ($ expression , 'self:: ' )) {
1046
1046
$ expression = $ nonMatchingExpression ;
1047
- } elseif (0 === strpos ($ expression , 'descendant:: ' )) {
1047
+ } elseif (str_starts_with ($ expression , 'descendant:: ' )) {
1048
1048
$ expression = 'descendant-or-self:: ' .substr ($ expression , 12 );
1049
1049
} elseif (preg_match ('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/ ' , $ expression )) {
1050
1050
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
1051
1051
$ expression = $ nonMatchingExpression ;
1052
- } elseif (0 !== strpos ($ expression , 'descendant-or-self:: ' )) {
1052
+ } elseif (! str_starts_with ($ expression , 'descendant-or-self:: ' )) {
1053
1053
$ expression = 'self:: ' .$ expression ;
1054
1054
}
1055
1055
$ expressions [] = $ parenthesis .$ expression ;
0 commit comments