Skip to content

Commit

Permalink
Merge branch '2.8' into 3.4
Browse files Browse the repository at this point in the history
* 2.8:
  Fix Clidumper tests
  Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
  Apply fixers
  Disable the native_constant_invocation fixer until it can be scoped
  Update the list of excluded files for the CS fixer
  • Loading branch information
nicolas-grekas committed Jul 26, 2018
2 parents 46f0a29 + 15579a6 commit f503315
Show file tree
Hide file tree
Showing 91 changed files with 260 additions and 260 deletions.
4 changes: 2 additions & 2 deletions AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function hasTypeExtensions($name)
$this->initTypeExtensions();
}

return isset($this->typeExtensions[$name]) && count($this->typeExtensions[$name]) > 0;
return isset($this->typeExtensions[$name]) && \count($this->typeExtensions[$name]) > 0;
}

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ private function initTypes()
throw new UnexpectedTypeException($type, 'Symfony\Component\Form\FormTypeInterface');
}

$this->types[get_class($type)] = $type;
$this->types[\get_class($type)] = $type;
}
}

Expand Down
4 changes: 2 additions & 2 deletions AbstractRendererEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function setTheme(FormView $view, $themes /*, $useDefaultThemes = true */
$cacheKey = $view->vars[self::CACHE_KEY_VAR];

// Do not cast, as casting turns objects into arrays of properties
$this->themes[$cacheKey] = is_array($themes) ? $themes : array($themes);
$this->themes[$cacheKey] = \is_array($themes) ? $themes : array($themes);

$args = func_get_args();
$args = \func_get_args();
$this->useDefaultThemes[$cacheKey] = isset($args[2]) ? (bool) $args[2] : true;

// Unset instead of resetting to an empty array, in order to allow
Expand Down
2 changes: 1 addition & 1 deletion AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getBlockPrefix()
{
return StringUtil::fqcnToBlockPrefix(get_class($this));
return StringUtil::fqcnToBlockPrefix(\get_class($this));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions CallbackTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(callable $transform, callable $reverseTransform)
*/
public function transform($data)
{
return call_user_func($this->transform, $data);
return \call_user_func($this->transform, $data);
}

/**
Expand All @@ -57,6 +57,6 @@ public function transform($data)
*/
public function reverseTransform($data)
{
return call_user_func($this->reverseTransform, $data);
return \call_user_func($this->reverseTransform, $data);
}
}
8 changes: 4 additions & 4 deletions ChoiceList/ArrayChoiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function getValuesForChoices(array $choices)
$givenValues = array();

foreach ($choices as $i => $givenChoice) {
$givenValues[$i] = (string) call_user_func($this->valueCallback, $givenChoice);
$givenValues[$i] = (string) \call_user_func($this->valueCallback, $givenChoice);
}

return array_intersect($givenValues, array_keys($this->choices));
Expand Down Expand Up @@ -196,13 +196,13 @@ protected function flatten(array $choices, $value, &$choicesByValues, &$keysByVa
}

foreach ($choices as $key => $choice) {
if (is_array($choice)) {
if (\is_array($choice)) {
$this->flatten($choice, $value, $choicesByValues, $keysByValues, $structuredValues[$key]);

continue;
}

$choiceValue = (string) call_user_func($value, $choice);
$choiceValue = (string) \call_user_func($value, $choice);
$choicesByValues[$choiceValue] = $choice;
$keysByValues[$choiceValue] = $key;
$structuredValues[$key] = $choiceValue;
Expand All @@ -222,7 +222,7 @@ protected function flatten(array $choices, $value, &$choicesByValues, &$keysByVa
private function castableToString(array $choices, array &$cache = array())
{
foreach ($choices as $choice) {
if (is_array($choice)) {
if (\is_array($choice)) {
if (!$this->castableToString($choice, $cache)) {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions ChoiceList/Factory/CachingFactoryDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface
*/
public static function generateHash($value, $namespace = '')
{
if (is_object($value)) {
if (\is_object($value)) {
$value = spl_object_hash($value);
} elseif (is_array($value)) {
} elseif (\is_array($value)) {
array_walk_recursive($value, function (&$v) {
if (is_object($v)) {
if (\is_object($v)) {
$v = spl_object_hash($v);
}
});
Expand All @@ -77,7 +77,7 @@ private static function flatten(array $array, &$output)
}

foreach ($array as $key => $value) {
if (is_array($value)) {
if (\is_array($value)) {
self::flatten($value, $output);
continue;
}
Expand Down
26 changes: 13 additions & 13 deletions ChoiceList/Factory/DefaultChoiceListFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
$choices = $list->getChoices();
$keys = $list->getOriginalKeys();

if (!is_callable($preferredChoices) && !empty($preferredChoices)) {
if (!\is_callable($preferredChoices) && !empty($preferredChoices)) {
$preferredChoices = function ($choice) use ($preferredChoices) {
return in_array($choice, $preferredChoices, true);
return \in_array($choice, $preferredChoices, true);
};
}

Expand All @@ -66,7 +66,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
// If $groupBy is a callable, choices are added to the group with the
// name returned by the callable. If the callable returns null, the
// choice is not added to any group
if (is_callable($groupBy)) {
if (\is_callable($groupBy)) {
foreach ($choices as $value => $choice) {
self::addChoiceViewGroupedBy(
$groupBy,
Expand Down Expand Up @@ -99,13 +99,13 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
// Remove any empty group view that may have been created by
// addChoiceViewGroupedBy()
foreach ($preferredViews as $key => $view) {
if ($view instanceof ChoiceGroupView && 0 === count($view->choices)) {
if ($view instanceof ChoiceGroupView && 0 === \count($view->choices)) {
unset($preferredViews[$key]);
}
}

foreach ($otherViews as $key => $view) {
if ($view instanceof ChoiceGroupView && 0 === count($view->choices)) {
if ($view instanceof ChoiceGroupView && 0 === \count($view->choices)) {
unset($otherViews[$key]);
}
}
Expand All @@ -118,7 +118,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
// $value may be an integer or a string, since it's stored in the array
// keys. We want to guarantee it's a string though.
$key = $keys[$value];
$nextIndex = is_int($index) ? $index++ : call_user_func($index, $choice, $key, $value);
$nextIndex = \is_int($index) ? $index++ : \call_user_func($index, $choice, $key, $value);

// BC normalize label to accept a false value
if (null === $label) {
Expand All @@ -127,7 +127,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
} elseif (false !== $label) {
// If "choice_label" is set to false and "expanded" is true, the value false
// should be passed on to the "label" option of the checkboxes/radio buttons
$dynamicLabel = call_user_func($label, $choice, $key, $value);
$dynamicLabel = \call_user_func($label, $choice, $key, $value);
$label = false === $dynamicLabel ? false : (string) $dynamicLabel;
}

Expand All @@ -137,11 +137,11 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $
$label,
// The attributes may be a callable or a mapping from choice indices
// to nested arrays
is_callable($attr) ? call_user_func($attr, $choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
\is_callable($attr) ? \call_user_func($attr, $choice, $key, $value) : (isset($attr[$key]) ? $attr[$key] : array())
);

// $isPreferred may be null if no choices are preferred
if ($isPreferred && call_user_func($isPreferred, $choice, $key, $value)) {
if ($isPreferred && \call_user_func($isPreferred, $choice, $key, $value)) {
$preferredViews[$nextIndex] = $view;
} else {
$otherViews[$nextIndex] = $view;
Expand All @@ -156,7 +156,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key
}

// Add the contents of groups to new ChoiceGroupView instances
if (is_array($value)) {
if (\is_array($value)) {
$preferredViewsForGroup = array();
$otherViewsForGroup = array();

Expand All @@ -172,11 +172,11 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key
$otherViewsForGroup
);

if (count($preferredViewsForGroup) > 0) {
if (\count($preferredViewsForGroup) > 0) {
$preferredViews[$key] = new ChoiceGroupView($key, $preferredViewsForGroup);
}

if (count($otherViewsForGroup) > 0) {
if (\count($otherViewsForGroup) > 0) {
$otherViews[$key] = new ChoiceGroupView($key, $otherViewsForGroup);
}

Expand All @@ -200,7 +200,7 @@ private static function addChoiceViewsGroupedBy($groupBy, $label, $choices, $key

private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label, $keys, &$index, $attr, $isPreferred, &$preferredViews, &$otherViews)
{
$groupLabel = call_user_func($groupBy, $choice, $keys[$value], $value);
$groupLabel = \call_user_func($groupBy, $choice, $keys[$value], $value);

if (null === $groupLabel) {
// If the callable returns null, don't group the choice
Expand Down
32 changes: 16 additions & 16 deletions ChoiceList/Factory/PropertyAccessDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public function getDecoratedFactory()
*/
public function createListFromChoices($choices, $value = null)
{
if (is_string($value) && !is_callable($value)) {
if (\is_string($value) && !\is_callable($value)) {
$value = new PropertyPath($value);
} elseif (is_string($value) && is_callable($value)) {
} elseif (\is_string($value) && \is_callable($value)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand All @@ -84,7 +84,7 @@ public function createListFromChoices($choices, $value = null)
// when such values are passed to
// ChoiceListInterface::getValuesForChoices(). Handle this case
// so that the call to getValue() doesn't break.
if (is_object($choice) || is_array($choice)) {
if (\is_object($choice) || \is_array($choice)) {
return $accessor->getValue($choice, $value);
}
};
Expand All @@ -104,9 +104,9 @@ public function createListFromChoices($choices, $value = null)
*/
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null)
{
if (is_string($value) && !is_callable($value)) {
if (\is_string($value) && !\is_callable($value)) {
$value = new PropertyPath($value);
} elseif (is_string($value) && is_callable($value)) {
} elseif (\is_string($value) && \is_callable($value)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand All @@ -117,7 +117,7 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
// when such values are passed to
// ChoiceListInterface::getValuesForChoices(). Handle this case
// so that the call to getValue() doesn't break.
if (is_object($choice) || is_array($choice)) {
if (\is_object($choice) || \is_array($choice)) {
return $accessor->getValue($choice, $value);
}
};
Expand All @@ -142,9 +142,9 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
{
$accessor = $this->propertyAccessor;

if (is_string($label) && !is_callable($label)) {
if (\is_string($label) && !\is_callable($label)) {
$label = new PropertyPath($label);
} elseif (is_string($label) && is_callable($label)) {
} elseif (\is_string($label) && \is_callable($label)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand All @@ -154,9 +154,9 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
};
}

if (is_string($preferredChoices) && !is_callable($preferredChoices)) {
if (\is_string($preferredChoices) && !\is_callable($preferredChoices)) {
$preferredChoices = new PropertyPath($preferredChoices);
} elseif (is_string($preferredChoices) && is_callable($preferredChoices)) {
} elseif (\is_string($preferredChoices) && \is_callable($preferredChoices)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand All @@ -171,9 +171,9 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
};
}

if (is_string($index) && !is_callable($index)) {
if (\is_string($index) && !\is_callable($index)) {
$index = new PropertyPath($index);
} elseif (is_string($index) && is_callable($index)) {
} elseif (\is_string($index) && \is_callable($index)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand All @@ -183,9 +183,9 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
};
}

if (is_string($groupBy) && !is_callable($groupBy)) {
if (\is_string($groupBy) && !\is_callable($groupBy)) {
$groupBy = new PropertyPath($groupBy);
} elseif (is_string($groupBy) && is_callable($groupBy)) {
} elseif (\is_string($groupBy) && \is_callable($groupBy)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand All @@ -199,9 +199,9 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
};
}

if (is_string($attr) && !is_callable($attr)) {
if (\is_string($attr) && !\is_callable($attr)) {
$attr = new PropertyPath($attr);
} elseif (is_string($attr) && is_callable($attr)) {
} elseif (\is_string($attr) && \is_callable($attr)) {
@trigger_error('Passing callable strings is deprecated since Symfony 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED);
}

Expand Down
2 changes: 1 addition & 1 deletion ChoiceList/Loader/CallbackChoiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function loadChoiceList($value = null)
return $this->choiceList;
}

return $this->choiceList = new ArrayChoiceList(call_user_func($this->callback), $value);
return $this->choiceList = new ArrayChoiceList(\call_user_func($this->callback), $value);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$object = $resolvedType->getOptionsResolver();

if (!$object->isDefined($option)) {
$message = sprintf('Option "%s" is not defined in "%s".', $option, get_class($resolvedType->getInnerType()));
$message = sprintf('Option "%s" is not defined in "%s".', $option, \get_class($resolvedType->getInnerType()));

if ($alternatives = $this->findAlternatives($option, $object->getDefinedOptions())) {
if (1 == count($alternatives)) {
if (1 == \count($alternatives)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
Expand Down Expand Up @@ -147,12 +147,12 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, $shor
}
}

if (0 === $count = count($classes)) {
if (0 === $count = \count($classes)) {
$message = sprintf("Could not find type \"%s\" into the following namespaces:\n %s", $shortClassName, implode("\n ", $this->namespaces));

$allTypes = array_merge($this->getCoreTypes(), $this->types);
if ($alternatives = $this->findAlternatives($shortClassName, $allTypes)) {
if (1 == count($alternatives)) {
if (1 == \count($alternatives)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
Expand All @@ -178,7 +178,7 @@ private function getCoreTypes()
$loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes');
$loadTypesRefMethod->setAccessible(true);
$coreTypes = $loadTypesRefMethod->invoke($coreExtension);
$coreTypes = array_map(function (FormTypeInterface $type) { return get_class($type); }, $coreTypes);
$coreTypes = array_map(function (FormTypeInterface $type) { return \get_class($type); }, $coreTypes);
sort($coreTypes);

return $coreTypes;
Expand All @@ -189,7 +189,7 @@ private function findAlternatives($name, array $collection)
$alternatives = array();
foreach ($collection as $item) {
$lev = levenshtein($name, $item);
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Console/Descriptor/Descriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function describe(OutputInterface $output, $object, array $options = arra
$this->describeOption($object, $options);
break;
default:
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
}
}

Expand Down Expand Up @@ -133,7 +133,7 @@ protected function getOptionDefinition(OptionsResolver $optionsResolver, $option

private function getParentOptionsResolver(ResolvedFormTypeInterface $type)
{
$this->parents[$class = get_class($type->getInnerType())] = array();
$this->parents[$class = \get_class($type->getInnerType())] = array();

if (null !== $type->getParent()) {
$optionsResolver = clone $this->getParentOptionsResolver($type->getParent());
Expand All @@ -155,7 +155,7 @@ private function collectTypeExtensionsOptions(ResolvedFormTypeInterface $type, O
foreach ($type->getTypeExtensions() as $extension) {
$inheritedOptions = $optionsResolver->getDefinedOptions();
$extension->configureOptions($optionsResolver);
$this->extensions[get_class($extension)] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions);
$this->extensions[\get_class($extension)] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions);
}
}
}
Loading

0 comments on commit f503315

Please sign in to comment.