Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Kernel::$projectDir is inconsistent #22727

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

Closed
wants to merge 1 commit into from
Closed

Kernel::$projectDir is inconsistent #22727

wants to merge 1 commit into from

Conversation

leofeyer
Copy link
Contributor

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

The new Kernel::$projectDir property is private instead of protected, which is inconsistent if you want to set the property in a child class.

class AppKernel extends Kernel
{
    public function overwriteDirectories()
    {
        $this->rootDir = ''; // works
        $this->projectDir = ''; // does not work
    }
}

Since the Kernel class is almost always extended and since the project root dir is very likely to be overwritten (e.g. in the unit tests), the property should be protected IMHO.

@xabbuh
Copy link
Member

xabbuh commented May 17, 2017

I am 👎 on this change. Maintaining BC for protected properties is a nightmare. And you can already achieve the same by overriding the getProjectDir() method in your custom kernel class.

@javiereguiluz
Copy link
Member

@leofeyer allowing to override these variables is very important ... but we don't allow to do that changing the value of the properties directly, but by overriding the getProjectDir() method of the Kernel class, as @xabbuh explained.

So I'm going to close this issue as "won't fix" because this can already be solved in other way. Thanks!

@stof
Copy link
Member

stof commented May 17, 2017

Note that writing directly to rootDir is not really something we want to support either (you should also overwrite the method). But we cannot switch it to private outside major versions

@stof
Copy link
Member

stof commented May 17, 2017

thus, you still have not provided a use case requiring the visibility change (i.e. something which cannot be achieved by overwriting the method)

@leofeyer
Copy link
Contributor Author

Ok, thanks for the clarification. We should merge #22728 then.

fabpot added a commit that referenced this pull request May 25, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[HttpKernel] Fix kernel.project_dir extensibility

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22727
| License       | MIT
| Doc PR        | n/a

Alternative to #22727 that makes use of the existing public api.

Commits
-------

3230fc7 Fix kernel.project_dir extensibility
symfony-splitter pushed a commit to symfony/http-kernel that referenced this pull request May 25, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[HttpKernel] Fix kernel.project_dir extensibility

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#22727
| License       | MIT
| Doc PR        | n/a

Alternative to #22727 that makes use of the existing public api.

Commits
-------

3230fc7 Fix kernel.project_dir extensibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants