SCA: consolidate non empty array checks across codebase

This commit is contained in:
Vladimir Reznichenko 2018-11-15 17:40:37 +01:00 committed by Nicolas Grekas
parent 236565c87e
commit 2f1fd54dda
3 changed files with 3 additions and 3 deletions

View File

@ -48,7 +48,7 @@ class FormValidator extends ConstraintValidator
// Validate the data against its own constraints
if ($form->isRoot() && (\is_object($data) || \is_array($data))) {
if (\is_array($groups) && \count($groups) > 0 || $groups instanceof GroupSequence && \count($groups->groups) > 0) {
if (($groups && \is_array($groups)) || ($groups instanceof GroupSequence && $groups->groups)) {
$validator->atPath('data')->validate($form->getData(), null, $groups);
}
}

View File

@ -69,7 +69,7 @@ class ArrayConverter
$elem = &$elem[$part];
}
if (\is_array($elem) && \count($elem) > 0 && $parentOfElem) {
if ($elem && \is_array($elem) && $parentOfElem) {
/* Process next case:
* 'foo.bar': 'test1'
* 'foo': 'test2'

View File

@ -120,7 +120,7 @@ abstract class Constraint
if (\is_array($options)) {
reset($options);
}
if (\is_array($options) && \count($options) > 0 && \is_string(key($options))) {
if ($options && \is_array($options) && \is_string(key($options))) {
foreach ($options as $option => $value) {
if (array_key_exists($option, $knownOptions)) {
$this->$option = $value;