Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

zf7428 fixed issue with inconsistent getTrait() behaviour #7428 #7431

Merged
merged 4 commits into from
May 4, 2015
Merged

zf7428 fixed issue with inconsistent getTrait() behaviour #7428 #7431

merged 4 commits into from
May 4, 2015

Conversation

stepashka69
Copy link
Contributor

  1. Made getTraits() to behave the same was a parent method - return null only in case of error and empty array otherwise
  2. Added phpdoc comment
  3. Added tests for getTraits()

public function getTraits()
{
$vals = array();
$traits = parent::getTraits();
if (! $traits) {
return;
if ($traits === null) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry, my mistake.

@steverhoades
Copy link
Contributor

👍 Thanks for catching that.

$this->dummy = boolval($dummy);
return $this;
}
}
Copy link
Member

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.

@weierophinney weierophinney added this to the 2.4.1 milestone May 4, 2015
weierophinney added a commit that referenced this pull request May 4, 2015
zf7428 fixed issue with inconsistent getTrait() behaviour #7428
weierophinney added a commit that referenced this pull request May 4, 2015
- Use `assertInternalType()` and `assertCount()`
weierophinney added a commit that referenced this pull request May 4, 2015
@weierophinney weierophinney merged commit d08700c into zendframework:master May 4, 2015
weierophinney added a commit that referenced this pull request May 4, 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.

6 participants