Skip to content

Conversation

@parth391
Copy link
Contributor

This pull request will change resolve helper to App::get facade.

And allow change to App::make facade, in case of more than 1 argument.

Comment on lines 66 to 70
if (count($node->args) !== 1) {
return null;
return $this->nodeFactory->createStaticCall('Illuminate\Support\Facades\App', 'make', $node->args);
}

return $this->nodeFactory->createStaticCall('Illuminate\Support\Facades\App', 'get', $node->args);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have to be careful changing the logic because at current your code would change app() use to App::make().

That said this rule is a bit broken and should be using make over get because they have slightly different behaviours in that get will throw and exception if the abstract does not exist and make just returns null. app(<service>) uses make.

I think the following is right:

        if (count($node->args) > 0) {
            return $this->nodeFactory->createStaticCall('Illuminate\Support\Facades\App', 'make', $node->args);
        }

        return null;

There needs to be tests that cover skipping app() with no arguments if they don't exist already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@peterfox thank you for pointing that out, i totally missed the no-argument scenario.

@parth391
Copy link
Contributor Author

@peterfox, i have updated the code and added the test case for no-argument.

Copy link
Collaborator

@peterfox peterfox left a comment

Choose a reason for hiding this comment

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

thank you @parth391 🎉 looks great

@peterfox peterfox merged commit 7bb8e3c into driftingly:main Mar 24, 2025
5 checks passed
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.

2 participants