Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Fix ->validationErrors->count() when the object is null #225

Merged
merged 2 commits into from
May 10, 2015
Merged

Fix ->validationErrors->count() when the object is null #225

merged 2 commits into from
May 10, 2015

Conversation

wemersonrv
Copy link
Contributor

Hi... in the src/LaravelBook/Ardent/Ardent.php line 541 i've found an issue: The $this->validationErrors->count() causes an error because validationErrors is null and does not retrive the count() method.

See this Screenshot

Then a single check if it's null, solve it... I do know how the object is null in my case, but here is my suggestion in this pull request.

Sorry about my poor english!

if ($this->validationErrors->count() > 0) {
if($this->validationErrors === null){
$this->validationErrors = new MessageBag;
}elseif($this->validationErrors->count() > 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would look cleaner if these two conditions were merged.

$this->validationErrors = new MessageBag; is executed in both cases anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, fix spacing. Would be nice if you follow PSR-2: http://www.php-fig.org/psr/psr-2/#5.1.-if,-elseif,-else

@igorsantos07
Copy link
Member

@wemersonrv, please take a look at the two notes in the diff :)

@igorsantos07 igorsantos07 merged commit 6f16334 into laravel-ardent:master May 10, 2015
igorsantos07 added a commit that referenced this pull request May 10, 2015
igorsantos07 added a commit that referenced this pull request May 10, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants