Simplify usage of dirname()
This commit is contained in:
parent
5a06f94c08
commit
c4d44eb089
@ -21,6 +21,7 @@ return PhpCsFixer\Config::create()
|
||||
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
|
||||
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
|
||||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
||||
'combine_nested_dirname' => true,
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(
|
||||
|
@ -269,7 +269,7 @@ class Deprecation
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$v = \dirname(\dirname($r->getFileName()));
|
||||
$v = \dirname($r->getFileName(), 2);
|
||||
if (file_exists($v.'/composer/installed.json')) {
|
||||
self::$vendors[] = $v;
|
||||
$loader = require $v.'/autoload.php';
|
||||
|
@ -169,7 +169,7 @@ class Client extends HttpKernelBrowser
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$file = \dirname(\dirname($r->getFileName())).'/autoload.php';
|
||||
$file = \dirname($r->getFileName(), 2).'/autoload.php';
|
||||
if (file_exists($file)) {
|
||||
$requires .= 'require_once '.var_export($file, true).";\n";
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ class FrameworkExtension extends Extension
|
||||
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
|
||||
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
||||
|
||||
$dirs[] = $transPaths[] = \dirname(\dirname($r->getFileName())).'/Resources/translations';
|
||||
$dirs[] = $transPaths[] = \dirname($r->getFileName(), 2).'/Resources/translations';
|
||||
}
|
||||
$defaultDir = $container->getParameterBag()->resolveValue($config['default_path']);
|
||||
$rootDir = $container->getParameter('kernel.root_dir');
|
||||
|
@ -64,7 +64,7 @@ class CacheClearCommandTest extends TestCase
|
||||
// check that app kernel file present in meta file of container's cache
|
||||
$containerClass = $this->kernel->getContainer()->getParameter('kernel.container_class');
|
||||
$containerRef = new \ReflectionClass($containerClass);
|
||||
$containerFile = \dirname(\dirname($containerRef->getFileName())).'/'.$containerClass.'.php';
|
||||
$containerFile = \dirname($containerRef->getFileName(), 2).'/'.$containerClass.'.php';
|
||||
$containerMetaFile = $containerFile.'.meta';
|
||||
$kernelRef = new \ReflectionObject($this->kernel);
|
||||
$kernelFile = $kernelRef->getFileName();
|
||||
|
@ -44,7 +44,7 @@ class ExtensionPass implements CompilerPassInterface
|
||||
$container->getDefinition('twig.extension.form')->addTag('twig.extension');
|
||||
$reflClass = new \ReflectionClass('Symfony\Bridge\Twig\Extension\FormExtension');
|
||||
|
||||
$coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form';
|
||||
$coreThemePath = \dirname($reflClass->getFileName(), 2).'/Resources/views/Form';
|
||||
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', [$coreThemePath]);
|
||||
|
||||
$paths = $container->getDefinition('twig.template_iterator')->getArgument(2);
|
||||
|
@ -60,7 +60,7 @@ class ComposerResource implements SelfCheckingResourceInterface
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$v = \dirname(\dirname($r->getFileName()));
|
||||
$v = \dirname($r->getFileName(), 2);
|
||||
if (file_exists($v.'/composer/installed.json')) {
|
||||
self::$runtimeVendors[$v] = @filemtime($v.'/composer/installed.json');
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class ClassNotFoundFatalErrorHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
if ($function[0] instanceof ComposerClassLoader) {
|
||||
$function[0]->add('Symfony_Component_Debug_Tests_Fixtures', \dirname(\dirname(\dirname(\dirname(\dirname(__DIR__))))));
|
||||
$function[0]->add('Symfony_Component_Debug_Tests_Fixtures', \dirname(__DIR__, 5));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class PhpDumperTest extends TestCase
|
||||
$container->setParameter('foo', 'wiz'.\dirname(__DIR__));
|
||||
$container->setParameter('bar', __DIR__);
|
||||
$container->setParameter('baz', '%bar%/PhpDumperTest.php');
|
||||
$container->setParameter('buz', \dirname(\dirname(__DIR__)));
|
||||
$container->setParameter('buz', \dirname(__DIR__, 2));
|
||||
$container->compile();
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
|
@ -29,15 +29,15 @@ class TranslationFilesTest extends TestCase
|
||||
{
|
||||
return array_map(
|
||||
function ($filePath) { return (array) $filePath; },
|
||||
glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf')
|
||||
glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf')
|
||||
);
|
||||
}
|
||||
|
||||
public function testNorwegianAlias()
|
||||
{
|
||||
$this->assertFileEquals(
|
||||
\dirname(\dirname(__DIR__)).'/Resources/translations/validators.nb.xlf',
|
||||
\dirname(\dirname(__DIR__)).'/Resources/translations/validators.no.xlf',
|
||||
\dirname(__DIR__, 2).'/Resources/translations/validators.nb.xlf',
|
||||
\dirname(__DIR__, 2).'/Resources/translations/validators.no.xlf',
|
||||
'The NO locale should be an alias for the NB variant of the Norwegian language.'
|
||||
);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class Client extends AbstractBrowser
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$file = \dirname(\dirname($r->getFileName())).'/autoload.php';
|
||||
$file = \dirname($r->getFileName(), 2).'/autoload.php';
|
||||
if (file_exists($file)) {
|
||||
$requires .= 'require_once '.var_export($file, true).";\n";
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ class TranslationFilesTest extends TestCase
|
||||
{
|
||||
return array_map(
|
||||
function ($filePath) { return (array) $filePath; },
|
||||
glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf')
|
||||
glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf')
|
||||
);
|
||||
}
|
||||
|
||||
public function testNorwegianAlias()
|
||||
{
|
||||
$this->assertFileEquals(
|
||||
\dirname(\dirname(__DIR__)).'/Resources/translations/security.nb.xlf',
|
||||
\dirname(\dirname(__DIR__)).'/Resources/translations/security.no.xlf',
|
||||
\dirname(__DIR__, 2).'/Resources/translations/security.nb.xlf',
|
||||
\dirname(__DIR__, 2).'/Resources/translations/security.no.xlf',
|
||||
'The NO locale should be an alias for the NB variant of the Norwegian language.'
|
||||
);
|
||||
}
|
||||
|
@ -29,15 +29,15 @@ class TranslationFilesTest extends TestCase
|
||||
{
|
||||
return array_map(
|
||||
function ($filePath) { return (array) $filePath; },
|
||||
glob(\dirname(\dirname(__DIR__)).'/Resources/translations/*.xlf')
|
||||
glob(\dirname(__DIR__, 2).'/Resources/translations/*.xlf')
|
||||
);
|
||||
}
|
||||
|
||||
public function testNorwegianAlias()
|
||||
{
|
||||
$this->assertFileEquals(
|
||||
\dirname(\dirname(__DIR__)).'/Resources/translations/validators.nb.xlf',
|
||||
\dirname(\dirname(__DIR__)).'/Resources/translations/validators.no.xlf',
|
||||
\dirname(__DIR__, 2).'/Resources/translations/validators.nb.xlf',
|
||||
\dirname(__DIR__, 2).'/Resources/translations/validators.no.xlf',
|
||||
'The NO locale should be an alias for the NB variant of the Norwegian language.'
|
||||
);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class LinkStub extends ConstStub
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$v = \dirname(\dirname($r->getFileName()));
|
||||
$v = \dirname($r->getFileName(), 2);
|
||||
if (file_exists($v.'/composer/installed.json')) {
|
||||
self::$vendorRoots[] = $v.\DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
Reference in New Issue
Block a user