SCA: minor code tweaks

This commit is contained in:
Vladimir Reznichenko 2019-09-08 17:58:07 +02:00 committed by Fabien Potencier
parent 47a87849c0
commit 32ea449679
4 changed files with 6 additions and 7 deletions

View File

@ -260,11 +260,11 @@ abstract class AbstractDoctrineExtension extends Extension
$configPath = $this->getMappingResourceConfigDirectory(); $configPath = $this->getMappingResourceConfigDirectory();
$extension = $this->getMappingResourceExtension(); $extension = $this->getMappingResourceExtension();
if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) { if (glob($dir.'/'.$configPath.'/*.'.$extension.'.xml', GLOB_NOSORT)) {
$driver = 'xml'; $driver = 'xml';
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) { } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.yml', GLOB_NOSORT)) {
$driver = 'yml'; $driver = 'yml';
} elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) { } elseif (glob($dir.'/'.$configPath.'/*.'.$extension.'.php', GLOB_NOSORT)) {
$driver = 'php'; $driver = 'php';
} else { } else {
// add the closest existing directory as a resource // add the closest existing directory as a resource

View File

@ -1098,8 +1098,7 @@ class Application
*/ */
public function extractNamespace($name, $limit = null) public function extractNamespace($name, $limit = null)
{ {
$parts = explode(':', $name); $parts = explode(':', $name, -1);
array_pop($parts);
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit)); return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
} }

View File

@ -673,7 +673,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
static $legacyContainers = []; static $legacyContainers = [];
$oldContainerDir = \dirname($oldContainer->getFileName()); $oldContainerDir = \dirname($oldContainer->getFileName());
$legacyContainers[$oldContainerDir.'.legacy'] = true; $legacyContainers[$oldContainerDir.'.legacy'] = true;
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) { foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', GLOB_NOSORT) as $legacyContainer) {
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) { if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
(new Filesystem())->remove(substr($legacyContainer, 0, -7)); (new Filesystem())->remove(substr($legacyContainer, 0, -7));
} }

View File

@ -42,7 +42,7 @@ class LocaleScanner
*/ */
public function scanLocales($sourceDir) public function scanLocales($sourceDir)
{ {
$locales = glob($sourceDir.'/*.txt'); $locales = glob($sourceDir.'/*.txt', GLOB_NOSORT);
// Remove file extension and sort // Remove file extension and sort
array_walk($locales, function (&$locale) { $locale = basename($locale, '.txt'); }); array_walk($locales, function (&$locale) { $locale = basename($locale, '.txt'); });