Merge branch '3.4'
* 3.4: [Console] Add protected static $defaultName to set the default name of a Command removed sf2 references [Console] Allow commands to provide a default name for compile time registration [DI] Case sensitive parameter names
This commit is contained in:
commit
3a9653df72
@ -26,6 +26,8 @@ use Twig\Environment;
|
|||||||
*/
|
*/
|
||||||
class DebugCommand extends Command
|
class DebugCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'debug:twig';
|
||||||
|
|
||||||
private $twig;
|
private $twig;
|
||||||
|
|
||||||
public function __construct(Environment $twig)
|
public function __construct(Environment $twig)
|
||||||
@ -38,7 +40,6 @@ class DebugCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('debug:twig')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all entries matching this filter'),
|
new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all entries matching this filter'),
|
||||||
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
|
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (text or json)', 'text'),
|
||||||
|
@ -31,6 +31,8 @@ use Twig\Source;
|
|||||||
*/
|
*/
|
||||||
class LintCommand extends Command
|
class LintCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'lint:twig';
|
||||||
|
|
||||||
private $twig;
|
private $twig;
|
||||||
|
|
||||||
public function __construct(Environment $twig)
|
public function __construct(Environment $twig)
|
||||||
@ -43,7 +45,6 @@ class LintCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('lint:twig')
|
|
||||||
->setDescription('Lints a template and outputs encountered errors')
|
->setDescription('Lints a template and outputs encountered errors')
|
||||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||||
->addArgument('filename', InputArgument::IS_ARRAY)
|
->addArgument('filename', InputArgument::IS_ARRAY)
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
"symfony/web-link": "~3.4|~4.0"
|
"symfony/web-link": "~3.4|~4.0"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/form": "<3.4"
|
"symfony/form": "<3.4",
|
||||||
|
"symfony/console": "<3.4"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/finder": "",
|
"symfony/finder": "",
|
||||||
|
@ -29,15 +29,14 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
|||||||
*/
|
*/
|
||||||
class AboutCommand extends Command
|
class AboutCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'about';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this->setDescription('Displays information about the current project');
|
||||||
->setName('about')
|
|
||||||
->setDescription('Displays information about the current project')
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +36,8 @@ class AssetsInstallCommand extends Command
|
|||||||
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
|
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
|
||||||
const METHOD_RELATIVE_SYMLINK = 'relative symlink';
|
const METHOD_RELATIVE_SYMLINK = 'relative symlink';
|
||||||
|
|
||||||
|
protected static $defaultName = 'assets:install';
|
||||||
|
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
|
|
||||||
public function __construct(Filesystem $filesystem)
|
public function __construct(Filesystem $filesystem)
|
||||||
@ -51,7 +53,6 @@ class AssetsInstallCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('assets:install')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'),
|
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'),
|
||||||
))
|
))
|
||||||
|
@ -32,6 +32,8 @@ use Symfony\Component\Finder\Finder;
|
|||||||
*/
|
*/
|
||||||
class CacheClearCommand extends Command
|
class CacheClearCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'cache:clear';
|
||||||
|
|
||||||
private $cacheClearer;
|
private $cacheClearer;
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
|
|
||||||
@ -53,7 +55,6 @@ class CacheClearCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('cache:clear')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
|
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
|
||||||
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
||||||
|
@ -26,6 +26,8 @@ use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
|||||||
*/
|
*/
|
||||||
final class CachePoolClearCommand extends Command
|
final class CachePoolClearCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'cache:pool:clear';
|
||||||
|
|
||||||
private $poolClearer;
|
private $poolClearer;
|
||||||
|
|
||||||
public function __construct(Psr6CacheClearer $poolClearer)
|
public function __construct(Psr6CacheClearer $poolClearer)
|
||||||
@ -41,7 +43,6 @@ final class CachePoolClearCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('cache:pool:clear')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'),
|
new InputArgument('pools', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of cache pools or cache pool clearers'),
|
||||||
))
|
))
|
||||||
|
@ -24,6 +24,8 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
*/
|
*/
|
||||||
final class CachePoolPruneCommand extends Command
|
final class CachePoolPruneCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'cache:pool:prune';
|
||||||
|
|
||||||
private $pools;
|
private $pools;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +44,6 @@ final class CachePoolPruneCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('cache:pool:prune')
|
|
||||||
->setDescription('Prune cache pools')
|
->setDescription('Prune cache pools')
|
||||||
->setHelp(<<<'EOF'
|
->setHelp(<<<'EOF'
|
||||||
The <info>%command.name%</info> command deletes all expired items from all pruneable pools.
|
The <info>%command.name%</info> command deletes all expired items from all pruneable pools.
|
||||||
|
@ -27,6 +27,8 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
|
|||||||
*/
|
*/
|
||||||
class CacheWarmupCommand extends Command
|
class CacheWarmupCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'cache:warmup';
|
||||||
|
|
||||||
private $cacheWarmer;
|
private $cacheWarmer;
|
||||||
|
|
||||||
public function __construct(CacheWarmerAggregate $cacheWarmer)
|
public function __construct(CacheWarmerAggregate $cacheWarmer)
|
||||||
@ -42,7 +44,6 @@ class CacheWarmupCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('cache:warmup')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
||||||
))
|
))
|
||||||
|
@ -28,13 +28,14 @@ use Symfony\Component\Yaml\Yaml;
|
|||||||
*/
|
*/
|
||||||
class ConfigDebugCommand extends AbstractConfigCommand
|
class ConfigDebugCommand extends AbstractConfigCommand
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'debug:config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('debug:config')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
|
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
|
||||||
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
|
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
|
||||||
|
@ -30,13 +30,14 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
*/
|
*/
|
||||||
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
class ConfigDumpReferenceCommand extends AbstractConfigCommand
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'config:dump-reference';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('config:dump-reference')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'),
|
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'),
|
||||||
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
|
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
|
||||||
|
@ -33,6 +33,8 @@ use Symfony\Component\Config\FileLocator;
|
|||||||
*/
|
*/
|
||||||
class ContainerDebugCommand extends Command
|
class ContainerDebugCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'debug:container';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ContainerBuilder|null
|
* @var ContainerBuilder|null
|
||||||
*/
|
*/
|
||||||
@ -44,7 +46,6 @@ class ContainerDebugCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('debug:container')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'),
|
new InputArgument('name', InputArgument::OPTIONAL, 'A service name (foo)'),
|
||||||
new InputOption('show-private', null, InputOption::VALUE_NONE, 'Used to show public *and* private services'),
|
new InputOption('show-private', null, InputOption::VALUE_NONE, 'Used to show public *and* private services'),
|
||||||
|
@ -29,6 +29,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
*/
|
*/
|
||||||
class EventDispatcherDebugCommand extends Command
|
class EventDispatcherDebugCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'debug:event-dispatcher';
|
||||||
private $dispatcher;
|
private $dispatcher;
|
||||||
|
|
||||||
public function __construct(EventDispatcherInterface $dispatcher)
|
public function __construct(EventDispatcherInterface $dispatcher)
|
||||||
@ -44,7 +45,6 @@ class EventDispatcherDebugCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('debug:event-dispatcher')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('event', InputArgument::OPTIONAL, 'An event name'),
|
new InputArgument('event', InputArgument::OPTIONAL, 'An event name'),
|
||||||
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
|
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
|
||||||
|
@ -33,6 +33,7 @@ use Symfony\Component\Routing\Route;
|
|||||||
*/
|
*/
|
||||||
class RouterDebugCommand extends Command
|
class RouterDebugCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'debug:router';
|
||||||
private $router;
|
private $router;
|
||||||
|
|
||||||
public function __construct(RouterInterface $router)
|
public function __construct(RouterInterface $router)
|
||||||
@ -48,7 +49,6 @@ class RouterDebugCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('debug:router')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
|
new InputArgument('name', InputArgument::OPTIONAL, 'A route name'),
|
||||||
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),
|
new InputOption('show-controllers', null, InputOption::VALUE_NONE, 'Show assigned controllers in overview'),
|
||||||
|
@ -30,6 +30,8 @@ use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
|
|||||||
*/
|
*/
|
||||||
class RouterMatchCommand extends Command
|
class RouterMatchCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'router:match';
|
||||||
|
|
||||||
private $router;
|
private $router;
|
||||||
|
|
||||||
public function __construct(RouterInterface $router)
|
public function __construct(RouterInterface $router)
|
||||||
@ -45,7 +47,6 @@ class RouterMatchCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('router:match')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
|
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
|
||||||
new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method'),
|
new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method'),
|
||||||
|
@ -41,6 +41,8 @@ class TranslationDebugCommand extends Command
|
|||||||
const MESSAGE_UNUSED = 1;
|
const MESSAGE_UNUSED = 1;
|
||||||
const MESSAGE_EQUALS_FALLBACK = 2;
|
const MESSAGE_EQUALS_FALLBACK = 2;
|
||||||
|
|
||||||
|
protected static $defaultName = 'debug:translation';
|
||||||
|
|
||||||
private $translator;
|
private $translator;
|
||||||
private $loader;
|
private $loader;
|
||||||
private $extractor;
|
private $extractor;
|
||||||
@ -60,7 +62,6 @@ class TranslationDebugCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('debug:translation')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
||||||
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'),
|
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'),
|
||||||
|
@ -34,6 +34,8 @@ use Symfony\Component\Translation\Writer\TranslationWriterInterface;
|
|||||||
*/
|
*/
|
||||||
class TranslationUpdateCommand extends Command
|
class TranslationUpdateCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'translation:update';
|
||||||
|
|
||||||
private $writer;
|
private $writer;
|
||||||
private $loader;
|
private $loader;
|
||||||
private $extractor;
|
private $extractor;
|
||||||
@ -61,7 +63,6 @@ class TranslationUpdateCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('translation:update')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
|
||||||
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'),
|
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages, defaults to app/Resources folder'),
|
||||||
|
@ -26,13 +26,14 @@ use Symfony\Component\Workflow\Marking;
|
|||||||
*/
|
*/
|
||||||
class WorkflowDumpCommand extends Command
|
class WorkflowDumpCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'workflow:dump';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('workflow:dump')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'),
|
new InputArgument('name', InputArgument::REQUIRED, 'A workflow name'),
|
||||||
new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'),
|
new InputArgument('marking', InputArgument::IS_ARRAY, 'A marking (a list of places)'),
|
||||||
|
@ -24,6 +24,8 @@ use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand;
|
|||||||
*/
|
*/
|
||||||
class XliffLintCommand extends BaseLintCommand
|
class XliffLintCommand extends BaseLintCommand
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'lint:xliff';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$directoryIteratorProvider = function ($directory, $default) {
|
$directoryIteratorProvider = function ($directory, $default) {
|
||||||
|
@ -23,6 +23,8 @@ use Symfony\Component\Yaml\Command\LintCommand as BaseLintCommand;
|
|||||||
*/
|
*/
|
||||||
class YamlLintCommand extends BaseLintCommand
|
class YamlLintCommand extends BaseLintCommand
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'lint:yaml';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$directoryIteratorProvider = function ($directory, $default) {
|
$directoryIteratorProvider = function ($directory, $default) {
|
||||||
|
@ -27,6 +27,8 @@ use Doctrine\DBAL\Schema\SchemaException;
|
|||||||
*/
|
*/
|
||||||
class InitAclCommand extends Command
|
class InitAclCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'init:acl';
|
||||||
|
|
||||||
private $connection;
|
private $connection;
|
||||||
private $schema;
|
private $schema;
|
||||||
|
|
||||||
@ -44,7 +46,6 @@ class InitAclCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('init:acl')
|
|
||||||
->setDescription('Mounts ACL tables in the database')
|
->setDescription('Mounts ACL tables in the database')
|
||||||
->setHelp(<<<'EOF'
|
->setHelp(<<<'EOF'
|
||||||
The <info>%command.name%</info> command mounts ACL tables in the database.
|
The <info>%command.name%</info> command mounts ACL tables in the database.
|
||||||
|
@ -32,6 +32,8 @@ use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface;
|
|||||||
*/
|
*/
|
||||||
class SetAclCommand extends Command
|
class SetAclCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'acl:set';
|
||||||
|
|
||||||
private $provider;
|
private $provider;
|
||||||
|
|
||||||
public function __construct(MutableAclProviderInterface $provider)
|
public function __construct(MutableAclProviderInterface $provider)
|
||||||
@ -47,7 +49,6 @@ class SetAclCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('acl:set')
|
|
||||||
->setDescription('Sets ACL for objects')
|
->setDescription('Sets ACL for objects')
|
||||||
->setHelp(<<<EOF
|
->setHelp(<<<EOF
|
||||||
The <info>%command.name%</info> command sets ACL.
|
The <info>%command.name%</info> command sets ACL.
|
||||||
|
@ -31,6 +31,8 @@ use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
|||||||
*/
|
*/
|
||||||
class UserPasswordEncoderCommand extends Command
|
class UserPasswordEncoderCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'security:encode-password';
|
||||||
|
|
||||||
private $encoderFactory;
|
private $encoderFactory;
|
||||||
private $userClasses;
|
private $userClasses;
|
||||||
|
|
||||||
@ -48,7 +50,6 @@ class UserPasswordEncoderCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('security:encode-password')
|
|
||||||
->setDescription('Encodes a password.')
|
->setDescription('Encodes a password.')
|
||||||
->addArgument('password', InputArgument::OPTIONAL, 'The plain password to encode.')
|
->addArgument('password', InputArgument::OPTIONAL, 'The plain password to encode.')
|
||||||
->addArgument('user-class', InputArgument::OPTIONAL, 'The User entity class path associated with the encoder used to encode the password.')
|
->addArgument('user-class', InputArgument::OPTIONAL, 'The User entity class path associated with the encoder used to encode the password.')
|
||||||
|
@ -20,7 +20,6 @@ namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Bundle\SecurityBundle\Command\InitAclCommand;
|
|
||||||
use Symfony\Bundle\SecurityBundle\Command\SetAclCommand;
|
use Symfony\Bundle\SecurityBundle\Command\SetAclCommand;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
|
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
|
||||||
@ -170,7 +169,6 @@ class SetAclCommandTest extends WebTestCase
|
|||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$application = new Application($kernel);
|
$application = new Application($kernel);
|
||||||
$application->add(new InitAclCommand($kernel->getContainer()->get('security.acl.dbal.connection'), $kernel->getContainer()->get('security.acl.dbal.schema')));
|
|
||||||
|
|
||||||
$initAclCommand = $application->find('init:acl');
|
$initAclCommand = $application->find('init:acl');
|
||||||
$initAclCommandTester = new CommandTester($initAclCommand);
|
$initAclCommandTester = new CommandTester($initAclCommand);
|
||||||
|
@ -46,7 +46,8 @@
|
|||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/var-dumper": "<3.4",
|
"symfony/var-dumper": "<3.4",
|
||||||
"symfony/event-dispatcher": "<3.4"
|
"symfony/event-dispatcher": "<3.4",
|
||||||
|
"symfony/console": "<3.4"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/security-acl": "For using the ACL functionality of this bundle"
|
"symfony/security-acl": "For using the ACL functionality of this bundle"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
var noop = function() {};
|
var noop = function() {};
|
||||||
|
|
||||||
var profilerStorageKey = 'sf2/profiler/';
|
var profilerStorageKey = 'symfony/profiler/';
|
||||||
|
|
||||||
var request = function(url, onSuccess, onError, payload, options) {
|
var request = function(url, onSuccess, onError, payload, options) {
|
||||||
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
var noop = function() {};
|
var noop = function() {};
|
||||||
|
|
||||||
var profilerStorageKey = 'sf2/profiler/';
|
var profilerStorageKey = 'symfony/profiler/';
|
||||||
|
|
||||||
var request = function(url, onSuccess, onError, payload, options) {
|
var request = function(url, onSuccess, onError, payload, options) {
|
||||||
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
|
@ -17,6 +17,10 @@ CHANGELOG
|
|||||||
* added `CommandLoaderInterface`, `FactoryCommandLoader` and PSR-11
|
* added `CommandLoaderInterface`, `FactoryCommandLoader` and PSR-11
|
||||||
`ContainerCommandLoader` for commands lazy-loading
|
`ContainerCommandLoader` for commands lazy-loading
|
||||||
* added a case-insensitive command name matching fallback
|
* added a case-insensitive command name matching fallback
|
||||||
|
* added static `Command::$defaultName/getDefaultName()`, allowing for
|
||||||
|
commands to be registered at compile time in the application command loader.
|
||||||
|
Setting the `$defaultName` property avoids the need for filling the `command`
|
||||||
|
attribute on the `console.command` tag when using `AddConsoleCommandPass`.
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -29,6 +29,11 @@ use Symfony\Component\Console\Exception\LogicException;
|
|||||||
*/
|
*/
|
||||||
class Command
|
class Command
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string|null The default command name
|
||||||
|
*/
|
||||||
|
protected static $defaultName;
|
||||||
|
|
||||||
private $application;
|
private $application;
|
||||||
private $name;
|
private $name;
|
||||||
private $processTitle;
|
private $processTitle;
|
||||||
@ -45,6 +50,17 @@ class Command
|
|||||||
private $usages = array();
|
private $usages = array();
|
||||||
private $helperSet;
|
private $helperSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string|null The default command name or null when no default name is set
|
||||||
|
*/
|
||||||
|
public static function getDefaultName()
|
||||||
|
{
|
||||||
|
$class = get_called_class();
|
||||||
|
$r = new \ReflectionProperty($class, 'defaultName');
|
||||||
|
|
||||||
|
return $class === $r->class ? static::$defaultName : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -56,7 +72,7 @@ class Command
|
|||||||
{
|
{
|
||||||
$this->definition = new InputDefinition();
|
$this->definition = new InputDefinition();
|
||||||
|
|
||||||
if (null !== $name) {
|
if (null !== $name || null !== $name = static::getDefaultName()) {
|
||||||
$this->setName($name);
|
$this->setName($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,16 +46,21 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
|||||||
$definition = $container->getDefinition($id);
|
$definition = $container->getDefinition($id);
|
||||||
$class = $container->getParameterBag()->resolveValue($definition->getClass());
|
$class = $container->getParameterBag()->resolveValue($definition->getClass());
|
||||||
|
|
||||||
if (!$r = $container->getReflectionClass($class)) {
|
|
||||||
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
|
||||||
}
|
|
||||||
if (!$r->isSubclassOf(Command::class)) {
|
|
||||||
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
$commandId = 'console.command.'.strtolower(str_replace('\\', '_', $class));
|
$commandId = 'console.command.'.strtolower(str_replace('\\', '_', $class));
|
||||||
|
|
||||||
if (!isset($tags[0]['command'])) {
|
if (isset($tags[0]['command'])) {
|
||||||
|
$commandName = $tags[0]['command'];
|
||||||
|
} else {
|
||||||
|
if (!$r = $container->getReflectionClass($class)) {
|
||||||
|
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||||
|
}
|
||||||
|
if (!$r->isSubclassOf(Command::class)) {
|
||||||
|
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
|
||||||
|
}
|
||||||
|
$commandName = $class::getDefaultName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $commandName) {
|
||||||
if (isset($serviceIds[$commandId]) || $container->hasAlias($commandId)) {
|
if (isset($serviceIds[$commandId]) || $container->hasAlias($commandId)) {
|
||||||
$commandId = $commandId.'_'.$id;
|
$commandId = $commandId.'_'.$id;
|
||||||
}
|
}
|
||||||
@ -69,7 +74,6 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$serviceIds[$commandId] = false;
|
$serviceIds[$commandId] = false;
|
||||||
$commandName = $tags[0]['command'];
|
|
||||||
unset($tags[0]);
|
unset($tags[0]);
|
||||||
$lazyCommandMap[$commandName] = $id;
|
$lazyCommandMap[$commandName] = $id;
|
||||||
$lazyCommandRefs[$id] = new TypedReference($id, $class);
|
$lazyCommandRefs[$id] = new TypedReference($id, $class);
|
||||||
|
@ -77,6 +77,38 @@ class AddConsoleCommandPassTest extends TestCase
|
|||||||
$this->assertSame(array(array('setName', array('my:command')), array('setAliases', array(array('my:alias')))), $command->getMethodCalls());
|
$this->assertSame(array(array('setName', array('my:command')), array('setAliases', array(array('my:alias')))), $command->getMethodCalls());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessFallsBackToDefaultName()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container
|
||||||
|
->register('with-default-name', NamedCommand::class)
|
||||||
|
->setPublic(false)
|
||||||
|
->addTag('console.command')
|
||||||
|
;
|
||||||
|
|
||||||
|
$pass = new AddConsoleCommandPass();
|
||||||
|
$pass->process($container);
|
||||||
|
|
||||||
|
$commandLoader = $container->getDefinition('console.command_loader');
|
||||||
|
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
|
||||||
|
|
||||||
|
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
||||||
|
$this->assertSame(array('default' => 'with-default-name'), $commandLoader->getArgument(1));
|
||||||
|
$this->assertEquals(array(array('with-default-name' => new ServiceClosureArgument(new TypedReference('with-default-name', NamedCommand::class)))), $commandLocator->getArguments());
|
||||||
|
$this->assertSame(array('console.command.symfony_component_console_tests_dependencyinjection_namedcommand' => false), $container->getParameter('console.command.ids'));
|
||||||
|
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container
|
||||||
|
->register('with-default-name', NamedCommand::class)
|
||||||
|
->setPublic(false)
|
||||||
|
->addTag('console.command', array('command' => 'new-name'))
|
||||||
|
;
|
||||||
|
|
||||||
|
$pass->process($container);
|
||||||
|
|
||||||
|
$this->assertSame(array('new-name' => 'with-default-name'), $container->getDefinition('console.command_loader')->getArgument(1));
|
||||||
|
}
|
||||||
|
|
||||||
public function visibilityProvider()
|
public function visibilityProvider()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
@ -96,7 +128,7 @@ class AddConsoleCommandPassTest extends TestCase
|
|||||||
$container->addCompilerPass(new AddConsoleCommandPass());
|
$container->addCompilerPass(new AddConsoleCommandPass());
|
||||||
|
|
||||||
$definition = new Definition('Symfony\Component\Console\Tests\DependencyInjection\MyCommand');
|
$definition = new Definition('Symfony\Component\Console\Tests\DependencyInjection\MyCommand');
|
||||||
$definition->addTag('console.command', array('command' => 'my:command'));
|
$definition->addTag('console.command');
|
||||||
$definition->setAbstract(true);
|
$definition->setAbstract(true);
|
||||||
$container->setDefinition('my-command', $definition);
|
$container->setDefinition('my-command', $definition);
|
||||||
|
|
||||||
@ -114,7 +146,7 @@ class AddConsoleCommandPassTest extends TestCase
|
|||||||
$container->addCompilerPass(new AddConsoleCommandPass());
|
$container->addCompilerPass(new AddConsoleCommandPass());
|
||||||
|
|
||||||
$definition = new Definition('SplObjectStorage');
|
$definition = new Definition('SplObjectStorage');
|
||||||
$definition->addTag('console.command', array('command' => 'my:command'));
|
$definition->addTag('console.command');
|
||||||
$container->setDefinition('my-command', $definition);
|
$container->setDefinition('my-command', $definition);
|
||||||
|
|
||||||
$container->compile();
|
$container->compile();
|
||||||
@ -146,3 +178,8 @@ class AddConsoleCommandPassTest extends TestCase
|
|||||||
class MyCommand extends Command
|
class MyCommand extends Command
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NamedCommand extends Command
|
||||||
|
{
|
||||||
|
protected static $defaultName = 'default';
|
||||||
|
}
|
||||||
|
@ -28,6 +28,7 @@ CHANGELOG
|
|||||||
* deprecated service auto-registration while autowiring
|
* deprecated service auto-registration while autowiring
|
||||||
* deprecated the ability to check for the initialization of a private service with the `Container::initialized()` method
|
* deprecated the ability to check for the initialization of a private service with the `Container::initialized()` method
|
||||||
* deprecated support for top-level anonymous services in XML
|
* deprecated support for top-level anonymous services in XML
|
||||||
|
* deprecated case insensitivity of parameter names
|
||||||
|
|
||||||
3.3.0
|
3.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -1039,11 +1039,15 @@ EOF;
|
|||||||
|
|
||||||
$php = array();
|
$php = array();
|
||||||
$dynamicPhp = array();
|
$dynamicPhp = array();
|
||||||
|
$normalizedParams = array();
|
||||||
|
|
||||||
foreach ($this->container->getParameterBag()->all() as $key => $value) {
|
foreach ($this->container->getParameterBag()->all() as $key => $value) {
|
||||||
if ($key !== $resolvedKey = $this->container->resolveEnvPlaceholders($key)) {
|
if ($key !== $resolvedKey = $this->container->resolveEnvPlaceholders($key)) {
|
||||||
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey));
|
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey));
|
||||||
}
|
}
|
||||||
|
if ($key !== $lcKey = strtolower($key)) {
|
||||||
|
$normalizedParams[] = sprintf(' %s => %s,', $this->export($lcKey), $this->export($key));
|
||||||
|
}
|
||||||
$export = $this->exportParameters(array($value));
|
$export = $this->exportParameters(array($value));
|
||||||
$export = explode('0 => ', substr(rtrim($export, " )\n"), 7, -1), 2);
|
$export = explode('0 => ', substr(rtrim($export, " )\n"), 7, -1), 2);
|
||||||
|
|
||||||
@ -1063,7 +1067,7 @@ EOF;
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -1081,7 +1085,7 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -1151,6 +1155,30 @@ EOF;
|
|||||||
{$getDynamicParameter}
|
{$getDynamicParameter}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$code .= ' private $normalizedParameterNames = '.($normalizedParams ? sprintf("array(\n%s\n );", implode("\n", $normalizedParams)) : 'array();')."\n";
|
||||||
|
$code .= <<<'EOF'
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$code .= <<<EOF
|
||||||
|
|
||||||
/*{$this->docStar}
|
/*{$this->docStar}
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
@ -1533,10 +1561,10 @@ EOF;
|
|||||||
if (preg_match('/^%([^%]+)%$/', $value, $match)) {
|
if (preg_match('/^%([^%]+)%$/', $value, $match)) {
|
||||||
// we do this to deal with non string values (Boolean, integer, ...)
|
// we do this to deal with non string values (Boolean, integer, ...)
|
||||||
// the preg_replace_callback converts them to strings
|
// the preg_replace_callback converts them to strings
|
||||||
return $this->dumpParameter(strtolower($match[1]));
|
return $this->dumpParameter($match[1]);
|
||||||
} else {
|
} else {
|
||||||
$replaceParameters = function ($match) {
|
$replaceParameters = function ($match) {
|
||||||
return "'.".$this->dumpParameter(strtolower($match[2])).".'";
|
return "'.".$this->dumpParameter($match[2]).".'";
|
||||||
};
|
};
|
||||||
|
|
||||||
$code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters, $this->export($value)));
|
$code = str_replace('%%', '%', preg_replace_callback('/(?<!%)(%)([^%]+)\1/', $replaceParameters, $this->export($value)));
|
||||||
@ -1582,8 +1610,6 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
private function dumpParameter($name)
|
private function dumpParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
|
||||||
|
|
||||||
if ($this->container->isCompiled() && $this->container->hasParameter($name)) {
|
if ($this->container->isCompiled() && $this->container->hasParameter($name)) {
|
||||||
$value = $this->container->getParameter($name);
|
$value = $this->container->getParameter($name);
|
||||||
$dumpedValue = $this->dumpValue($value, false);
|
$dumpedValue = $this->dumpValue($value, false);
|
||||||
|
@ -471,11 +471,6 @@ class XmlFileLoader extends FileLoader
|
|||||||
$key = array_pop($keys);
|
$key = array_pop($keys);
|
||||||
} else {
|
} else {
|
||||||
$key = $arg->getAttribute('key');
|
$key = $arg->getAttribute('key');
|
||||||
|
|
||||||
// parameter keys are case insensitive
|
|
||||||
if ('parameter' == $name && $lowercase) {
|
|
||||||
$key = strtolower($key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInvalid = $arg->getAttribute('on-invalid');
|
$onInvalid = $arg->getAttribute('on-invalid');
|
||||||
@ -579,7 +574,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
foreach ($schemaLocations as $namespace => $location) {
|
foreach ($schemaLocations as $namespace => $location) {
|
||||||
$parts = explode('/', $location);
|
$parts = explode('/', $location);
|
||||||
if (0 === stripos($location, 'phar://')) {
|
if (0 === stripos($location, 'phar://')) {
|
||||||
$tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
|
$tmpfile = tempnam(sys_get_temp_dir(), 'symfony');
|
||||||
if ($tmpfile) {
|
if ($tmpfile) {
|
||||||
copy($location, $tmpfile);
|
copy($location, $tmpfile);
|
||||||
$tmpfiles[] = $tmpfile;
|
$tmpfiles[] = $tmpfile;
|
||||||
|
@ -91,7 +91,7 @@ class EnvPlaceholderParameterBag extends ParameterBag
|
|||||||
parent::resolve();
|
parent::resolve();
|
||||||
|
|
||||||
foreach ($this->envPlaceholders as $env => $placeholders) {
|
foreach ($this->envPlaceholders as $env => $placeholders) {
|
||||||
if (!isset($this->parameters[$name = strtolower("env($env)")])) {
|
if (!$this->has($name = "env($env)")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (is_numeric($default = $this->parameters[$name])) {
|
if (is_numeric($default = $this->parameters[$name])) {
|
||||||
|
@ -25,6 +25,8 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
protected $parameters = array();
|
protected $parameters = array();
|
||||||
protected $resolved = false;
|
protected $resolved = false;
|
||||||
|
|
||||||
|
private $normalizedNames = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $parameters An array of parameters
|
* @param array $parameters An array of parameters
|
||||||
*/
|
*/
|
||||||
@ -49,7 +51,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
public function add(array $parameters)
|
public function add(array $parameters)
|
||||||
{
|
{
|
||||||
foreach ($parameters as $key => $value) {
|
foreach ($parameters as $key => $value) {
|
||||||
$this->parameters[strtolower($key)] = $value;
|
$this->set($key, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +68,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
*/
|
*/
|
||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeName($name);
|
||||||
|
|
||||||
if (!array_key_exists($name, $this->parameters)) {
|
if (!array_key_exists($name, $this->parameters)) {
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
@ -111,7 +113,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
*/
|
*/
|
||||||
public function set($name, $value)
|
public function set($name, $value)
|
||||||
{
|
{
|
||||||
$this->parameters[strtolower($name)] = $value;
|
$this->parameters[$this->normalizeName($name)] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,7 +121,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
*/
|
*/
|
||||||
public function has($name)
|
public function has($name)
|
||||||
{
|
{
|
||||||
return array_key_exists(strtolower($name), $this->parameters);
|
return array_key_exists($this->normalizeName($name), $this->parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +131,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
*/
|
*/
|
||||||
public function remove($name)
|
public function remove($name)
|
||||||
{
|
{
|
||||||
unset($this->parameters[strtolower($name)]);
|
unset($this->parameters[$this->normalizeName($name)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +208,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
// a non-string in a parameter value
|
// a non-string in a parameter value
|
||||||
if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
|
if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
|
||||||
$key = $match[1];
|
$key = $match[1];
|
||||||
$lcKey = strtolower($key);
|
$lcKey = strtolower($key); // strtolower() to be removed in 4.0
|
||||||
|
|
||||||
if (isset($resolving[$lcKey])) {
|
if (isset($resolving[$lcKey])) {
|
||||||
throw new ParameterCircularReferenceException(array_keys($resolving));
|
throw new ParameterCircularReferenceException(array_keys($resolving));
|
||||||
@ -224,7 +226,7 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$key = $match[1];
|
$key = $match[1];
|
||||||
$lcKey = strtolower($key);
|
$lcKey = strtolower($key); // strtolower() to be removed in 4.0
|
||||||
if (isset($resolving[$lcKey])) {
|
if (isset($resolving[$lcKey])) {
|
||||||
throw new ParameterCircularReferenceException(array_keys($resolving));
|
throw new ParameterCircularReferenceException(array_keys($resolving));
|
||||||
}
|
}
|
||||||
@ -288,4 +290,18 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function normalizeName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedNames[$normalizedName = strtolower($name)])) {
|
||||||
|
$normalizedName = $this->normalizedNames[$normalizedName];
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1097,6 +1097,21 @@ class ContainerBuilderTest extends TestCase
|
|||||||
$this->assertNotSame($container->get('foo'), $container->get('fOO'), '->get() returns the service for the given id, case sensitively');
|
$this->assertNotSame($container->get('foo'), $container->get('fOO'), '->get() returns the service for the given id, case sensitively');
|
||||||
$this->assertSame($container->get('fOO')->Foo->foo, $container->get('foo'), '->get() returns the service for the given id, case sensitively');
|
$this->assertSame($container->get('fOO')->Foo->foo, $container->get('foo'), '->get() returns the service for the given id, case sensitively');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "FOO" instead of "foo" is deprecated since version 3.4.
|
||||||
|
*/
|
||||||
|
public function testParameterWithMixedCase()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
|
||||||
|
$container->register('foo', 'stdClass')
|
||||||
|
->setProperty('foo', '%FOO%');
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$this->assertSame('bar', $container->get('foo')->foo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FooClass
|
class FooClass
|
||||||
|
@ -112,10 +112,6 @@ class ContainerTest extends TestCase
|
|||||||
$sc->setParameter('foo', 'baz');
|
$sc->setParameter('foo', 'baz');
|
||||||
$this->assertEquals('baz', $sc->getParameter('foo'), '->setParameter() overrides previously set parameter');
|
$this->assertEquals('baz', $sc->getParameter('foo'), '->setParameter() overrides previously set parameter');
|
||||||
|
|
||||||
$sc->setParameter('Foo', 'baz1');
|
|
||||||
$this->assertEquals('baz1', $sc->getParameter('foo'), '->setParameter() converts the key to lowercase');
|
|
||||||
$this->assertEquals('baz1', $sc->getParameter('FOO'), '->getParameter() converts the key to lowercase');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sc->getParameter('baba');
|
$sc->getParameter('baba');
|
||||||
$this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist');
|
$this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist');
|
||||||
@ -125,6 +121,20 @@ class ContainerTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since version 3.4.
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "FOO" instead of "foo" is deprecated since version 3.4.
|
||||||
|
*/
|
||||||
|
public function testGetSetParameterWithMixedCase()
|
||||||
|
{
|
||||||
|
$sc = new Container(new ParameterBag(array('foo' => 'bar')));
|
||||||
|
|
||||||
|
$sc->setParameter('Foo', 'baz1');
|
||||||
|
$this->assertEquals('baz1', $sc->getParameter('foo'), '->setParameter() converts the key to lowercase');
|
||||||
|
$this->assertEquals('baz1', $sc->getParameter('FOO'), '->getParameter() converts the key to lowercase');
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetServiceIds()
|
public function testGetServiceIds()
|
||||||
{
|
{
|
||||||
$sc = new Container();
|
$sc = new Container();
|
||||||
|
@ -650,4 +650,43 @@ class PhpDumperTest extends TestCase
|
|||||||
|
|
||||||
$container->get('bar');
|
$container->get('bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "foo" instead of "Foo" is deprecated since version 3.4.
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "FOO" instead of "Foo" is deprecated since version 3.4.
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "bar" instead of "BAR" is deprecated since version 3.4.
|
||||||
|
*/
|
||||||
|
public function testParameterWithMixedCase()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder(new ParameterBag(array('Foo' => 'bar', 'BAR' => 'foo')));
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$dumper = new PhpDumper($container);
|
||||||
|
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Parameter_With_Mixed_Case')));
|
||||||
|
|
||||||
|
$container = new \Symfony_DI_PhpDumper_Test_Parameter_With_Mixed_Case();
|
||||||
|
|
||||||
|
$this->assertSame('bar', $container->getParameter('foo'));
|
||||||
|
$this->assertSame('bar', $container->getParameter('FOO'));
|
||||||
|
$this->assertSame('foo', $container->getParameter('bar'));
|
||||||
|
$this->assertSame('foo', $container->getParameter('BAR'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "FOO" instead of "foo" is deprecated since version 3.4.
|
||||||
|
*/
|
||||||
|
public function testParameterWithLowerCase()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$dumper = new PhpDumper($container);
|
||||||
|
eval('?>'.$dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Parameter_With_Lower_Case')));
|
||||||
|
|
||||||
|
$container = new \Symfony_DI_PhpDumper_Test_Parameter_With_Lower_Case();
|
||||||
|
|
||||||
|
$this->assertSame('bar', $container->getParameter('FOO'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
|
|
||||||
$container = new ContainerBuilder(new ParameterBag(array(
|
$container = new ContainerBuilder(new ParameterBag(array(
|
||||||
'FOO' => '%baz%',
|
'foo' => '%baz%',
|
||||||
'baz' => 'bar',
|
'baz' => 'bar',
|
||||||
'bar' => 'foo is %%foo bar',
|
'bar' => 'foo is %%foo bar',
|
||||||
'escape' => '@escapeme',
|
'escape' => '@escapeme',
|
||||||
|
@ -78,7 +78,7 @@ class ProjectServiceContainer extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -96,7 +96,7 @@ class ProjectServiceContainer extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -142,6 +142,22 @@ class ProjectServiceContainer extends Container
|
|||||||
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array();
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
|
@ -82,7 +82,7 @@ class ProjectServiceContainer extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -100,7 +100,7 @@ class ProjectServiceContainer extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -156,6 +156,22 @@ class ProjectServiceContainer extends Container
|
|||||||
return $this->dynamicParameters[$name] = $value;
|
return $this->dynamicParameters[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array();
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
|
@ -80,7 +80,7 @@ class ProjectServiceContainer extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -98,7 +98,7 @@ class ProjectServiceContainer extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -152,6 +152,24 @@ class ProjectServiceContainer extends Container
|
|||||||
return $this->dynamicParameters[$name] = $value;
|
return $this->dynamicParameters[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array(
|
||||||
|
'env(foo)' => 'env(FOO)',
|
||||||
|
);
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
@ -160,7 +178,7 @@ class ProjectServiceContainer extends Container
|
|||||||
protected function getDefaultParameters()
|
protected function getDefaultParameters()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'env(foo)' => 'foo',
|
'env(FOO)' => 'foo',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class ProjectServiceContainer extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -83,7 +83,7 @@ class ProjectServiceContainer extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -129,6 +129,22 @@ class ProjectServiceContainer extends Container
|
|||||||
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array();
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
|
@ -383,7 +383,7 @@ class Container%s extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -401,7 +401,7 @@ class Container%s extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -447,6 +447,22 @@ class Container%s extends Container
|
|||||||
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array();
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
|
@ -392,7 +392,7 @@ class ProjectServiceContainer extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -410,7 +410,7 @@ class ProjectServiceContainer extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -456,6 +456,22 @@ class ProjectServiceContainer extends Container
|
|||||||
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array();
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
|
@ -86,7 +86,7 @@ class ProjectServiceContainer extends Container
|
|||||||
public function getParameter($name)
|
public function getParameter($name)
|
||||||
{
|
{
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
|
||||||
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
|
||||||
@ -104,7 +104,7 @@ class ProjectServiceContainer extends Container
|
|||||||
*/
|
*/
|
||||||
public function hasParameter($name)
|
public function hasParameter($name)
|
||||||
{
|
{
|
||||||
$name = strtolower($name);
|
$name = $this->normalizeParameterName($name);
|
||||||
|
|
||||||
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
|
||||||
}
|
}
|
||||||
@ -160,6 +160,22 @@ class ProjectServiceContainer extends Container
|
|||||||
return $this->dynamicParameters[$name] = $value;
|
return $this->dynamicParameters[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private $normalizedParameterNames = array();
|
||||||
|
|
||||||
|
private function normalizeParameterName($name)
|
||||||
|
{
|
||||||
|
if (isset($this->normalizedParameterNames[$normalizedName = strtolower($name)]) || isset($this->parameters[$normalizedName]) || array_key_exists($normalizedName, $this->parameters)) {
|
||||||
|
$normalizedName = isset($this->normalizedParameterNames[$normalizedName]) ? $this->normalizedParameterNames[$normalizedName] : $normalizedName;
|
||||||
|
if ((string) $name !== $normalizedName) {
|
||||||
|
@trigger_error(sprintf('Parameter names will be made case sensitive in Symfony 4.0. Using "%s" instead of "%s" is deprecated since version 3.4.', $name, $normalizedName), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$normalizedName = $this->normalizedParameterNames[$normalizedName] = (string) $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default parameters.
|
* Gets the default parameters.
|
||||||
*
|
*
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter>a string</parameter>
|
<parameter>a string</parameter>
|
||||||
<parameter key="FOO">bar</parameter>
|
<parameter key="foo">bar</parameter>
|
||||||
<parameter key="values" type="collection">
|
<parameter key="values" type="collection">
|
||||||
<parameter>0</parameter>
|
<parameter>0</parameter>
|
||||||
<parameter key="integer">4</parameter>
|
<parameter key="integer">4</parameter>
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<parameter>bar</parameter>
|
<parameter>bar</parameter>
|
||||||
</parameter>
|
</parameter>
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter key="MixedCase" type="collection"> <!-- Should be lower cased -->
|
<parameter key="mixedcase" type="collection"> <!-- Should be lower cased -->
|
||||||
<parameter key="MixedCaseKey">value</parameter> <!-- Should stay mixed case -->
|
<parameter key="MixedCaseKey">value</parameter> <!-- Should stay mixed case -->
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter key="constant" type="constant">PHP_EOL</parameter>
|
<parameter key="constant" type="constant">PHP_EOL</parameter>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
parameters:
|
parameters:
|
||||||
FOO: bar
|
foo: bar
|
||||||
values:
|
values:
|
||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
@ -9,5 +9,5 @@ parameters:
|
|||||||
bar: foo
|
bar: foo
|
||||||
escape: '@@escapeme'
|
escape: '@@escapeme'
|
||||||
foo_bar: '@foo_bar'
|
foo_bar: '@foo_bar'
|
||||||
MixedCase:
|
mixedcase:
|
||||||
MixedCaseKey: value
|
MixedCaseKey: value
|
||||||
|
@ -115,18 +115,18 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
|||||||
{
|
{
|
||||||
$bag = new EnvPlaceholderParameterBag();
|
$bag = new EnvPlaceholderParameterBag();
|
||||||
$bag->get('env(INT_VAR)');
|
$bag->get('env(INT_VAR)');
|
||||||
$bag->set('env(Int_Var)', 2);
|
$bag->set('env(INT_VAR)', 2);
|
||||||
$bag->resolve();
|
$bag->resolve();
|
||||||
$this->assertSame('2', $bag->all()['env(int_var)']);
|
$this->assertSame('2', $bag->all()['env(INT_VAR)']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testResolveEnvAllowsNull()
|
public function testResolveEnvAllowsNull()
|
||||||
{
|
{
|
||||||
$bag = new EnvPlaceholderParameterBag();
|
$bag = new EnvPlaceholderParameterBag();
|
||||||
$bag->get('env(NULL_VAR)');
|
$bag->get('env(NULL_VAR)');
|
||||||
$bag->set('env(Null_Var)', null);
|
$bag->set('env(NULL_VAR)', null);
|
||||||
$bag->resolve();
|
$bag->resolve();
|
||||||
$this->assertNull($bag->all()['env(null_var)']);
|
$this->assertNull($bag->all()['env(NULL_VAR)']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +137,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
|||||||
{
|
{
|
||||||
$bag = new EnvPlaceholderParameterBag();
|
$bag = new EnvPlaceholderParameterBag();
|
||||||
$bag->get('env(ARRAY_VAR)');
|
$bag->get('env(ARRAY_VAR)');
|
||||||
$bag->set('env(Array_Var)', array());
|
$bag->set('env(ARRAY_VAR)', array());
|
||||||
$bag->resolve();
|
$bag->resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
|||||||
$bag->get('env(NULL_VAR)');
|
$bag->get('env(NULL_VAR)');
|
||||||
$bag->resolve();
|
$bag->resolve();
|
||||||
|
|
||||||
$this->assertNull($bag->all()['env(null_var)']);
|
$this->assertNull($bag->all()['env(NULL_VAR)']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,8 +46,6 @@ class ParameterBagTest extends TestCase
|
|||||||
));
|
));
|
||||||
$bag->remove('foo');
|
$bag->remove('foo');
|
||||||
$this->assertEquals(array('bar' => 'bar'), $bag->all(), '->remove() removes a parameter');
|
$this->assertEquals(array('bar' => 'bar'), $bag->all(), '->remove() removes a parameter');
|
||||||
$bag->remove('BAR');
|
|
||||||
$this->assertEquals(array(), $bag->all(), '->remove() converts key to lowercase before removing');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetSet()
|
public function testGetSet()
|
||||||
@ -59,10 +57,6 @@ class ParameterBagTest extends TestCase
|
|||||||
$bag->set('foo', 'baz');
|
$bag->set('foo', 'baz');
|
||||||
$this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter');
|
$this->assertEquals('baz', $bag->get('foo'), '->set() overrides previously set parameter');
|
||||||
|
|
||||||
$bag->set('Foo', 'baz1');
|
|
||||||
$this->assertEquals('baz1', $bag->get('foo'), '->set() converts the key to lowercase');
|
|
||||||
$this->assertEquals('baz1', $bag->get('FOO'), '->get() converts the key to lowercase');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$bag->get('baba');
|
$bag->get('baba');
|
||||||
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist');
|
$this->fail('->get() throws an Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException if the key does not exist');
|
||||||
@ -109,10 +103,33 @@ class ParameterBagTest extends TestCase
|
|||||||
{
|
{
|
||||||
$bag = new ParameterBag(array('foo' => 'bar'));
|
$bag = new ParameterBag(array('foo' => 'bar'));
|
||||||
$this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined');
|
$this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined');
|
||||||
$this->assertTrue($bag->has('Foo'), '->has() converts the key to lowercase');
|
|
||||||
$this->assertFalse($bag->has('bar'), '->has() returns false if a parameter is not defined');
|
$this->assertFalse($bag->has('bar'), '->has() returns false if a parameter is not defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "BAR" instead of "bar" is deprecated since version 3.4.
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since version 3.4.
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "FOO" instead of "foo" is deprecated since version 3.4.
|
||||||
|
* @expectedDeprecation Parameter names will be made case sensitive in Symfony 4.0. Using "Foo" instead of "foo" is deprecated since version 3.4.
|
||||||
|
*/
|
||||||
|
public function testMixedCase()
|
||||||
|
{
|
||||||
|
$bag = new ParameterBag(array(
|
||||||
|
'foo' => 'foo',
|
||||||
|
'bar' => 'bar',
|
||||||
|
));
|
||||||
|
|
||||||
|
$bag->remove('BAR');
|
||||||
|
$this->assertEquals(array('foo' => 'foo'), $bag->all(), '->remove() converts key to lowercase before removing');
|
||||||
|
|
||||||
|
$bag->set('Foo', 'baz1');
|
||||||
|
$this->assertEquals('baz1', $bag->get('foo'), '->set() converts the key to lowercase');
|
||||||
|
$this->assertEquals('baz1', $bag->get('FOO'), '->get() converts the key to lowercase');
|
||||||
|
|
||||||
|
$this->assertTrue($bag->has('Foo'), '->has() converts the key to lowercase');
|
||||||
|
}
|
||||||
|
|
||||||
public function testResolveValue()
|
public function testResolveValue()
|
||||||
{
|
{
|
||||||
$bag = new ParameterBag(array());
|
$bag = new ParameterBag(array());
|
||||||
|
@ -39,7 +39,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
|||||||
*
|
*
|
||||||
* @param string $storageKey The key used to store flashes in the session
|
* @param string $storageKey The key used to store flashes in the session
|
||||||
*/
|
*/
|
||||||
public function __construct($storageKey = '_sf2_flashes')
|
public function __construct($storageKey = '_symfony_flashes')
|
||||||
{
|
{
|
||||||
$this->storageKey = $storageKey;
|
$this->storageKey = $storageKey;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class FlashBag implements FlashBagInterface
|
|||||||
*
|
*
|
||||||
* @param string $storageKey The key used to store flashes in the session
|
* @param string $storageKey The key used to store flashes in the session
|
||||||
*/
|
*/
|
||||||
public function __construct($storageKey = '_sf2_flashes')
|
public function __construct($storageKey = '_symfony_flashes')
|
||||||
{
|
{
|
||||||
$this->storageKey = $storageKey;
|
$this->storageKey = $storageKey;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class AutoExpireFlashBagTest extends TestCase
|
|||||||
|
|
||||||
public function testGetStorageKey()
|
public function testGetStorageKey()
|
||||||
{
|
{
|
||||||
$this->assertEquals('_sf2_flashes', $this->bag->getStorageKey());
|
$this->assertEquals('_symfony_flashes', $this->bag->getStorageKey());
|
||||||
$attributeBag = new FlashBag('test');
|
$attributeBag = new FlashBag('test');
|
||||||
$this->assertEquals('test', $attributeBag->getStorageKey());
|
$this->assertEquals('test', $attributeBag->getStorageKey());
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class FlashBagTest extends TestCase
|
|||||||
|
|
||||||
public function testGetStorageKey()
|
public function testGetStorageKey()
|
||||||
{
|
{
|
||||||
$this->assertEquals('_sf2_flashes', $this->bag->getStorageKey());
|
$this->assertEquals('_symfony_flashes', $this->bag->getStorageKey());
|
||||||
$attributeBag = new FlashBag('test');
|
$attributeBag = new FlashBag('test');
|
||||||
$this->assertEquals('test', $attributeBag->getStorageKey());
|
$this->assertEquals('test', $attributeBag->getStorageKey());
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
*/
|
*/
|
||||||
class XliffLintCommand extends Command
|
class XliffLintCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'lint:xliff';
|
||||||
|
|
||||||
private $format;
|
private $format;
|
||||||
private $displayCorrectFiles;
|
private $displayCorrectFiles;
|
||||||
private $directoryIteratorProvider;
|
private $directoryIteratorProvider;
|
||||||
@ -45,7 +47,6 @@ class XliffLintCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('lint:xliff')
|
|
||||||
->setDescription('Lints a XLIFF file and outputs encountered errors')
|
->setDescription('Lints a XLIFF file and outputs encountered errors')
|
||||||
->addArgument('filename', null, 'A file or a directory or STDIN')
|
->addArgument('filename', null, 'A file or a directory or STDIN')
|
||||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||||
|
@ -222,7 +222,7 @@ class XliffFileLoader implements LoaderInterface
|
|||||||
$newPath = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd';
|
$newPath = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd';
|
||||||
$parts = explode('/', $newPath);
|
$parts = explode('/', $newPath);
|
||||||
if (0 === stripos($newPath, 'phar://')) {
|
if (0 === stripos($newPath, 'phar://')) {
|
||||||
$tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
|
$tmpfile = tempnam(sys_get_temp_dir(), 'symfony');
|
||||||
if ($tmpfile) {
|
if ($tmpfile) {
|
||||||
copy($newPath, $tmpfile);
|
copy($newPath, $tmpfile);
|
||||||
$parts = explode('/', str_replace('\\', '/', $tmpfile));
|
$parts = explode('/', str_replace('\\', '/', $tmpfile));
|
||||||
|
@ -28,6 +28,8 @@ use Symfony\Component\Yaml\Yaml;
|
|||||||
*/
|
*/
|
||||||
class LintCommand extends Command
|
class LintCommand extends Command
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'lint:yaml';
|
||||||
|
|
||||||
private $parser;
|
private $parser;
|
||||||
private $format;
|
private $format;
|
||||||
private $displayCorrectFiles;
|
private $displayCorrectFiles;
|
||||||
@ -48,7 +50,6 @@ class LintCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('lint:yaml')
|
|
||||||
->setDescription('Lints a file and outputs encountered errors')
|
->setDescription('Lints a file and outputs encountered errors')
|
||||||
->addArgument('filename', null, 'A file or a directory or STDIN')
|
->addArgument('filename', null, 'A file or a directory or STDIN')
|
||||||
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/console": "~3.4|~4.0"
|
"symfony/console": "~3.4|~4.0"
|
||||||
},
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/console": "<3.4"
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/console": "For validating YAML files using the lint command"
|
"symfony/console": "For validating YAML files using the lint command"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user