Skip to content

[5.4] Return the used traits from setUpTraits#19486

Merged
taylorotwell merged 1 commit intolaravel:5.4from
Lidbetter:patch-2
Jun 6, 2017
Merged

[5.4] Return the used traits from setUpTraits#19486
taylorotwell merged 1 commit intolaravel:5.4from
Lidbetter:patch-2

Conversation

@Lidbetter
Copy link
Contributor

@Lidbetter Lidbetter commented Jun 5, 2017

Allows for the developer to add their own traits and actions during the setup phase without having to call: $uses = array_flip(class_uses_recursive(static::class)); in the subclass.

Example usage before:

    protected function setUpTraits()
    {
        parent::setUpTraits();
        $uses = array_flip(class_uses_recursive(static::class));

        if(isset($uses[MyGreatTrait::class])) {
            $this->runMyUsefulThing();
        }
    }

Example usage with change from this pr:

    protected function setUpTraits()
    {
        $uses = parent::setUpTraits();

        if(isset($uses[MyGreatTrait::class])) {
            $this->runMyUsefulThing();
        }

        return $uses;
    }

@Lidbetter Lidbetter changed the title Return the used traits from setUpTraits [5.4] Return the used traits from setUpTraits Jun 5, 2017
@taylorotwell taylorotwell merged commit 4586bb7 into laravel:5.4 Jun 6, 2017
crynobone added a commit to orchestral/testbench that referenced this pull request Jun 6, 2017
From laravel/framework#19486

Signed-off-by: crynobone <crynobone@gmail.com>
@mfn
Copy link
Contributor

mfn commented Jun 7, 2017

Great @Lidbetter just want I was thinking about the other day, thx!

springer12 added a commit to springer12/laravel-testbench that referenced this pull request May 9, 2020
From laravel/framework#19486

Signed-off-by: crynobone <crynobone@gmail.com>
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