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] getNamespace is independent #27915

Merged
merged 1 commit into from
Mar 18, 2019
Merged

[5.8] getNamespace is independent #27915

merged 1 commit into from
Mar 18, 2019

Conversation

seriquynh
Copy link
Contributor

@seriquynh seriquynh commented Mar 18, 2019

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
Member

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

@seriquynh
Copy link
Contributor Author

seriquynh commented Mar 18, 2019

@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
@seriquynh seriquynh 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