Skip to content

[5.8] getNamespace is independent#27915

Merged
taylorotwell merged 1 commit into
laravel:5.8from
oliverquynh:getNamespace_is_independent
Mar 18, 2019
Merged

[5.8] getNamespace is independent#27915
taylorotwell merged 1 commit into
laravel:5.8from
oliverquynh:getNamespace_is_independent

Conversation

@oliverquynh

@oliverquynh oliverquynh commented Mar 18, 2019

Copy link
Copy Markdown
Contributor

Application::getNamespace() currently uses global helpers in which the first call to this method is the call to global container instance only because Application constructor sets it via Application::registerBaseBindings(). Application::getNamespace() is independent and returns the namespace itself. This pull request solves by using the exact methods of Application rather than global helpers.

See the example below for more details:

  • Step 1: The application laravel1/composer.json
{
    "autoload": {
        "psr-4": {
            "Laravel\\One\\": "app/"
        }
    }
}
  • Step 2: The application laravel2/composer.json
{
    "autoload": {
        "psr-4": {
            "Laravel\\Two\\": "app/"
        }
    }
}
  • Step 3: Create 2 application instances in a single process:
$app1 = new Application(realpath(__DIR__.'/path/to/laravel1'));
$app2 = new Application(realpath(__DIR__.'/path/to/laravel2'));
// Initialize but I haven't called getNamespace() from them.

Expected

$app1->getNamespace(); // "Laravel\\One\\"
$app2->getNamespace(); // "Laravel\\Two\\"

Actual

$app1->getNamespace(); // "Laravel\\Two\\"
$app2->getNamespace(); // "Laravel\\Two\\"

@driesvints

Copy link
Copy Markdown
Member

@XuanQuynh please always provide the full description to your initial comment and not link to an external issue/pr.

@oliverquynh

oliverquynh commented Mar 18, 2019

Copy link
Copy Markdown
Contributor Author

@driesvints I updated (just copy from my earlier pr) . OK, I will provide on the later pull requests/issues.

@taylorotwell taylorotwell merged commit c2410f0 into laravel:5.8 Mar 18, 2019
@oliverquynh oliverquynh deleted the getNamespace_is_independent branch March 20, 2019 08:41
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