Skip to content

Commit

Permalink
minor #18400 Lower complexity of Form:isValid() (krzysiekpiasecki)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.7 branch (closes #18400).

Discussion
----------

Lower complexity of Form:isValid()

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Replace #18391
- use Yoda condition,
- merge into 2.7 branch

Why?

- lower LOC
- less return expressions
- lower complexity
- more readable comparison

Commits
-------

d583ec3 Lower complexity of Form:isValid()
  • Loading branch information
fabpot committed Apr 1, 2016
2 parents c5b792c + d583ec3 commit 83bb723
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/Symfony/Component/Form/Form.php
Expand Up @@ -766,11 +766,7 @@ public function isValid()
return true;
}

if (count($this->getErrors(true)) > 0) {
return false;
}

return true;
return 0 === count($this->getErrors(true));
}

/**
Expand Down

0 comments on commit 83bb723

Please sign in to comment.