-
Notifications
You must be signed in to change notification settings - Fork 2.5k
zf7428 fixed issue with inconsistent getTrait() behaviour #7428 #7431
Conversation
stepashka69
commented
Apr 7, 2015
- Made getTraits() to behave the same was a parent method - return null only in case of error and empty array otherwise
- Added phpdoc comment
- Added tests for getTraits()
public function getTraits() | ||
{ | ||
$vals = array(); | ||
$traits = parent::getTraits(); | ||
if (! $traits) { | ||
return; | ||
if ($traits === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$traits === null
is not possible here, because ReflectionClass:getTraits()
returns array
or null
in case of an error (see manual). if (! $traits) {
is correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if $traits
is empty array then if (! $traits)
is true
and the return of getTraits()
is null
. It is incorrect behaviour which broke a lot of unittests in my projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, my mistake.
👍 Thanks for catching that. |
$this->dummy = boolval($dummy); | ||
return $this; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use spaces instead of tabs.
zf7428 fixed issue with inconsistent getTrait() behaviour #7428
- Use `assertInternalType()` and `assertCount()`