minor #29231 SCA: consolidate non empty array checks across codebase (kalessil)
This PR was squashed before being merged into the 3.4 branch (closes #29231).
Discussion
----------
SCA: consolidate non empty array checks across codebase
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
This PR replaces `is_array(...) && count(...) > 0` with `... && is_array(...)` construct used in the codebase.
Commits
-------
2f1fd54dda
SCA: consolidate non empty array checks across codebase
This commit is contained in:
commit
36527634f2
@ -48,7 +48,7 @@ class FormValidator extends ConstraintValidator
|
|||||||
|
|
||||||
// Validate the data against its own constraints
|
// Validate the data against its own constraints
|
||||||
if ($form->isRoot() && (\is_object($data) || \is_array($data))) {
|
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);
|
$validator->atPath('data')->validate($form->getData(), null, $groups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class ArrayConverter
|
|||||||
$elem = &$elem[$part];
|
$elem = &$elem[$part];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_array($elem) && \count($elem) > 0 && $parentOfElem) {
|
if ($elem && \is_array($elem) && $parentOfElem) {
|
||||||
/* Process next case:
|
/* Process next case:
|
||||||
* 'foo.bar': 'test1'
|
* 'foo.bar': 'test1'
|
||||||
* 'foo': 'test2'
|
* 'foo': 'test2'
|
||||||
|
@ -120,7 +120,7 @@ abstract class Constraint
|
|||||||
if (\is_array($options)) {
|
if (\is_array($options)) {
|
||||||
reset($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) {
|
foreach ($options as $option => $value) {
|
||||||
if (array_key_exists($option, $knownOptions)) {
|
if (array_key_exists($option, $knownOptions)) {
|
||||||
$this->$option = $value;
|
$this->$option = $value;
|
||||||
|
Reference in New Issue
Block a user