Skip to content

Commit

Permalink
Merge branch '3.4' into 4.2
Browse files Browse the repository at this point in the history
* 3.4: (24 commits)
  Apply php-cs-fixer rule for array_key_exists()
  [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
  [Validator] Add the missing translations for the Greek (el) locale
  ...
  • Loading branch information
nicolas-grekas committed Feb 23, 2019
2 parents 8ac69b9 + b0a3208 commit 87f3c36
Show file tree
Hide file tree
Showing 145 changed files with 887 additions and 287 deletions.
2 changes: 1 addition & 1 deletion UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function getMetadata($class)
// 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];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return new class
{
return new class() {
public $proxyClass;
private $privates = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function set($key, $value)
*/
public function has($key)
{
if (array_key_exists($key, $this->data)) {
if (\array_key_exists($key, $this->data)) {
return true;
}

Expand All @@ -98,7 +98,7 @@ public function has($key)
*/
public function get($key, $default = null)
{
if (array_key_exists($key, $this->data)) {
if (\array_key_exists($key, $this->data)) {
return $this->data[$key];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private function getConfigForPath(array $config, string $path, string $alias)
$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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, $serviceI
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con
*/
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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ protected function describeContainerParameter($parameter, array $options = [])
*/
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ protected function describeContainerParameter($parameter, array $options = [])
*/
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con
*/
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));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
}

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;
Expand Down Expand Up @@ -365,7 +365,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
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 {
Expand Down Expand Up @@ -1117,15 +1117,15 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
$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.');
}

$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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
// 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected static function createKernel(array $options = [])
$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
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function prepend(ContainerBuilder $container)
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) {
Expand Down Expand Up @@ -412,7 +412,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected static function createKernel(array $options = [])
$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
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/WebServerBundle/Resources/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/BrowserKit/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public function back()
{
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);
}
Expand All @@ -562,7 +562,7 @@ public function forward()
{
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function setUp()
{
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.';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function setUp()
{
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.';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/MemcachedTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static function createConnection($servers, array $options = [])
$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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/RedisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ protected function doFetch(array $ids)

$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];
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Config/Definition/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function preNormalize($value)
$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;
Expand Down Expand Up @@ -223,7 +223,7 @@ protected function finalizeValue($value)
}

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());
Expand Down Expand Up @@ -383,7 +383,7 @@ protected function mergeValues($leftSide, $rightSide)

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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ public function performNoDeepMerging()
* 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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected function normalizeValue($value)
// 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;
Expand All @@ -258,7 +258,7 @@ protected function normalizeValue($value)
}
}

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());

Expand Down Expand Up @@ -301,14 +301,14 @@ protected function mergeValues($leftSide, $rightSide)
}

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());
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ public function doRun(InputInterface $input, OutputInterface $output)
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) {
Expand Down

0 comments on commit 87f3c36

Please sign in to comment.