Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] class_uses_recursive() return parent class's trait first #22536

Closed
wants to merge 2 commits into from

Conversation

zhwei
Copy link
Contributor

@zhwei zhwei commented Dec 26, 2017

Reason

when Model booting traits, subclass's trait will boot before parent's trait, It is quite different from dev's expectation.


Changed

  • This PR will make class_uses_recursive() return traits order by use order.
  • PHPUnit assertEquals does not validate the order of array elements , so i change to assertSame

@@ -699,20 +699,27 @@ public function testLast()

public function testClassUsesRecursiveShouldReturnTraitsOnParentClasses()
{
$this->assertEquals([
'Illuminate\Tests\Support\SupportTestTraitOne' => 'Illuminate\Tests\Support\SupportTestTraitOne',
$this->assertTrue([
Copy link
Contributor

Choose a reason for hiding this comment

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

Use assertSame instead. It checks strict.

Copy link
Contributor Author

@zhwei zhwei Dec 26, 2017

Choose a reason for hiding this comment

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

Thanks ! 👍

@sisve
Copy link
Contributor

sisve commented Dec 26, 2017

This sounds like a breaking change and something that should target the 5.6 release (the master branch).

@zhwei
Copy link
Contributor Author

zhwei commented Dec 26, 2017

@sisve

I think this should be a Bug, In my case, subclass boot depend on the data generated by parent class's boot. On the contrary, parent class's boot certainly not depend on subclass's boot.

@sisve
Copy link
Contributor

sisve commented Dec 26, 2017

You're not changing just how model traits are initiated, you are changing how the global helper class_uses_recursive works. This could affect a lot more things that just your specific scenario. Thus I argue that it should target the 5.6 release and be documented as a change in the upgrade guide.

@zhwei
Copy link
Contributor Author

zhwei commented Dec 26, 2017

ok

@zhwei
Copy link
Contributor Author

zhwei commented Dec 26, 2017

new PR is #22537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants