Skip to content

Commit 16c6e31

Browse files
committed
Leverage str_ends_with
added the php80 polyfill to requirements when necessary
1 parent 865c443 commit 16c6e31

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

Generator/UrlGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
221221
// so we need to encode them as they are not used for this purpose here
222222
// otherwise we would generate a URI that, when followed by a user agent (e.g. browser), does not match this route
223223
$url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']);
224-
if ('/..' === substr($url, -3)) {
224+
if (str_ends_with($url, '/..')) {
225225
$url = substr($url, 0, -2).'%2E%2E';
226-
} elseif ('/.' === substr($url, -2)) {
226+
} elseif (str_ends_with($url, '/.')) {
227227
$url = substr($url, 0, -1).'%2E';
228228
}
229229

Loader/AnnotationDirectoryLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function (\SplFileInfo $current) {
5454
});
5555

5656
foreach ($files as $file) {
57-
if (!$file->isFile() || '.php' !== substr($file->getFilename(), -4)) {
57+
if (!$file->isFile() || !str_ends_with($file->getFilename(), '.php')) {
5858
continue;
5959
}
6060

Route.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ private function sanitizeRequirement(string $key, $regex)
527527
$regex = (string) substr($regex, 1); // returns false for a single character
528528
}
529529

530-
if ('$' === substr($regex, -1)) {
530+
if (str_ends_with($regex, '$')) {
531531
$regex = substr($regex, 0, -1);
532532
}
533533

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=7.1.3"
19+
"php": ">=7.1.3",
20+
"symfony/polyfill-php80": "^1.16"
2021
},
2122
"require-dev": {
2223
"symfony/config": "^4.2|^5.0",

0 commit comments

Comments
 (0)