Merge branch '4.2'
* 4.2: (26 commits) Apply php-cs-fixer rule for array_key_exists() [Cache] fix warming up cache.system and apcu [Security] Change FormAuthenticator if condition handles multi-byte characters in autocomplete speed up tests running them without debug flag [Translations] added missing Croatian validators Fix getItems() performance issue with RedisCluster (php-redis) [VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning IntegerType: reject submitted non-integer numbers be keen to newcomers [HttpKernel] Fix possible infinite loop of exceptions fixed CS [Validator] Added missing translations for Afrikaans do not validate non-submitted form fields in PATCH requests Update usage example in ArrayInput doc block. [Console] Prevent ArgvInput::getFirstArgument() from returning an option value [Validator] Fixed duplicate UUID fixed CS [EventDispatcher] Fix unknown priority Avoid mutating the Finder when building the iterator ...
This commit is contained in:
commit
a0c566504c
@ -230,7 +230,7 @@ DependencyInjection
|
||||
supported.
|
||||
|
||||
* The ``strict`` attribute in service arguments has been removed.
|
||||
The attribute is ignored since 3.0, so you can simply remove it.
|
||||
The attribute is ignored since 3.0, you can remove it.
|
||||
|
||||
* Top-level anonymous services in XML are no longer supported.
|
||||
|
||||
|
@ -24,8 +24,8 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
* The compiler pass is meant to register the mappings with the metadata
|
||||
* chain driver corresponding to one of the object managers.
|
||||
*
|
||||
* For concrete implementations that are easy to use, see the
|
||||
* RegisterXyMappingsPass classes in the DoctrineBundle resp.
|
||||
* For concrete implementations, see the RegisterXyMappingsPass classes
|
||||
* in the DoctrineBundle resp.
|
||||
* DoctrineMongodbBundle, DoctrineCouchdbBundle and DoctrinePhpcrBundle.
|
||||
*
|
||||
* @author David Buchmann <david@liip.ch>
|
||||
|
@ -165,7 +165,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
||||
// normalize class name
|
||||
$class = self::getRealClass(ltrim($class, '\\'));
|
||||
|
||||
if (array_key_exists($class, $this->cache)) {
|
||||
if (\array_key_exists($class, $this->cache)) {
|
||||
return $this->cache[$class];
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
/**
|
||||
* Wrapper around a Doctrine ObjectManager.
|
||||
*
|
||||
* Provides easy to use provisioning for Doctrine entity users.
|
||||
* Provides provisioning for Doctrine entity users.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
|
@ -31,10 +31,10 @@ class HttpCodeActivationStrategy extends ErrorLevelActivationStrategy
|
||||
public function __construct(RequestStack $requestStack, array $exclusions, $actionLevel)
|
||||
{
|
||||
foreach ($exclusions as $exclusion) {
|
||||
if (!array_key_exists('code', $exclusion)) {
|
||||
if (!\array_key_exists('code', $exclusion)) {
|
||||
throw new \LogicException(sprintf('An exclusion must have a "code" key'));
|
||||
}
|
||||
if (!array_key_exists('urls', $exclusion)) {
|
||||
if (!\array_key_exists('urls', $exclusion)) {
|
||||
throw new \LogicException(sprintf('An exclusion must have a "urls" key'));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
return new class
|
||||
{
|
||||
return new class() {
|
||||
public $proxyClass;
|
||||
private $privates = [];
|
||||
|
||||
|
@ -77,7 +77,7 @@ class Scope
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
if (\array_key_exists($key, $this->data)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class Scope
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
if (\array_key_exists($key, $this->data)) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ EOF
|
||||
$steps = explode('.', $path);
|
||||
|
||||
foreach ($steps as $step) {
|
||||
if (!array_key_exists($step, $config)) {
|
||||
if (!\array_key_exists($step, $config)) {
|
||||
throw new LogicException(sprintf('Unable to find configuration for "%s.%s"', $alias, $path));
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
|
||||
|
||||
use Symfony\Component\Config\Resource\ClassExistenceResource;
|
||||
use Symfony\Component\Console\Descriptor\DescriptorInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
@ -226,7 +227,7 @@ abstract class Descriptor implements DescriptorInterface
|
||||
return $builder->getDefinition($serviceId);
|
||||
}
|
||||
|
||||
// Some service IDs don't have a Definition, they're simply an Alias
|
||||
// Some service IDs don't have a Definition, they're aliases
|
||||
if ($builder->hasAlias($serviceId)) {
|
||||
return $builder->getAlias($serviceId);
|
||||
}
|
||||
@ -292,6 +293,11 @@ abstract class Descriptor implements DescriptorInterface
|
||||
{
|
||||
$resolvedClass = $class;
|
||||
try {
|
||||
$resource = new ClassExistenceResource($class, false);
|
||||
|
||||
// isFresh() will explode ONLY if a parent class/trait does not exist
|
||||
$resource->isFresh(0);
|
||||
|
||||
$r = new \ReflectionClass($class);
|
||||
$resolvedClass = $r->name;
|
||||
|
||||
|
@ -156,7 +156,7 @@ class JsonDescriptor extends Descriptor
|
||||
*/
|
||||
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
|
||||
{
|
||||
$this->writeData($this->getEventDispatcherListenersData($eventDispatcher, array_key_exists('event', $options) ? $options['event'] : null), $options);
|
||||
$this->writeData($this->getEventDispatcherListenersData($eventDispatcher, \array_key_exists('event', $options) ? $options['event'] : null), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,7 +274,7 @@ class MarkdownDescriptor extends Descriptor
|
||||
*/
|
||||
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
|
||||
{
|
||||
$event = array_key_exists('event', $options) ? $options['event'] : null;
|
||||
$event = \array_key_exists('event', $options) ? $options['event'] : null;
|
||||
|
||||
$title = 'Registered listeners';
|
||||
if (null !== $event) {
|
||||
|
@ -385,7 +385,7 @@ class TextDescriptor extends Descriptor
|
||||
*/
|
||||
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
|
||||
{
|
||||
$event = array_key_exists('event', $options) ? $options['event'] : null;
|
||||
$event = \array_key_exists('event', $options) ? $options['event'] : null;
|
||||
|
||||
if (null !== $event) {
|
||||
$title = sprintf('Registered Listeners for "%s" Event', $event);
|
||||
|
@ -112,7 +112,7 @@ class XmlDescriptor extends Descriptor
|
||||
*/
|
||||
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
|
||||
{
|
||||
$this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, array_key_exists('event', $options) ? $options['event'] : null));
|
||||
$this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, \array_key_exists('event', $options) ? $options['event'] : null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,7 +327,7 @@ class Configuration implements ConfigurationInterface
|
||||
}
|
||||
|
||||
foreach ($places as $name => $place) {
|
||||
if (\is_array($place) && array_key_exists('name', $place)) {
|
||||
if (\is_array($place) && \array_key_exists('name', $place)) {
|
||||
continue;
|
||||
}
|
||||
$place['name'] = $name;
|
||||
@ -365,7 +365,7 @@ class Configuration implements ConfigurationInterface
|
||||
}
|
||||
|
||||
foreach ($transitions as $name => $transition) {
|
||||
if (\is_array($transition) && array_key_exists('name', $transition)) {
|
||||
if (\is_array($transition) && \array_key_exists('name', $transition)) {
|
||||
continue;
|
||||
}
|
||||
$transition['name'] = $name;
|
||||
|
@ -939,7 +939,7 @@ class FrameworkExtension extends Extension
|
||||
foreach ($config['packages'] as $name => $package) {
|
||||
if (null !== $package['version_strategy']) {
|
||||
$version = new Reference($package['version_strategy']);
|
||||
} elseif (!array_key_exists('version', $package) && null === $package['json_manifest_path']) {
|
||||
} elseif (!\array_key_exists('version', $package) && null === $package['json_manifest_path']) {
|
||||
// if neither version nor json_manifest_path are specified, use the default
|
||||
$version = $defaultVersion;
|
||||
} else {
|
||||
@ -1146,7 +1146,7 @@ class FrameworkExtension extends Extension
|
||||
$definition = $container->findDefinition('validator.email');
|
||||
$definition->replaceArgument(0, $config['email_validation_mode']);
|
||||
|
||||
if (array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
|
||||
if (\array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
|
||||
if (!$this->annotationsConfigEnabled) {
|
||||
throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
|
||||
}
|
||||
@ -1154,7 +1154,7 @@ class FrameworkExtension extends Extension
|
||||
$validatorBuilder->addMethodCall('enableAnnotationMapping', [new Reference('annotation_reader')]);
|
||||
}
|
||||
|
||||
if (array_key_exists('static_method', $config) && $config['static_method']) {
|
||||
if (\array_key_exists('static_method', $config) && $config['static_method']) {
|
||||
foreach ($config['static_method'] as $methodName) {
|
||||
$validatorBuilder->addMethodCall('addMethodMapping', [$methodName]);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class CacheClearCommandTest extends TestCase
|
||||
// Ensure that all *.meta files are fresh
|
||||
$finder = new Finder();
|
||||
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
|
||||
// simply check that cache is warmed up
|
||||
// check that cache is warmed up
|
||||
$this->assertNotEmpty($metaFiles);
|
||||
$configCacheFactory = new ConfigCacheFactory(true);
|
||||
|
||||
|
@ -22,7 +22,7 @@ class ContainerDebugCommandTest extends WebTestCase
|
||||
{
|
||||
public function testDumpContainerIfNotExists()
|
||||
{
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml']);
|
||||
static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => true]);
|
||||
|
||||
$application = new Application(static::$kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
@ -62,7 +62,7 @@ class WebTestCase extends BaseWebTestCase
|
||||
$options['test_case'],
|
||||
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
|
||||
isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']),
|
||||
isset($options['debug']) ? $options['debug'] : true
|
||||
isset($options['debug']) ? $options['debug'] : false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
foreach ($container->getExtensionConfig('framework') as $config) {
|
||||
if (isset($config['session']) && \is_array($config['session'])) {
|
||||
$rememberMeSecureDefault = $config['session']['cookie_secure'] ?? $rememberMeSecureDefault;
|
||||
$rememberMeSameSiteDefault = array_key_exists('cookie_samesite', $config['session']) ? $config['session']['cookie_samesite'] : $rememberMeSameSiteDefault;
|
||||
$rememberMeSameSiteDefault = \array_key_exists('cookie_samesite', $config['session']) ? $config['session']['cookie_samesite'] : $rememberMeSameSiteDefault;
|
||||
}
|
||||
}
|
||||
foreach ($this->listenerPositions as $position) {
|
||||
@ -412,7 +412,7 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
|
||||
foreach ($this->factories as $position) {
|
||||
foreach ($position as $factory) {
|
||||
$key = str_replace('-', '_', $factory->getKey());
|
||||
if (array_key_exists($key, $firewall)) {
|
||||
if (\array_key_exists($key, $firewall)) {
|
||||
$listenerKeys[] = $key;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class WebTestCase extends BaseWebTestCase
|
||||
$options['test_case'],
|
||||
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
|
||||
isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']),
|
||||
isset($options['debug']) ? $options['debug'] : true
|
||||
isset($options['debug']) ? $options['debug'] : false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
* If you have custom directory layout, then you have to write your own router
|
||||
* and pass it as a value to 'router' option of server:run command.
|
||||
*
|
||||
* @author: Michał Pipa <michal.pipa.xsolve@gmail.com>
|
||||
* @author: Albert Jessurum <ajessu@gmail.com>
|
||||
* @author Michał Pipa <michal.pipa.xsolve@gmail.com>
|
||||
* @author Albert Jessurum <ajessu@gmail.com>
|
||||
*/
|
||||
|
||||
// Workaround https://bugs.php.net/64566
|
||||
|
@ -548,7 +548,7 @@ abstract class Client
|
||||
{
|
||||
do {
|
||||
$request = $this->history->back();
|
||||
} while (array_key_exists(serialize($request), $this->redirects));
|
||||
} while (\array_key_exists(serialize($request), $this->redirects));
|
||||
|
||||
return $this->requestFromRequest($request, false);
|
||||
}
|
||||
@ -562,7 +562,7 @@ abstract class Client
|
||||
{
|
||||
do {
|
||||
$request = $this->history->forward();
|
||||
} while (array_key_exists(serialize($request), $this->redirects));
|
||||
} while (\array_key_exists(serialize($request), $this->redirects));
|
||||
|
||||
return $this->requestFromRequest($request, false);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
|
||||
* Returns the best possible adapter that your runtime supports.
|
||||
*
|
||||
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
|
||||
*
|
||||
@ -108,16 +108,12 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
*/
|
||||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
||||
{
|
||||
if (null === self::$apcuSupported) {
|
||||
self::$apcuSupported = ApcuAdapter::isSupported();
|
||||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
|
||||
if (null !== $logger) {
|
||||
$opcache->setLogger($logger);
|
||||
}
|
||||
|
||||
if (!self::$apcuSupported) {
|
||||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
|
||||
if (null !== $logger) {
|
||||
$opcache->setLogger($logger);
|
||||
}
|
||||
|
||||
if (!self::$apcuSupported = self::$apcuSupported ?? ApcuAdapter::isSupported()) {
|
||||
return $opcache;
|
||||
}
|
||||
|
||||
@ -128,7 +124,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
||||
$apcu->setLogger($logger);
|
||||
}
|
||||
|
||||
return $apcu;
|
||||
return new ChainAdapter([$apcu, $opcache]);
|
||||
}
|
||||
|
||||
public static function createConnection($dsn, array $options = [])
|
||||
|
@ -22,7 +22,7 @@ abstract class AdapterTestCase extends CachePoolTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!array_key_exists('testPrune', $this->skippedTests) && !$this->createCachePool() instanceof PruneableInterface) {
|
||||
if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createCachePool() instanceof PruneableInterface) {
|
||||
$this->skippedTests['testPrune'] = 'Not a pruneable cache pool.';
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class Psr16CacheTest extends SimpleCacheTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (array_key_exists('testPrune', $this->skippedTests)) {
|
||||
if (\array_key_exists('testPrune', $this->skippedTests)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ abstract class CacheTestCase extends SimpleCacheTest
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) {
|
||||
if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) {
|
||||
$this->skippedTests['testPrune'] = 'Not a pruneable cache pool.';
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ trait MemcachedTrait
|
||||
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
|
||||
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
|
||||
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
|
||||
if (!array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
|
||||
if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
|
||||
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
|
||||
}
|
||||
foreach ($options as $name => $value) {
|
||||
|
@ -284,7 +284,7 @@ trait RedisTrait
|
||||
|
||||
$result = [];
|
||||
|
||||
if ($this->redis instanceof \Predis\Client) {
|
||||
if ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface) {
|
||||
$values = $this->pipeline(function () use ($ids) {
|
||||
foreach ($ids as $id) {
|
||||
yield 'get' => [$id];
|
||||
|
@ -59,7 +59,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
$normalized = [];
|
||||
|
||||
foreach ($value as $k => $v) {
|
||||
if (false !== strpos($k, '-') && false === strpos($k, '_') && !array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
|
||||
if (false !== strpos($k, '-') && false === strpos($k, '_') && !\array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) {
|
||||
$normalized[$normalizedKey] = $v;
|
||||
} else {
|
||||
$normalized[$k] = $v;
|
||||
@ -223,7 +223,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
}
|
||||
|
||||
foreach ($this->children as $name => $child) {
|
||||
if (!array_key_exists($name, $value)) {
|
||||
if (!\array_key_exists($name, $value)) {
|
||||
if ($child->isRequired()) {
|
||||
$ex = new InvalidConfigurationException(sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
@ -383,7 +383,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
||||
|
||||
foreach ($rightSide as $k => $v) {
|
||||
// no conflict
|
||||
if (!array_key_exists($k, $leftSide)) {
|
||||
if (!\array_key_exists($k, $leftSide)) {
|
||||
if (!$this->allowNewKeys) {
|
||||
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
@ -332,10 +332,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
* Allows extra config keys to be specified under an array without
|
||||
* throwing an exception.
|
||||
*
|
||||
* Those config values are simply ignored and removed from the
|
||||
* resulting array. This should be used only in special cases where
|
||||
* you want to send an entire configuration array through a special
|
||||
* tree that processes only part of the array.
|
||||
* Those config values are ignored and removed from the resulting
|
||||
* array. This should be used only in special cases where you want
|
||||
* to send an entire configuration array through a special tree that
|
||||
* processes only part of the array.
|
||||
*
|
||||
* @param bool $remove Whether to remove the extra keys
|
||||
*
|
||||
|
@ -245,7 +245,7 @@ class PrototypedArrayNode extends ArrayNode
|
||||
// if only "value" is left
|
||||
if (array_keys($v) === ['value']) {
|
||||
$v = $v['value'];
|
||||
if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && array_key_exists('value', $children)) {
|
||||
if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) {
|
||||
$valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
|
||||
$valuePrototype->parent = $this;
|
||||
$originalClosures = $this->prototype->normalizationClosures;
|
||||
@ -258,7 +258,7 @@ class PrototypedArrayNode extends ArrayNode
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists($k, $normalized)) {
|
||||
if (\array_key_exists($k, $normalized)) {
|
||||
$ex = new DuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
||||
@ -301,14 +301,14 @@ class PrototypedArrayNode extends ArrayNode
|
||||
}
|
||||
|
||||
foreach ($rightSide as $k => $v) {
|
||||
// prototype, and key is irrelevant, so simply append the element
|
||||
// prototype, and key is irrelevant, append the element
|
||||
if (null === $this->keyAttribute) {
|
||||
$leftSide[] = $v;
|
||||
continue;
|
||||
}
|
||||
|
||||
// no conflict
|
||||
if (!array_key_exists($k, $leftSide)) {
|
||||
if (!\array_key_exists($k, $leftSide)) {
|
||||
if (!$this->allowNewKeys) {
|
||||
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath()));
|
||||
$ex->setPath($this->getPath());
|
||||
|
@ -199,6 +199,13 @@ class Application
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
// Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument.
|
||||
$input->bind($this->getDefinition());
|
||||
} catch (ExceptionInterface $e) {
|
||||
// Errors must be ignored, full binding/validation happens later when the command is known.
|
||||
}
|
||||
|
||||
$name = $this->getCommandName($input);
|
||||
if (true === $input->hasParameterOption(['--help', '-h'], true)) {
|
||||
if (!$name) {
|
||||
|
@ -269,6 +269,10 @@ class QuestionHelper extends Helper
|
||||
|
||||
continue;
|
||||
} else {
|
||||
if ("\x80" <= $c) {
|
||||
$c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
|
||||
}
|
||||
|
||||
$output->write($c);
|
||||
$ret .= $c;
|
||||
++$i;
|
||||
|
@ -257,8 +257,27 @@ class ArgvInput extends Input
|
||||
*/
|
||||
public function getFirstArgument()
|
||||
{
|
||||
foreach ($this->tokens as $token) {
|
||||
$isOption = false;
|
||||
foreach ($this->tokens as $i => $token) {
|
||||
if ($token && '-' === $token[0]) {
|
||||
if (false !== strpos($token, '=') || !isset($this->tokens[$i + 1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's a long option, consider that everything after "--" is the option name.
|
||||
// Otherwise, use the last char (if it's a short option set, only the last one can take a value with space separator)
|
||||
$name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
|
||||
if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
|
||||
// noop
|
||||
} elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
|
||||
$isOption = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($isOption) {
|
||||
$isOption = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Console\Exception\InvalidOptionException;
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $input = new ArrayInput(['name' => 'foo', '--bar' => 'foobar']);
|
||||
* $input = new ArrayInput(['command' => 'foo:bar', 'foo' => 'bar', '--bar' => 'foobar']);
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
$givenArguments = $this->arguments;
|
||||
|
||||
$missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
|
||||
return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
|
||||
return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
|
||||
});
|
||||
|
||||
if (\count($missingArguments) > 0) {
|
||||
@ -150,7 +150,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
|
||||
}
|
||||
|
||||
return array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
|
||||
return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -338,8 +338,10 @@ class InputDefinition
|
||||
* @return string The InputOption name
|
||||
*
|
||||
* @throws InvalidArgumentException When option given does not exist
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
private function shortcutToName($shortcut)
|
||||
public function shortcutToName($shortcut)
|
||||
{
|
||||
if (!isset($this->shortcuts[$shortcut])) {
|
||||
throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
|
@ -126,7 +126,7 @@ trait TesterTrait
|
||||
*/
|
||||
private function initOutput(array $options)
|
||||
{
|
||||
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
$this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
if (isset($options['decorated'])) {
|
||||
|
@ -968,6 +968,19 @@ class ApplicationTest extends TestCase
|
||||
$this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
|
||||
}
|
||||
|
||||
public function testRunWithGlobalOptionAndNoCommand()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$application->getDefinition()->addOption(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL));
|
||||
|
||||
$output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
$input = new ArgvInput(['cli.php', '--foo', 'bar']);
|
||||
|
||||
$this->assertSame(0, $application->run($input, $output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue #9285.
|
||||
*
|
||||
|
@ -237,6 +237,43 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
$this->assertSame('b', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
public function getInputs()
|
||||
{
|
||||
return [
|
||||
['$'], // 1 byte character
|
||||
['¢'], // 2 bytes character
|
||||
['€'], // 3 bytes character
|
||||
['𐍈'], // 4 bytes character
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInputs
|
||||
*/
|
||||
public function testAskWithAutocompleteWithMultiByteCharacter($character)
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
$inputStream = $this->getInputStream("$character\n");
|
||||
|
||||
$possibleChoices = [
|
||||
'$' => '1 byte character',
|
||||
'¢' => '2 bytes character',
|
||||
'€' => '3 bytes character',
|
||||
'𐍈' => '4 bytes character',
|
||||
];
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setHelperSet(new HelperSet([new FormatterHelper()]));
|
||||
|
||||
$question = new ChoiceQuestion('Please select a character', $possibleChoices);
|
||||
$question->setMaxAttempts(1);
|
||||
|
||||
$this->assertSame($character, $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
public function testAutocompleteWithTrailingBackslash()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
|
@ -312,6 +312,14 @@ class ArgvInputTest extends TestCase
|
||||
|
||||
$input = new ArgvInput(['cli.php', '-fbbar', 'foo']);
|
||||
$this->assertEquals('foo', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input');
|
||||
|
||||
$input = new ArgvInput(['cli.php', '--foo', 'fooval', 'bar']);
|
||||
$input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('arg')]));
|
||||
$this->assertSame('bar', $input->getFirstArgument());
|
||||
|
||||
$input = new ArgvInput(['cli.php', '-bf', 'fooval', 'argval']);
|
||||
$input->bind(new InputDefinition([new InputOption('bar', 'b', InputOption::VALUE_NONE), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('arg')]));
|
||||
$this->assertSame('argval', $input->getFirstArgument());
|
||||
}
|
||||
|
||||
public function testHasParameterOption()
|
||||
|
@ -222,7 +222,7 @@ class ErrorHandler
|
||||
}
|
||||
if (!\is_array($log)) {
|
||||
$log = [$log];
|
||||
} elseif (!array_key_exists(0, $log)) {
|
||||
} elseif (!\array_key_exists(0, $log)) {
|
||||
throw new \InvalidArgumentException('No logger provided');
|
||||
}
|
||||
if (null === $log[0]) {
|
||||
|
@ -44,7 +44,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
$functions = spl_autoload_functions();
|
||||
foreach ($functions as $function) {
|
||||
if (is_array($function) && $function[0] instanceof DebugClassLoader) {
|
||||
if (\is_array($function) && $function[0] instanceof DebugClassLoader) {
|
||||
$reflClass = new \ReflectionClass($function[0]);
|
||||
$reflProp = $reflClass->getProperty('classLoader');
|
||||
$reflProp->setAccessible(true);
|
||||
@ -205,7 +205,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
require __DIR__.'/Fixtures/FinalClasses.php';
|
||||
|
||||
$i = 1;
|
||||
while(class_exists($finalClass = __NAMESPACE__.'\\Fixtures\\FinalClass'.$i++, false)) {
|
||||
while (class_exists($finalClass = __NAMESPACE__.'\\Fixtures\\FinalClass'.$i++, false)) {
|
||||
spl_autoload_call($finalClass);
|
||||
class_exists('Test\\'.__NAMESPACE__.'\\Extends'.substr($finalClass, strrpos($finalClass, '\\') + 1), true);
|
||||
}
|
||||
@ -371,7 +371,7 @@ class ClassLoader
|
||||
|
||||
public function findFile($class)
|
||||
{
|
||||
$fixtureDir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR;
|
||||
$fixtureDir = __DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR;
|
||||
|
||||
if (__NAMESPACE__.'\TestingUnsilencing' === $class) {
|
||||
eval('-- parse error --');
|
||||
@ -380,7 +380,7 @@ class ClassLoader
|
||||
} elseif (__NAMESPACE__.'\TestingCaseMismatch' === $class) {
|
||||
eval('namespace '.__NAMESPACE__.'; class TestingCaseMisMatch {}');
|
||||
} elseif (__NAMESPACE__.'\Fixtures\Psr4CaseMismatch' === $class) {
|
||||
return $fixtureDir.'psr4'.DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php';
|
||||
return $fixtureDir.'psr4'.\DIRECTORY_SEPARATOR.'Psr4CaseMismatch.php';
|
||||
} elseif (__NAMESPACE__.'\Fixtures\NotPSR0' === $class) {
|
||||
return $fixtureDir.'reallyNotPsr0.php';
|
||||
} elseif (__NAMESPACE__.'\Fixtures\NotPSR0bis' === $class) {
|
||||
|
@ -71,7 +71,7 @@ class ChildDefinition extends Definition
|
||||
*/
|
||||
public function getArgument($index)
|
||||
{
|
||||
if (array_key_exists('index_'.$index, $this->arguments)) {
|
||||
if (\array_key_exists('index_'.$index, $this->arguments)) {
|
||||
return $this->arguments['index_'.$index];
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ class AutowirePass extends AbstractRecursivePass
|
||||
}
|
||||
|
||||
foreach ($parameters as $index => $parameter) {
|
||||
if (array_key_exists($index, $arguments) && '' !== $arguments[$index]) {
|
||||
if (\array_key_exists($index, $arguments) && '' !== $arguments[$index]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,10 @@ class RegisterServiceSubscribersPass extends AbstractRecursivePass
|
||||
if ([] !== array_diff(array_keys($attributes), ['id', 'key'])) {
|
||||
throw new InvalidArgumentException(sprintf('The "container.service_subscriber" tag accepts only the "key" and "id" attributes, "%s" given for service "%s".', implode('", "', array_keys($attributes)), $this->currentId));
|
||||
}
|
||||
if (!array_key_exists('id', $attributes)) {
|
||||
if (!\array_key_exists('id', $attributes)) {
|
||||
throw new InvalidArgumentException(sprintf('Missing "id" attribute on "container.service_subscriber" tag with key="%s" for service "%s".', $attributes['key'], $this->currentId));
|
||||
}
|
||||
if (!array_key_exists('key', $attributes)) {
|
||||
if (!\array_key_exists('key', $attributes)) {
|
||||
$attributes['key'] = $attributes['id'];
|
||||
}
|
||||
if (isset($serviceMap[$attributes['key']])) {
|
||||
|
@ -119,19 +119,19 @@ class ResolveBindingsPass extends AbstractRecursivePass
|
||||
}
|
||||
|
||||
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
|
||||
if (array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
|
||||
if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter);
|
||||
|
||||
if (array_key_exists($k = ltrim($typeHint, '\\').' $'.$parameter->name, $bindings)) {
|
||||
if (\array_key_exists($k = ltrim($typeHint, '\\').' $'.$parameter->name, $bindings)) {
|
||||
$arguments[$key] = $this->getBindingValue($bindings[$k]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists('$'.$parameter->name, $bindings)) {
|
||||
if (\array_key_exists('$'.$parameter->name, $bindings)) {
|
||||
$arguments[$key] = $this->getBindingValue($bindings['$'.$parameter->name]);
|
||||
|
||||
continue;
|
||||
|
@ -77,7 +77,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
|
||||
|
||||
$typeFound = false;
|
||||
foreach ($parameters as $j => $p) {
|
||||
if (!array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, true) === $key) {
|
||||
if (!\array_key_exists($j, $resolvedArguments) && ProxyHelper::getTypeHint($r, $p, true) === $key) {
|
||||
$resolvedArguments[$j] = $argument;
|
||||
$typeFound = true;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ class Container implements ResettableContainerInterface
|
||||
if (isset($this->resolving[$envName = "env($name)"])) {
|
||||
throw new ParameterCircularReferenceException(array_keys($this->resolving));
|
||||
}
|
||||
if (isset($this->envCache[$name]) || array_key_exists($name, $this->envCache)) {
|
||||
if (isset($this->envCache[$name]) || \array_key_exists($name, $this->envCache)) {
|
||||
return $this->envCache[$name];
|
||||
}
|
||||
if (!$this->has($id = 'container.env_var_processors_locator')) {
|
||||
|
@ -269,7 +269,7 @@ class Definition
|
||||
throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, \count($this->arguments) - 1));
|
||||
}
|
||||
|
||||
if (!array_key_exists($index, $this->arguments)) {
|
||||
if (!\array_key_exists($index, $this->arguments)) {
|
||||
throw new OutOfBoundsException(sprintf('The argument "%s" doesn\'t exist.', $index));
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ class Definition
|
||||
*/
|
||||
public function getArgument($index)
|
||||
{
|
||||
if (!array_key_exists($index, $this->arguments)) {
|
||||
if (!\array_key_exists($index, $this->arguments)) {
|
||||
throw new OutOfBoundsException(sprintf('The argument "%s" doesn\'t exist.', $index));
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ class GraphvizDumper extends Dumper
|
||||
}
|
||||
|
||||
foreach ($container->getServiceIds() as $id) {
|
||||
if (array_key_exists($id, $container->getAliases())) {
|
||||
if (\array_key_exists($id, $container->getAliases())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
|
||||
throw new RuntimeException(sprintf('Resolved value of "%s" did not result in an array value.', $next));
|
||||
}
|
||||
|
||||
if (!isset($array[$key]) && !array_key_exists($key, $array)) {
|
||||
if (!isset($array[$key]) && !\array_key_exists($key, $array)) {
|
||||
throw new EnvNotFoundException(sprintf('Key "%s" not found in "%s" (resolved from "%s").', $key, json_encode($array), $next));
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ abstract class Extension implements ExtensionInterface, ConfigurationExtensionIn
|
||||
*/
|
||||
protected function isConfigEnabled(ContainerBuilder $container, array $config)
|
||||
{
|
||||
if (!array_key_exists('enabled', $config)) {
|
||||
if (!\array_key_exists('enabled', $config)) {
|
||||
throw new InvalidArgumentException("The config array has no 'enabled' key.");
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use Symfony\Component\DependencyInjection\Definition;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Noop proxy instantiator - simply produces the real service instead of a proxy instance.
|
||||
* Noop proxy instantiator - produces the real service instead of a proxy instance.
|
||||
*
|
||||
* @author Marco Pivetta <ocramius@gmail.com>
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ class ParameterBag implements ParameterBagInterface
|
||||
{
|
||||
$name = (string) $name;
|
||||
|
||||
if (!array_key_exists($name, $this->parameters)) {
|
||||
if (!\array_key_exists($name, $this->parameters)) {
|
||||
if (!$name) {
|
||||
throw new ParameterNotFoundException($name);
|
||||
}
|
||||
@ -119,7 +119,7 @@ class ParameterBag implements ParameterBagInterface
|
||||
*/
|
||||
public function has($name)
|
||||
{
|
||||
return array_key_exists((string) $name, $this->parameters);
|
||||
return \array_key_exists((string) $name, $this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -985,7 +985,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
$expressions = [];
|
||||
|
||||
// An expression which will never match to replace expressions which cannot match in the crawler
|
||||
// We cannot simply drop
|
||||
// We cannot drop
|
||||
$nonMatchingExpression = 'a[name() = "b"]';
|
||||
|
||||
$xpathLen = \strlen($xpath);
|
||||
|
@ -60,7 +60,7 @@ class FileFormField extends FormField
|
||||
|
||||
// copy to a tmp location
|
||||
$tmp = sys_get_temp_dir().'/'.strtr(substr(base64_encode(hash('sha256', uniqid(mt_rand(), true), true)), 0, 7), '/', '_');
|
||||
if (array_key_exists('extension', $info)) {
|
||||
if (\array_key_exists('extension', $info)) {
|
||||
$tmp .= '.'.$info['extension'];
|
||||
}
|
||||
if (is_file($tmp)) {
|
||||
|
@ -57,7 +57,7 @@ class FormFieldRegistry
|
||||
$target = &$this->fields;
|
||||
while (\count($segments) > 1) {
|
||||
$path = array_shift($segments);
|
||||
if (!array_key_exists($path, $target)) {
|
||||
if (!\array_key_exists($path, $target)) {
|
||||
return;
|
||||
}
|
||||
$target = &$target[$path];
|
||||
@ -80,7 +80,7 @@ class FormFieldRegistry
|
||||
$target = &$this->fields;
|
||||
while ($segments) {
|
||||
$path = array_shift($segments);
|
||||
if (!array_key_exists($path, $target)) {
|
||||
if (!\array_key_exists($path, $target)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path));
|
||||
}
|
||||
$target = &$target[$path];
|
||||
|
@ -30,6 +30,7 @@ class WrappedListener
|
||||
private $dispatcher;
|
||||
private $pretty;
|
||||
private $stub;
|
||||
private $priority;
|
||||
private static $hasClassStub;
|
||||
|
||||
public function __construct(callable $listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
|
||||
@ -98,7 +99,7 @@ class WrappedListener
|
||||
|
||||
return [
|
||||
'event' => $eventName,
|
||||
'priority' => null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null,
|
||||
'priority' => null !== $this->priority ? $this->priority : (null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null),
|
||||
'pretty' => $this->pretty,
|
||||
'stub' => $this->stub,
|
||||
];
|
||||
@ -106,11 +107,14 @@ class WrappedListener
|
||||
|
||||
public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$dispatcher = $this->dispatcher ?: $dispatcher;
|
||||
|
||||
$this->called = true;
|
||||
$this->priority = $dispatcher->getListenerPriority($eventName, $this->listener);
|
||||
|
||||
$e = $this->stopwatch->start($this->name, 'event_listener');
|
||||
|
||||
($this->optimizedListener)($event, $eventName, $this->dispatcher ?: $dispatcher);
|
||||
($this->optimizedListener)($event, $eventName, $dispatcher);
|
||||
|
||||
if ($e->isStarted()) {
|
||||
$e->stop();
|
||||
|
@ -111,7 +111,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
*/
|
||||
public function hasArgument($key)
|
||||
{
|
||||
return array_key_exists($key, $this->arguments);
|
||||
return \array_key_exists($key, $this->arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ use Symfony\Component\Finder\Iterator\SortableIterator;
|
||||
*
|
||||
* All rules may be invoked several times.
|
||||
*
|
||||
* All methods return the current Finder object to allow easy chaining:
|
||||
* All methods return the current Finder object to allow chaining:
|
||||
*
|
||||
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
|
||||
*
|
||||
@ -674,12 +674,15 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
|
||||
private function searchInDirectory(string $dir): \Iterator
|
||||
{
|
||||
$exclude = $this->exclude;
|
||||
$notPaths = $this->notPaths;
|
||||
|
||||
if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
|
||||
$this->exclude = array_merge($this->exclude, self::$vcsPatterns);
|
||||
$exclude = array_merge($exclude, self::$vcsPatterns);
|
||||
}
|
||||
|
||||
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
|
||||
$this->notPaths[] = '#(^|/)\..+(/|$)#';
|
||||
$notPaths[] = '#(^|/)\..+(/|$)#';
|
||||
}
|
||||
|
||||
$minDepth = 0;
|
||||
@ -712,8 +715,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
|
||||
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
|
||||
|
||||
if ($this->exclude) {
|
||||
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
|
||||
if ($exclude) {
|
||||
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
||||
@ -746,8 +749,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
||||
}
|
||||
|
||||
if ($this->paths || $this->notPaths) {
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
|
||||
if ($this->paths || $notPaths) {
|
||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
|
||||
}
|
||||
|
||||
if ($this->sort || $this->reverseSorting) {
|
||||
|
@ -421,6 +421,18 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
]), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreVCSCanBeDisabledAfterFirstIteration()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->in(self::$tmpDir);
|
||||
$finder->ignoreDotFiles(false);
|
||||
|
||||
$this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar']), $finder->getIterator());
|
||||
|
||||
$finder->ignoreVCS(false);
|
||||
$this->assertIterator($this->toAbsolute(['.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar']), $finder->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreDotFiles()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
@ -496,6 +508,17 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
]), $finder->in(self::$tmpDir)->getIterator());
|
||||
}
|
||||
|
||||
public function testIgnoreDotFilesCanBeDisabledAfterFirstIteration()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
$finder->in(self::$tmpDir);
|
||||
|
||||
$this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar']), $finder->getIterator());
|
||||
|
||||
$finder->ignoreDotFiles(false);
|
||||
$this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar']), $finder->getIterator());
|
||||
}
|
||||
|
||||
public function testSortByName()
|
||||
{
|
||||
$finder = $this->buildFinder();
|
||||
|
@ -670,7 +670,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||
*/
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
return array_key_exists($name, $this->attributes);
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -683,7 +683,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||
*/
|
||||
public function getAttribute($name, $default = null)
|
||||
{
|
||||
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -777,7 +777,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||
*/
|
||||
public function hasOption($name)
|
||||
{
|
||||
return array_key_exists($name, $this->options);
|
||||
return \array_key_exists($name, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -790,7 +790,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
|
||||
*/
|
||||
public function getOption($name, $default = null)
|
||||
{
|
||||
return array_key_exists($name, $this->options) ? $this->options[$name] : $default;
|
||||
return \array_key_exists($name, $this->options) ? $this->options[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ class ArrayChoiceList implements ChoiceListInterface
|
||||
// If a deterministic value generator was passed, use it later
|
||||
$this->valueCallback = $value;
|
||||
} else {
|
||||
// Otherwise simply generate incrementing integers as values
|
||||
// Otherwise generate incrementing integers as values
|
||||
$i = 0;
|
||||
$value = function () use (&$i) {
|
||||
return $i++;
|
||||
@ -135,7 +135,7 @@ class ArrayChoiceList implements ChoiceListInterface
|
||||
$choices = [];
|
||||
|
||||
foreach ($values as $i => $givenValue) {
|
||||
if (array_key_exists($givenValue, $this->choices)) {
|
||||
if (\array_key_exists($givenValue, $this->choices)) {
|
||||
$choices[$i] = $this->choices[$givenValue];
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class LazyChoiceList implements ChoiceListInterface
|
||||
/**
|
||||
* The callable creating string values for each choice.
|
||||
*
|
||||
* If null, choices are simply cast to strings.
|
||||
* If null, choices are cast to strings.
|
||||
*
|
||||
* @var callable|null
|
||||
*/
|
||||
|
@ -79,7 +79,7 @@ class JsonDescriptor extends Descriptor
|
||||
'allowed_values' => 'allowedValues',
|
||||
];
|
||||
foreach ($map as $label => $name) {
|
||||
if (array_key_exists($name, $definition)) {
|
||||
if (\array_key_exists($name, $definition)) {
|
||||
$data[$label] = $definition[$name];
|
||||
|
||||
if ('default' === $name) {
|
||||
|
@ -114,7 +114,7 @@ class TextDescriptor extends Descriptor
|
||||
];
|
||||
$rows = [];
|
||||
foreach ($map as $label => $name) {
|
||||
$value = array_key_exists($name, $definition) ? $dump($definition[$name]) : '-';
|
||||
$value = \array_key_exists($name, $definition) ? $dump($definition[$name]) : '-';
|
||||
if ('default' === $name && isset($definition['lazy'])) {
|
||||
$value = "Value: $value\n\nClosure(s): ".$dump($definition['lazy']);
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Form\Extension\Core\DataTransformer;
|
||||
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
/**
|
||||
* Transforms between an integer and a localized number with grouping
|
||||
* (each thousand) and comma separators.
|
||||
@ -42,6 +44,12 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo
|
||||
*/
|
||||
public function reverseTransform($value)
|
||||
{
|
||||
$decimalSeparator = $this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
|
||||
|
||||
if (\is_string($value) && false !== strpos($value, $decimalSeparator)) {
|
||||
throw new TransformationFailedException(sprintf('The value "%s" is not a valid integer.', $value));
|
||||
}
|
||||
|
||||
$result = parent::reverseTransform($value);
|
||||
|
||||
return null !== $result ? (int) $result : null;
|
||||
|
@ -38,7 +38,7 @@ class FormType extends BaseType
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$isDataOptionSet = array_key_exists('data', $options);
|
||||
$isDataOptionSet = \array_key_exists('data', $options);
|
||||
|
||||
$builder
|
||||
->setRequired($options['required'])
|
||||
|
@ -41,7 +41,7 @@ class FormValidator extends ConstraintValidator
|
||||
|
||||
$validator = $this->context->getValidator()->inContext($this->context);
|
||||
|
||||
if ($form->isSynchronized()) {
|
||||
if ($form->isSubmitted() && $form->isSynchronized()) {
|
||||
// Validate the form data only if transformation succeeded
|
||||
$groups = self::getValidationGroups($form);
|
||||
$data = $form->getData();
|
||||
@ -90,7 +90,7 @@ class FormValidator extends ConstraintValidator
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} elseif (!$form->isSynchronized()) {
|
||||
$childrenSynchronized = true;
|
||||
|
||||
/** @var FormInterface $child */
|
||||
|
@ -273,9 +273,6 @@ class ViolationMapper implements ViolationMapperInterface
|
||||
*/
|
||||
private function acceptsErrors(FormInterface $form)
|
||||
{
|
||||
// Ignore non-submitted forms. This happens, for example, in PATCH
|
||||
// requests.
|
||||
// https://github.com/symfony/symfony/pull/10567
|
||||
return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized());
|
||||
return $this->allowNonSynchronized || $form->isSynchronized();
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
*
|
||||
* In most cases, format (1) and format (2) will be the same. For example,
|
||||
* a checkbox field uses a Boolean value for both internal processing and
|
||||
* storage in the object. In these cases you simply need to set a view
|
||||
* transformer to convert between formats (2) and (3). You can do this by
|
||||
* calling addViewTransformer().
|
||||
* storage in the object. In these cases you need to set a view transformer
|
||||
* to convert between formats (2) and (3). You can do this by calling
|
||||
* addViewTransformer().
|
||||
*
|
||||
* In some cases though it makes sense to make format (1) configurable. To
|
||||
* demonstrate this, let's extend our above date field to store the value
|
||||
@ -574,7 +574,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
||||
}
|
||||
|
||||
foreach ($this->children as $name => $child) {
|
||||
$isSubmitted = array_key_exists($name, $submittedData);
|
||||
$isSubmitted = \array_key_exists($name, $submittedData);
|
||||
|
||||
if ($isSubmitted || $clearMissing) {
|
||||
$child->submit($isSubmitted ? $submittedData[$name] : null, $clearMissing);
|
||||
|
@ -418,7 +418,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*/
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
return array_key_exists($name, $this->attributes);
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,7 +426,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*/
|
||||
public function getAttribute($name, $default = null)
|
||||
{
|
||||
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -513,7 +513,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*/
|
||||
public function hasOption($name)
|
||||
{
|
||||
return array_key_exists($name, $this->options);
|
||||
return \array_key_exists($name, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -521,7 +521,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
|
||||
*/
|
||||
public function getOption($name, $default = null)
|
||||
{
|
||||
return array_key_exists($name, $this->options) ? $this->options[$name] : $default;
|
||||
return \array_key_exists($name, $this->options) ? $this->options[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ class FormFactory implements FormFactoryInterface
|
||||
*/
|
||||
public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = [])
|
||||
{
|
||||
if (null !== $data && !array_key_exists('data', $options)) {
|
||||
if (null !== $data && !\array_key_exists('data', $options)) {
|
||||
$options['data'] = $data;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ class FormRenderer implements FormRendererInterface
|
||||
// "form_widget" in this example (again, no matter in which theme).
|
||||
// If the designer wants to explicitly fallback to "form_widget" in their
|
||||
// custom "choice_widget", for example because they only want to wrap
|
||||
// a <div> around the original implementation, they can simply call the
|
||||
// a <div> around the original implementation, they can call the
|
||||
// widget() function again to render the block for the parent type.
|
||||
//
|
||||
// The second kind is implemented in the following blocks.
|
||||
|
@ -94,10 +94,10 @@ class NativeRequestHandler implements RequestHandlerInterface
|
||||
if ('' === $name) {
|
||||
$params = $_POST;
|
||||
$files = $fixedFiles;
|
||||
} elseif (array_key_exists($name, $_POST) || array_key_exists($name, $fixedFiles)) {
|
||||
} elseif (\array_key_exists($name, $_POST) || \array_key_exists($name, $fixedFiles)) {
|
||||
$default = $form->getConfig()->getCompound() ? [] : null;
|
||||
$params = array_key_exists($name, $_POST) ? $_POST[$name] : $default;
|
||||
$files = array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
|
||||
$params = \array_key_exists($name, $_POST) ? $_POST[$name] : $default;
|
||||
$files = \array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
|
||||
} else {
|
||||
// Don't submit the form if it is not present in the request
|
||||
return;
|
||||
@ -115,7 +115,7 @@ class NativeRequestHandler implements RequestHandlerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_array($data) && array_key_exists('_method', $data) && $method === $data['_method'] && !$form->has('_method')) {
|
||||
if (\is_array($data) && \array_key_exists('_method', $data) && $method === $data['_method'] && !$form->has('_method')) {
|
||||
unset($data['_method']);
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,7 @@ class IntegerToLocalizedStringTransformerTest extends TestCase
|
||||
$transformer = new IntegerToLocalizedStringTransformer();
|
||||
|
||||
$this->assertEquals(1, $transformer->reverseTransform('1'));
|
||||
$this->assertEquals(1, $transformer->reverseTransform('1,5'));
|
||||
$this->assertEquals(1234, $transformer->reverseTransform('1234,5'));
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12345,912'));
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12345'));
|
||||
}
|
||||
|
||||
public function testReverseTransformEmpty()
|
||||
@ -147,10 +145,10 @@ class IntegerToLocalizedStringTransformerTest extends TestCase
|
||||
|
||||
$transformer = new IntegerToLocalizedStringTransformer(null, true);
|
||||
|
||||
$this->assertEquals(1234, $transformer->reverseTransform('1.234,5'));
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12.345,912'));
|
||||
$this->assertEquals(1234, $transformer->reverseTransform('1234,5'));
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12345,912'));
|
||||
$this->assertEquals(1234, $transformer->reverseTransform('1.234'));
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12.345'));
|
||||
$this->assertEquals(1234, $transformer->reverseTransform('1234'));
|
||||
$this->assertEquals(12345, $transformer->reverseTransform('12345'));
|
||||
}
|
||||
|
||||
public function reverseTransformWithRoundingProvider()
|
||||
@ -246,6 +244,29 @@ class IntegerToLocalizedStringTransformerTest extends TestCase
|
||||
$transformer->reverseTransform('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider floatNumberProvider
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformExpectsInteger($number, $locale)
|
||||
{
|
||||
IntlTestHelper::requireFullIntl($this, false);
|
||||
|
||||
\Locale::setDefault($locale);
|
||||
|
||||
$transformer = new IntegerToLocalizedStringTransformer();
|
||||
|
||||
$transformer->reverseTransform($number);
|
||||
}
|
||||
|
||||
public function floatNumberProvider()
|
||||
{
|
||||
return [
|
||||
['12345.912', 'en'],
|
||||
['1.234,5', 'de_DE'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
|
@ -24,14 +24,15 @@ class IntegerTypeTest extends BaseTypeTest
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testSubmitCastsToInteger()
|
||||
public function testSubmitRejectsFloats()
|
||||
{
|
||||
$form = $this->factory->create(static::TESTED_TYPE);
|
||||
|
||||
$form->submit('1.678');
|
||||
|
||||
$this->assertSame(1, $form->getData());
|
||||
$this->assertSame('1', $form->getViewData());
|
||||
$this->assertTrue($form->isSubmitted());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertFalse($form->isSynchronized());
|
||||
}
|
||||
|
||||
public function testSubmitNull($expected = null, $norm = null, $view = null)
|
||||
|
@ -61,9 +61,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$options = ['validation_groups' => ['group1', 'group2']];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
|
||||
@ -82,9 +81,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
'validation_groups' => ['group1', 'group2'],
|
||||
'constraints' => [$constraint1, $constraint2],
|
||||
];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$form->submit([]);
|
||||
|
||||
// First default constraints
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
@ -110,10 +108,9 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
'validation_groups' => ['group1', 'group2'],
|
||||
'constraints' => [new Valid()],
|
||||
];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$parent->add($form);
|
||||
|
||||
$form->setData($object);
|
||||
$parent->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
|
||||
@ -146,8 +143,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
public function testMissingConstraintIndex()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory);
|
||||
$form = $form->setData($object)->getForm();
|
||||
$form = $this->getCompoundForm($object);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['Default']);
|
||||
|
||||
@ -170,10 +167,9 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
'validation_groups' => ['group1', 'group2'],
|
||||
'constraints' => [$constraint1, $constraint2],
|
||||
];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$parent->add($form);
|
||||
$parent->submit([]);
|
||||
|
||||
$this->expectValidateValueAt(0, 'data', $object, $constraint1, 'group1');
|
||||
$this->expectValidateValueAt(1, 'data', $object, $constraint2, 'group2');
|
||||
@ -361,9 +357,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$options = ['validation_groups' => new GroupSequence(['group1', 'group2'])];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, new GroupSequence(['group1', 'group2']));
|
||||
$this->expectValidateAt(1, 'data', $object, new GroupSequence(['group1', 'group2']));
|
||||
@ -377,9 +372,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$options = ['validation_groups' => [$this, 'getValidationGroups']];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
|
||||
@ -392,9 +386,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$options = ['validation_groups' => 'header'];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['header']);
|
||||
|
||||
@ -409,9 +402,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
$options = ['validation_groups' => function (FormInterface $form) {
|
||||
return ['group1', 'group2'];
|
||||
}];
|
||||
$form = $this->getBuilder('name', '\stdClass', $options)
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object, $options);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
|
||||
@ -455,7 +447,7 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
->setCompound(true)
|
||||
->setDataMapper(new PropertyPathMapper())
|
||||
->getForm();
|
||||
$form = $this->getForm('name', '\stdClass', [
|
||||
$form = $this->getCompoundForm($object, [
|
||||
'validation_groups' => 'form_group',
|
||||
'constraints' => [new Valid()],
|
||||
]);
|
||||
@ -465,7 +457,7 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
'validation_groups' => 'button_group',
|
||||
]));
|
||||
|
||||
$form->setData($object);
|
||||
$parent->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['form_group']);
|
||||
|
||||
@ -484,10 +476,9 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
->setDataMapper(new PropertyPathMapper())
|
||||
->getForm();
|
||||
$formOptions = ['constraints' => [new Valid()]];
|
||||
$form = $this->getBuilder('name', '\stdClass', $formOptions)->getForm();
|
||||
$form = $this->getCompoundForm($object, $formOptions);
|
||||
$parent->add($form);
|
||||
|
||||
$form->setData($object);
|
||||
$parent->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group']);
|
||||
|
||||
@ -506,10 +497,9 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
->setDataMapper(new PropertyPathMapper())
|
||||
->getForm();
|
||||
$formOptions = ['constraints' => [new Valid()]];
|
||||
$form = $this->getBuilder('name', '\stdClass', $formOptions)->getForm();
|
||||
$form = $this->getCompoundForm($object, $formOptions);
|
||||
$parent->add($form);
|
||||
|
||||
$form->setData($object);
|
||||
$parent->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
|
||||
@ -523,7 +513,7 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
$object = new \stdClass();
|
||||
|
||||
$parentOptions = [
|
||||
'validation_groups' => function (FormInterface $form) {
|
||||
'validation_groups' => function () {
|
||||
return ['group1', 'group2'];
|
||||
},
|
||||
];
|
||||
@ -532,10 +522,9 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
->setDataMapper(new PropertyPathMapper())
|
||||
->getForm();
|
||||
$formOptions = ['constraints' => [new Valid()]];
|
||||
$form = $this->getBuilder('name', '\stdClass', $formOptions)->getForm();
|
||||
$form = $this->getCompoundForm($object, $formOptions);
|
||||
$parent->add($form);
|
||||
|
||||
$form->setData($object);
|
||||
$parent->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['group1', 'group2']);
|
||||
|
||||
@ -547,9 +536,8 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
public function testAppendPropertyPath()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$form = $this->getBuilder('name', '\stdClass')
|
||||
->setData($object)
|
||||
->getForm();
|
||||
$form = $this->getCompoundForm($object);
|
||||
$form->submit([]);
|
||||
|
||||
$this->expectValidateAt(0, 'data', $object, ['Default']);
|
||||
|
||||
@ -683,6 +671,15 @@ class FormValidatorTest extends ConstraintValidatorTestCase
|
||||
return $this->getBuilder($name, $dataClass, $options)->getForm();
|
||||
}
|
||||
|
||||
private function getCompoundForm($data, array $options = [])
|
||||
{
|
||||
return $this->getBuilder('name', \get_class($data), $options)
|
||||
->setData($data)
|
||||
->setCompound(true)
|
||||
->setDataMapper(new PropertyPathMapper())
|
||||
->getForm();
|
||||
}
|
||||
|
||||
private function getSubmitButton($name = 'name', array $options = [])
|
||||
{
|
||||
$builder = new SubmitButtonBuilder($name, $options);
|
||||
|
@ -12,12 +12,19 @@
|
||||
namespace Symfony\Component\Form\Tests\Extension\Validator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Validator\Constraints\Form as FormConstraint;
|
||||
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
|
||||
use Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormFactoryBuilder;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Mapping\CascadingStrategy;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
|
||||
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
|
||||
use Symfony\Component\Validator\Mapping\TraversalStrategy;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
@ -45,4 +52,78 @@ class ValidatorExtensionTest extends TestCase
|
||||
$this->assertSame(CascadingStrategy::CASCADE, $metadata->getPropertyMetadata('children')[0]->cascadingStrategy);
|
||||
$this->assertSame(TraversalStrategy::IMPLICIT, $metadata->getPropertyMetadata('children')[0]->traversalStrategy);
|
||||
}
|
||||
|
||||
public function testDataConstraintsInvalidateFormEvenIfFieldIsNotSubmitted()
|
||||
{
|
||||
$form = $this->createForm(FooType::class);
|
||||
$form->submit(['baz' => 'foobar'], false);
|
||||
|
||||
$this->assertTrue($form->isSubmitted());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertFalse($form->get('bar')->isSubmitted());
|
||||
$this->assertCount(1, $form->get('bar')->getErrors());
|
||||
}
|
||||
|
||||
public function testFieldConstraintsDoNotInvalidateFormIfFieldIsNotSubmitted()
|
||||
{
|
||||
$form = $this->createForm(FooType::class);
|
||||
$form->submit(['bar' => 'foobar'], false);
|
||||
|
||||
$this->assertTrue($form->isSubmitted());
|
||||
$this->assertTrue($form->isValid());
|
||||
}
|
||||
|
||||
public function testFieldConstraintsInvalidateFormIfFieldIsSubmitted()
|
||||
{
|
||||
$form = $this->createForm(FooType::class);
|
||||
$form->submit(['bar' => 'foobar', 'baz' => ''], false);
|
||||
|
||||
$this->assertTrue($form->isSubmitted());
|
||||
$this->assertFalse($form->isValid());
|
||||
$this->assertTrue($form->get('bar')->isSubmitted());
|
||||
$this->assertTrue($form->get('bar')->isValid());
|
||||
$this->assertTrue($form->get('baz')->isSubmitted());
|
||||
$this->assertFalse($form->get('baz')->isValid());
|
||||
}
|
||||
|
||||
private function createForm($type)
|
||||
{
|
||||
$validator = Validation::createValidatorBuilder()
|
||||
->setMetadataFactory(new LazyLoadingMetadataFactory(new StaticMethodLoader()))
|
||||
->getValidator();
|
||||
$formFactoryBuilder = new FormFactoryBuilder();
|
||||
$formFactoryBuilder->addExtension(new ValidatorExtension($validator));
|
||||
$formFactory = $formFactoryBuilder->getFormFactory();
|
||||
|
||||
return $formFactory->create($type);
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
public $bar;
|
||||
public $baz;
|
||||
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata)
|
||||
{
|
||||
$metadata->addPropertyConstraint('bar', new NotBlank());
|
||||
}
|
||||
}
|
||||
|
||||
class FooType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('bar')
|
||||
->add('baz', null, [
|
||||
'constraints' => [new NotBlank()],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefault('data_class', Foo::class);
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ class ViolationMapperTest extends TestCase
|
||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||
}
|
||||
|
||||
public function testAbortMappingIfNotSubmitted()
|
||||
public function testMappingIfNotSubmitted()
|
||||
{
|
||||
$violation = $this->getConstraintViolation('children[address].data.street');
|
||||
$parent = $this->getForm('parent');
|
||||
@ -225,10 +225,10 @@ class ViolationMapperTest extends TestCase
|
||||
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error');
|
||||
}
|
||||
|
||||
public function testAbortDotRuleMappingIfNotSubmitted()
|
||||
public function testDotRuleMappingIfNotSubmitted()
|
||||
{
|
||||
$violation = $this->getConstraintViolation('data.address');
|
||||
$parent = $this->getForm('parent');
|
||||
@ -250,7 +250,7 @@ class ViolationMapperTest extends TestCase
|
||||
|
||||
$this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
|
||||
$this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
|
||||
$this->assertCount(1, $grandChild->getErrors(), $grandChild->getName().' should have one error');
|
||||
}
|
||||
|
||||
public function provideDefaultTests()
|
||||
|
@ -26,7 +26,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
|
||||
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->array);
|
||||
return \array_key_exists($offset, $this->array);
|
||||
}
|
||||
|
||||
public function offsetGet($offset)
|
||||
|
@ -25,7 +25,7 @@ class FixedDataTransformer implements DataTransformerInterface
|
||||
|
||||
public function transform($value)
|
||||
{
|
||||
if (!array_key_exists($value, $this->mapping)) {
|
||||
if (!\array_key_exists($value, $this->mapping)) {
|
||||
throw new TransformationFailedException(sprintf('No mapping for value "%s"', $value));
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
$key = str_replace('_', '-', strtolower($key));
|
||||
$headers = $this->all();
|
||||
|
||||
if (!array_key_exists($key, $headers)) {
|
||||
if (!\array_key_exists($key, $headers)) {
|
||||
if (null === $default) {
|
||||
return $first ? null : [];
|
||||
}
|
||||
@ -168,7 +168,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return array_key_exists(str_replace('_', '-', strtolower($key)), $this->all());
|
||||
return \array_key_exists(str_replace('_', '-', strtolower($key)), $this->all());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,7 +245,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function hasCacheControlDirective($key)
|
||||
{
|
||||
return array_key_exists($key, $this->cacheControl);
|
||||
return \array_key_exists($key, $this->cacheControl);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,7 +257,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function getCacheControlDirective($key)
|
||||
{
|
||||
return array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
|
||||
return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
|
||||
return \array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +104,7 @@ class ParameterBag implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return array_key_exists($key, $this->parameters);
|
||||
return \array_key_exists($key, $this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ class RedirectResponse extends Response
|
||||
throw new \InvalidArgumentException(sprintf('The HTTP status code is not a redirect ("%s" given).', $status));
|
||||
}
|
||||
|
||||
if (301 == $status && !array_key_exists('cache-control', $headers)) {
|
||||
if (301 == $status && !\array_key_exists('cache-control', $headers)) {
|
||||
$this->headers->remove('cache-control');
|
||||
}
|
||||
}
|
||||
|
@ -617,6 +617,81 @@ class Request
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
* Sets the name for trusted headers.
|
||||
*
|
||||
* The following header keys are supported:
|
||||
*
|
||||
* * Request::HEADER_CLIENT_IP: defaults to X-Forwarded-For (see getClientIp())
|
||||
* * Request::HEADER_CLIENT_HOST: defaults to X-Forwarded-Host (see getHost())
|
||||
* * Request::HEADER_CLIENT_PORT: defaults to X-Forwarded-Port (see getPort())
|
||||
* * Request::HEADER_CLIENT_PROTO: defaults to X-Forwarded-Proto (see getScheme() and isSecure())
|
||||
* * Request::HEADER_FORWARDED: defaults to Forwarded (see RFC 7239)
|
||||
*
|
||||
* Setting an empty value allows to disable the trusted header for the given key.
|
||||
*
|
||||
* @param string $key The header key
|
||||
* @param string $value The header name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.
|
||||
*/
|
||||
public static function setTrustedHeaderName($key, $value)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the $trustedHeaderSet argument of the Request::setTrustedProxies() method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
if ('forwarded' === $key) {
|
||||
$key = self::HEADER_FORWARDED;
|
||||
} elseif ('client_ip' === $key) {
|
||||
$key = self::HEADER_CLIENT_IP;
|
||||
} elseif ('client_host' === $key) {
|
||||
$key = self::HEADER_CLIENT_HOST;
|
||||
} elseif ('client_proto' === $key) {
|
||||
$key = self::HEADER_CLIENT_PROTO;
|
||||
} elseif ('client_port' === $key) {
|
||||
$key = self::HEADER_CLIENT_PORT;
|
||||
} elseif (!\array_key_exists($key, self::$trustedHeaders)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to set the trusted header name for key "%s".', $key));
|
||||
}
|
||||
|
||||
self::$trustedHeaders[$key] = $value;
|
||||
|
||||
if (null !== $value) {
|
||||
self::$trustedHeaderNames[$key] = $value;
|
||||
self::$trustedHeaderSet |= $key;
|
||||
} else {
|
||||
self::$trustedHeaderSet &= ~$key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the trusted proxy header name.
|
||||
*
|
||||
* @param string $key The header key
|
||||
*
|
||||
* @return string The header name
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.
|
||||
*/
|
||||
public static function getTrustedHeaderName($key)
|
||||
{
|
||||
if (2 > \func_num_args() || func_get_arg(1)) {
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Request::getTrustedHeaderSet() method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (!\array_key_exists($key, self::$trustedHeaders)) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to get the trusted header name for key "%s".', $key));
|
||||
}
|
||||
|
||||
return self::$trustedHeaders[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
>>>>>>> 3.4
|
||||
* Normalizes a query string.
|
||||
*
|
||||
* It builds a normalized query string, where keys/value pairs are alphabetized,
|
||||
|
@ -160,7 +160,7 @@ class ResponseHeaderBag extends HeaderBag
|
||||
*/
|
||||
public function hasCacheControlDirective($key)
|
||||
{
|
||||
return array_key_exists($key, $this->computedCacheControl);
|
||||
return \array_key_exists($key, $this->computedCacheControl);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +168,7 @@ class ResponseHeaderBag extends HeaderBag
|
||||
*/
|
||||
public function getCacheControlDirective($key)
|
||||
{
|
||||
return array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null;
|
||||
return \array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null;
|
||||
}
|
||||
|
||||
public function setCookie(Cookie $cookie)
|
||||
|
@ -63,7 +63,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
*/
|
||||
public function has($name)
|
||||
{
|
||||
return array_key_exists($name, $this->attributes);
|
||||
return \array_key_exists($name, $this->attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +71,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
*/
|
||||
public function get($name, $default = null)
|
||||
{
|
||||
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ class AttributeBag implements AttributeBagInterface, \IteratorAggregate, \Counta
|
||||
public function remove($name)
|
||||
{
|
||||
$retval = null;
|
||||
if (array_key_exists($name, $this->attributes)) {
|
||||
if (\array_key_exists($name, $this->attributes)) {
|
||||
$retval = $this->attributes[$name];
|
||||
unset($this->attributes[$name]);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_key_exists($name, $attributes);
|
||||
return \array_key_exists($name, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +60,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
return $default;
|
||||
}
|
||||
|
||||
return array_key_exists($name, $attributes) ? $attributes[$name] : $default;
|
||||
return \array_key_exists($name, $attributes) ? $attributes[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +81,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
$retval = null;
|
||||
$attributes = &$this->resolveAttributePath($name);
|
||||
$name = $this->resolveKey($name);
|
||||
if (null !== $attributes && array_key_exists($name, $attributes)) {
|
||||
if (null !== $attributes && \array_key_exists($name, $attributes)) {
|
||||
$retval = $attributes[$name];
|
||||
unset($attributes[$name]);
|
||||
}
|
||||
@ -123,7 +123,7 @@ class NamespacedAttributeBag extends AttributeBag
|
||||
unset($parts[\count($parts) - 1]);
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (null !== $array && !array_key_exists($part, $array)) {
|
||||
if (null !== $array && !\array_key_exists($part, $array)) {
|
||||
if (!$writeContext) {
|
||||
$null = null;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
// The logic: messages from the last request will be stored in new, so we move them to previous
|
||||
// This request we will show what is in 'display'. What is placed into 'new' this time round will
|
||||
// be moved to display next time round.
|
||||
$this->flashes['display'] = array_key_exists('new', $this->flashes) ? $this->flashes['new'] : [];
|
||||
$this->flashes['display'] = \array_key_exists('new', $this->flashes) ? $this->flashes['new'] : [];
|
||||
$this->flashes['new'] = [];
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function peekAll()
|
||||
{
|
||||
return array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : [];
|
||||
return \array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,7 +132,7 @@ class AutoExpireFlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function has($type)
|
||||
{
|
||||
return array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
|
||||
return \array_key_exists($type, $this->flashes['display']) && $this->flashes['display'][$type];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ class FlashBag implements FlashBagInterface
|
||||
*/
|
||||
public function has($type)
|
||||
{
|
||||
return array_key_exists($type, $this->flashes) && $this->flashes[$type];
|
||||
return \array_key_exists($type, $this->flashes) && $this->flashes[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,13 +79,12 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), $e->getFile(), $e->getLine()));
|
||||
|
||||
$wrapper = $e;
|
||||
|
||||
while ($prev = $wrapper->getPrevious()) {
|
||||
$prev = $e;
|
||||
do {
|
||||
if ($exception === $wrapper = $prev) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
} while ($prev = $wrapper->getPrevious());
|
||||
|
||||
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
|
||||
$prev->setAccessible(true);
|
||||
|
@ -80,7 +80,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
||||
return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false);
|
||||
} catch (\Exception $e) {
|
||||
// we dispatch the exception event to trigger the logging
|
||||
// the response that comes back is simply ignored
|
||||
// the response that comes back is ignored
|
||||
if (isset($options['ignore_errors']) && $options['ignore_errors'] && $this->dispatcher) {
|
||||
$event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::SUB_REQUEST, $e);
|
||||
|
||||
|
@ -351,15 +351,15 @@ class RequestDataCollectorTest extends TestCase
|
||||
|
||||
public function provideJsonContentTypes()
|
||||
{
|
||||
return array(
|
||||
array('text/csv', false),
|
||||
array('application/json', true),
|
||||
array('application/JSON', true),
|
||||
array('application/hal+json', true),
|
||||
array('application/xml+json', true),
|
||||
array('application/xml', false),
|
||||
array('', false),
|
||||
);
|
||||
return [
|
||||
['text/csv', false],
|
||||
['application/json', true],
|
||||
['application/JSON', true],
|
||||
['application/hal+json', true],
|
||||
['application/xml+json', true],
|
||||
['application/xml', false],
|
||||
['', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -368,7 +368,7 @@ class RequestDataCollectorTest extends TestCase
|
||||
public function testGetPrettyJsonValidity($content, $expected)
|
||||
{
|
||||
$response = $this->createResponse();
|
||||
$request = Request::create('/', 'POST', array(), array(), array(), array(), $content);
|
||||
$request = Request::create('/', 'POST', [], [], [], [], $content);
|
||||
|
||||
$c = new RequestDataCollector();
|
||||
$c->collect($request, $response);
|
||||
@ -378,13 +378,13 @@ class RequestDataCollectorTest extends TestCase
|
||||
|
||||
public function providePrettyJson()
|
||||
{
|
||||
return array(
|
||||
array('null', 'null'),
|
||||
array('{ "foo": "bar" }', '{
|
||||
return [
|
||||
['null', 'null'],
|
||||
['{ "foo": "bar" }', '{
|
||||
"foo": "bar"
|
||||
}'),
|
||||
array('{ "abc" }', null),
|
||||
array('', null),
|
||||
);
|
||||
}'],
|
||||
['{ "abc" }', null],
|
||||
['', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class LocaleDataGenerator
|
||||
// the name sorting
|
||||
// $name = $this->langBundle->getLanguageName($displayLocale, $lang, $region);
|
||||
|
||||
// Some languages are simply not translated
|
||||
// Some languages are not translated
|
||||
// Example: "az" (Azerbaijani) has no translation in "af" (Afrikaans)
|
||||
if (null === ($name = $this->languageDataProvider->getName($lang, $displayLocale))) {
|
||||
return;
|
||||
|
@ -25,7 +25,7 @@ class RecursiveArrayAccess
|
||||
foreach ($indices as $index) {
|
||||
// Use array_key_exists() for arrays, isset() otherwise
|
||||
if (\is_array($array)) {
|
||||
if (array_key_exists($index, $array)) {
|
||||
if (\array_key_exists($index, $array)) {
|
||||
$array = $array[$index];
|
||||
continue;
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ class NumberFormatter
|
||||
*/
|
||||
public function getSymbol($attr)
|
||||
{
|
||||
return array_key_exists($this->style, self::$enSymbols) && array_key_exists($attr, self::$enSymbols[$this->style]) ? self::$enSymbols[$this->style][$attr] : false;
|
||||
return \array_key_exists($this->style, self::$enSymbols) && \array_key_exists($attr, self::$enSymbols[$this->style]) ? self::$enSymbols[$this->style][$attr] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -474,7 +474,7 @@ class NumberFormatter
|
||||
*/
|
||||
public function getTextAttribute($attr)
|
||||
{
|
||||
return array_key_exists($this->style, self::$enTextAttributes) && array_key_exists($attr, self::$enTextAttributes[$this->style]) ? self::$enTextAttributes[$this->style][$attr] : false;
|
||||
return \array_key_exists($this->style, self::$enTextAttributes) && \array_key_exists($attr, self::$enTextAttributes[$this->style]) ? self::$enTextAttributes[$this->style][$attr] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ class Connection
|
||||
private static function normalizeQueueArguments(array $arguments): array
|
||||
{
|
||||
foreach (self::ARGUMENTS_AS_INTEGER as $key) {
|
||||
if (!array_key_exists($key, $arguments)) {
|
||||
if (!\array_key_exists($key, $arguments)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -256,6 +256,6 @@ class Connection
|
||||
|
||||
private function shouldSetup(): bool
|
||||
{
|
||||
return !array_key_exists('auto-setup', $this->connectionCredentials) || !\in_array($this->connectionCredentials['auto-setup'], [false, 'false'], true);
|
||||
return !\array_key_exists('auto-setup', $this->connectionCredentials) || !\in_array($this->connectionCredentials['auto-setup'], [false, 'false'], true);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class OptionsResolverIntrospector
|
||||
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option));
|
||||
}
|
||||
|
||||
if (!array_key_exists($option, $this->{$property})) {
|
||||
if (!\array_key_exists($option, $this->{$property})) {
|
||||
throw new NoConfigurationException($message);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user