-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Deprecate auto-discovery in Kernel::getName() #24292
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,15 +78,23 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl | |
/** | ||
* Constructor. | ||
* | ||
* @param string $environment The environment | ||
* @param bool $debug Whether to enable debugging or not | ||
* @param string $environment The environment | ||
* @param bool $debug Whether to enable debugging or not | ||
* @param string|null $name The application name | ||
*/ | ||
public function __construct($environment, $debug) | ||
public function __construct($environment, $debug, $name = null) | ||
{ | ||
$this->environment = $environment; | ||
$this->debug = (bool) $debug; | ||
$this->rootDir = $this->getRootDir(); | ||
$this->name = $this->getName(); | ||
|
||
if (null === $name) { | ||
$this->name = $this->getName(); | ||
} elseif (preg_match('~^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$~', $name)) { | ||
$this->name = $name; | ||
} else { | ||
throw new \InvalidArgumentException(sprintf('"%s" is not a valid kernel name.', $name)); | ||
} | ||
|
||
if ($this->debug) { | ||
$this->startTime = microtime(true); | ||
|
@@ -297,6 +305,10 @@ public function getName() | |
if (ctype_digit($this->name[0])) { | ||
$this->name = '_'.$this->name; | ||
} | ||
|
||
if ('app' !== $this->name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why And what would this look like in 4.0? Would this method exist... but throw an exception? (so that the user either needs to override this method or pass in as an arg?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For 4.0 auto-discovery is removed and it should look like a simple getter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weaverryan AFAIK, in 4.0, this method would be We have 2 solutions in 4.0:
If we go for the second option, the deprecation should instead be moved at the very beginning of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof for 4.0 it should look like |
||
@trigger_error(sprintf('Auto-discovery of the kernel name is deprecated since Symfony 3.4 and won\'t be supported in 4.0.'), E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message should tell users to override There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is to pass the Kernel name as constructor argument, with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then it should tell them to pass it in the constructor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, the deprecation should happen in the constructor itself (when passing |
||
} | ||
} | ||
|
||
return $this->name; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a BC break.