8000 Leverage str_ends_with by Tobion · Pull Request #41973 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function findExtension($name)
}
}

if ('Bundle' !== substr($name, -6)) {
if (!str_ends_with($name, 'Bundle')) {
$message = sprintf('No extensions with configuration available for "%s".', $name);
} else {
$message = sprintf('No extension with alias "%s" is enabled.', $name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
// the old cache dir name must not be longer than the real one to avoid exceeding
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
$oldCacheDir = substr($realCacheDir, 0, -1).(str_ends_with($realCacheDir, '~') ? '+' : '~');
$fs->remove($oldCacheDir);

if (!is_writable($realCacheDir)) {
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"symfony/http-foundation": "^4.4|^5.0",
"symfony/http-kernel": "^4.4",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.16",
"symfony/filesystem": "^3.4|^4.0|^5.0",
"symfony/finder": "^3.4|^4.0|^5.0",
"symfony/routing": "^4.4.12|^5.1.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private function getBundleTemplatePaths(ContainerBuilder $container, array $conf

private function normalizeBundleName(string $name): string
{
if ('Bundle' === substr($name, -6)) {
if (str_ends_with($name, 'Bundle')) {
$name = substr($name, 0, -6);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/TemplateIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getIterator()
}
foreach ($this->kernel->getBundles() as $bundle) {
$name = $bundle->getName();
if ('Bundle' === substr($name, -6)) {
if (str_ends_with($name, 'Bundle')) {
$name = substr($name, 0, -6);
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/TwigBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"symfony/http-foundation": "^4.3|^5.0",
"symfony/http-kernel": "^4.4",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-php80": "^1.16",
"twig/twig": "^1.43|^2.13|^3.0.4"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private function authorizesInline(array $directivesSet, string $type): bool
private function hasHashOrNonce(array $directives): bool
{
foreach ($directives as $directive) {
if ('\'' !== substr($directive, -1)) {
if (!str_ends_with($directive, '\'')) {
continue;
}
if ('\'nonce-' === substr($directive, 0, 7)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getNames(Profile $profile)
continue;
}

if ('.html.twig' === substr($template, -10)) {
if (str_ends_with($template, '.html.twig')) {
$template = substr($template, 0, -10);
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/WebProfilerBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"symfony/config": "^4.2|^5.0",
"symfony/framework-bundle": "^4.4|^5.0",
"symfony/http-kernel": "^4.4",
"symfony/polyfill-php80": "^1.16",
"symfony/routing": "^4.3|^5.0",
"symfony/twig-bundle": "^4.2|^5.0",
"twig/twig": "^1.43|^2.13|^3.0.4"
Expand Down