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.8] added $params argument to resolve helper #28020

Merged
merged 2 commits into from
Mar 26, 2019

Conversation

yamenarahman
Copy link
Contributor

$api = resolve('HelpSpot\API'); is an alias for $api = $this->app->make('HelpSpot\API');

So, may $api = resolveWith('HelpSpot\API', ['id' => 1]);
be an alias for $api = $this->app->makeWith('HelpSpot\API', ['id' => 1]);

@driesvints
Copy link
Member

Can't we just add the , array $params = [] part to the resolve function instead? Would rather not see more helpers be added.

@driesvints
Copy link
Member

Btw, you can already do this with

$api = app('HelpSpot\API', ['id' => 1]);

@driesvints driesvints changed the title added resolveWith helper [5.8] added resolveWith helper Mar 26, 2019
@yamenarahman
Copy link
Contributor Author

Hmm, Thanks.

@yamenarahman
Copy link
Contributor Author

yamenarahman commented Mar 26, 2019

function resolve($name, array $params = []) 
{
    return app($name, $params);
}

Should it be like that?

@yamenarahman yamenarahman changed the title [5.8] added resolveWith helper [5.8] added $params argument to resolve helper Mar 26, 2019
src/Illuminate/Foundation/helpers.php Outdated Show resolved Hide resolved
@yamenarahman
Copy link
Contributor Author

@36864 resolve is already an alias for app.

@Miguel-Serejo
Copy link

Sorry, jumped the gun with my previous comment.

I still think this type of alias helpers should just be removed, but no harm in just making it closer to the helper it's aliasing I guess.

@devcircus
Copy link
Contributor

devcircus commented Mar 26, 2019

A little history:
Originally this helper accepted parameters, but for a brief time, the container was changed to not have this ability. So parameters were removed from the “app” and “resolve” helpers in #17060. A few months later parameters were brought back in #18271, so parameters were added back to the “app” helper in #18320. Somehow “resolve” just got left out of those changes.

We’ve made it 2 years without anyone asking why.

@taylorotwell taylorotwell merged commit f852b97 into laravel:5.8 Mar 26, 2019
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.

5 participants