Skip to content

Commit 200cd8b

Browse files
Merge branch '5.3' into 5.4
* 5.3: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 1ad14c6 + 316ad33 commit 200cd8b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

AbstractUriElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function canonicalizePath(string $path)
103103
return $path;
104104
}
105105

106-
if ('.' === substr($path, -1)) {
106+
if (str_ends_with($path, '.')) {
107107
$path .= '/';
108108
}
109109

Crawler.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function add($node)
154154
public function addContent(string $content, string $type = null)
155155
{
156156
if (empty($type)) {
157-
$type = 0 === strpos($content, '<?xml') ? 'application/xml' : 'text/html';
157+
$type = str_starts_with($content, '<?xml') ? 'application/xml' : 'text/html';
158158
}
159159

160160
// DOM only for HTML/XML content
@@ -966,11 +966,11 @@ public function registerNamespace(string $prefix, string $namespace)
966966
*/
967967
public static function xpathLiteral(string $s)
968968
{
969-
if (false === strpos($s, "'")) {
969+
if (!str_contains($s, "'")) {
970970
return sprintf("'%s'", $s);
971971
}
972972

973-
if (false === strpos($s, '"')) {
973+
if (!str_contains($s, '"')) {
974974
return sprintf('"%s"', $s);
975975
}
976976

@@ -1065,29 +1065,29 @@ private function relativize(string $xpath): string
10651065
}
10661066
$expression = rtrim(substr($xpath, $startPosition, $i - $startPosition));
10671067

1068-
if (0 === strpos($expression, 'self::*/')) {
1068+
if (str_starts_with($expression, 'self::*/')) {
10691069
$expression = './'.substr($expression, 8);
10701070
}
10711071

10721072
// add prefix before absolute element selector
10731073
if ('' === $expression) {
10741074
$expression = $nonMatchingExpression;
1075-
} elseif (0 === strpos($expression, '//')) {
1075+
} elseif (str_starts_with($expression, '//')) {
10761076
$expression = 'descendant-or-self::'.substr($expression, 2);
1077-
} elseif (0 === strpos($expression, './/')) {
1077+
} elseif (str_starts_with($expression, './/')) {
10781078
$expression = 'descendant-or-self::'.substr($expression, 3);
1079-
} elseif (0 === strpos($expression, './')) {
1079+
} elseif (str_starts_with($expression, './')) {
10801080
$expression = 'self::'.substr($expression, 2);
1081-
} elseif (0 === strpos($expression, 'child::')) {
1081+
} elseif (str_starts_with($expression, 'child::')) {
10821082
$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::')) {
10841084
$expression = $nonMatchingExpression;
1085-
} elseif (0 === strpos($expression, 'descendant::')) {
1085+
} elseif (str_starts_with($expression, 'descendant::')) {
10861086
$expression = 'descendant-or-self::'.substr($expression, 12);
10871087
} elseif (preg_match('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/', $expression)) {
10881088
// the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes)
10891089
$expression = $nonMatchingExpression;
1090-
} elseif (0 !== strpos($expression, 'descendant-or-self::')) {
1090+
} elseif (!str_starts_with($expression, 'descendant-or-self::')) {
10911091
$expression = 'self::'.$expression;
10921092
}
10931093
$expressions[] = $parenthesis.$expression;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"symfony/deprecation-contracts": "^2.1",
2121
"symfony/polyfill-ctype": "~1.8",
2222
"symfony/polyfill-mbstring": "~1.0",
23-
"symfony/polyfill-php80": "^1.15"
23+
"symfony/polyfill-php80": "^1.16"
2424
},
2525
"require-dev": {
2626
"symfony/css-selector": "^4.4|^5.0|^6.0",

0 commit comments

Comments
 (0)