Skip to content

Commit

Permalink
Fix inconsistent return points.
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus authored and nicolas-grekas committed Aug 20, 2019
1 parent 4d7e958 commit 9b20d41
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ protected function loadTypeExtensions()
*/
protected function loadTypeGuesser()
{
return null;
}

/**
Expand Down
9 changes: 3 additions & 6 deletions ChoiceList/Factory/PropertyAccessDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,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)) {
return $accessor->getValue($choice, $value);
}
return \is_object($choice) || \is_array($choice) ? $accessor->getValue($choice, $value) : null;
};
}

Expand Down Expand Up @@ -113,9 +111,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)) {
return $accessor->getValue($choice, $value);
}
return \is_object($choice) || \is_array($choice) ? $accessor->getValue($choice, $value) : null;
};
}

Expand Down Expand Up @@ -191,6 +187,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null,
return $accessor->getValue($choice, $groupBy);
} catch (UnexpectedTypeException $e) {
// Don't group if path is not readable
return null;
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/DataTransformer/ArrayToPartsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function reverseTransform($array)
if (\count($emptyKeys) > 0) {
if (\count($emptyKeys) === \count($this->partMapping)) {
// All parts empty
return;
return null;
}

throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function reverseTransform($value)

if (1 !== \count($choices)) {
if (null === $value || '' === $value) {
return;
return null;
}

throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique', $value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($multiple = false)
public function transform($dateTimeZone)
{
if (null === $dateTimeZone) {
return;
return null;
}

if ($this->multiple) {
Expand All @@ -58,7 +58,7 @@ public function transform($dateTimeZone)
public function reverseTransform($value)
{
if (null === $value) {
return;
return null;
}

if ($this->multiple) {
Expand Down
11 changes: 4 additions & 7 deletions Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function configureOptions(OptionsResolver $resolver)
{
$emptyData = function (Options $options) {
if ($options['expanded'] && !$options['multiple']) {
return;
return null;
}

if ($options['multiple']) {
Expand Down Expand Up @@ -284,13 +284,13 @@ public function configureOptions(OptionsResolver $resolver)
$placeholderNormalizer = function (Options $options, $placeholder) {
if ($options['multiple']) {
// never use an empty value for this case
return;
return null;
} elseif ($options['required'] && ($options['expanded'] || isset($options['attr']['size']) && $options['attr']['size'] > 1)) {
// placeholder for required radio buttons or a select with size > 1 does not make sense
return;
return null;
} elseif (false === $placeholder) {
// an empty value should be added but the user decided otherwise
return;
return null;
} elseif ($options['expanded'] && '' === $placeholder) {
// never use an empty label for radio buttons
return 'None';
Expand Down Expand Up @@ -380,9 +380,6 @@ private function addSubForms(FormBuilderInterface $builder, array $choiceViews,
}
}

/**
* @return mixed
*/
private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $choiceView, array $options)
{
$choiceOpts = [
Expand Down
2 changes: 1 addition & 1 deletion Extension/Validator/Type/BaseValidatorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function configureOptions(OptionsResolver $resolver)
}

if (empty($groups)) {
return;
return null;
}

if (\is_callable($groups)) {
Expand Down
8 changes: 8 additions & 0 deletions Extension/Validator/ValidatorTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public function guessTypeForConstraint(Constraint $constraint)
case 'Symfony\Component\Validator\Constraints\IsFalse':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::MEDIUM_CONFIDENCE);
}

return null;
}

/**
Expand All @@ -168,6 +170,8 @@ public function guessRequiredForConstraint(Constraint $constraint)
case 'Symfony\Component\Validator\Constraints\IsTrue':
return new ValueGuess(true, Guess::HIGH_CONFIDENCE);
}

return null;
}

/**
Expand Down Expand Up @@ -196,6 +200,8 @@ public function guessMaxLengthForConstraint(Constraint $constraint)
}
break;
}

return null;
}

/**
Expand Down Expand Up @@ -232,6 +238,8 @@ public function guessPatternForConstraint(Constraint $constraint)
}
break;
}

return null;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions Extension/Validator/ViolationMapper/MappingRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public function getOrigin()
*/
public function match($propertyPath)
{
if ($propertyPath === $this->propertyPath) {
return $this->getTarget();
}
return $propertyPath === $this->propertyPath ? $this->getTarget() : null;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,7 @@ public function getClickedButton()
return $this->clickedButton;
}

if ($this->parent && method_exists($this->parent, 'getClickedButton')) {
return $this->parent->getClickedButton();
}
return $this->parent && method_exists($this->parent, 'getClickedButton') ? $this->parent->getClickedButton() : null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Util/StringUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ public static function fqcnToBlockPrefix($fqcn)
if (preg_match('~([^\\\\]+?)(type)?$~i', $fqcn, $matches)) {
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $matches[1]));
}

return null;
}
}

0 comments on commit 9b20d41

Please sign in to comment.