minor #32216 [5.0] [WebProfilerBundle] Add parameter type-hints where possible (Matts)
This PR was merged into the 5.0-dev branch.
Discussion
----------
[5.0] [WebProfilerBundle] Add parameter type-hints where possible
| Q | A
| ------------- | ---
| Branch? | 5.0
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #32179
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
Add type-hints for WebProfilerBundle in 5.0
Commits
-------
8f33c6f1f3
[WebProfilerBundle] Use scalar type-hints where possible
This commit is contained in:
commit
885a1922e1
@ -47,13 +47,11 @@ class ExceptionController
|
|||||||
/**
|
/**
|
||||||
* Renders the exception panel for the given token.
|
* Renders the exception panel for the given token.
|
||||||
*
|
*
|
||||||
* @param string $token The profiler token
|
|
||||||
*
|
|
||||||
* @return Response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function showAction($token)
|
public function showAction(string $token)
|
||||||
{
|
{
|
||||||
if (null === $this->profiler) {
|
if (null === $this->profiler) {
|
||||||
throw new NotFoundHttpException('The profiler must be enabled.');
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
@ -85,13 +83,11 @@ class ExceptionController
|
|||||||
/**
|
/**
|
||||||
* Renders the exception panel stylesheet for the given token.
|
* Renders the exception panel stylesheet for the given token.
|
||||||
*
|
*
|
||||||
* @param string $token The profiler token
|
|
||||||
*
|
|
||||||
* @return Response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function cssAction($token)
|
public function cssAction(string $token)
|
||||||
{
|
{
|
||||||
if (null === $this->profiler) {
|
if (null === $this->profiler) {
|
||||||
throw new NotFoundHttpException('The profiler must be enabled.');
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
@ -114,7 +110,7 @@ class ExceptionController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to be removed when the minimum required version of Twig is >= 2.0
|
// to be removed when the minimum required version of Twig is >= 2.0
|
||||||
protected function templateExists($template)
|
protected function templateExists(string $template)
|
||||||
{
|
{
|
||||||
$loader = $this->twig->getLoader();
|
$loader = $this->twig->getLoader();
|
||||||
if ($loader instanceof ExistsLoaderInterface) {
|
if ($loader instanceof ExistsLoaderInterface) {
|
||||||
|
@ -62,14 +62,11 @@ class ProfilerController
|
|||||||
/**
|
/**
|
||||||
* Renders a profiler panel for the given token.
|
* Renders a profiler panel for the given token.
|
||||||
*
|
*
|
||||||
* @param Request $request The current HTTP request
|
|
||||||
* @param string $token The profiler token
|
|
||||||
*
|
|
||||||
* @return Response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function panelAction(Request $request, $token)
|
public function panelAction(Request $request, string $token)
|
||||||
{
|
{
|
||||||
$this->denyAccessIfProfilerDisabled();
|
$this->denyAccessIfProfilerDisabled();
|
||||||
|
|
||||||
@ -108,14 +105,11 @@ class ProfilerController
|
|||||||
/**
|
/**
|
||||||
* Renders the Web Debug Toolbar.
|
* Renders the Web Debug Toolbar.
|
||||||
*
|
*
|
||||||
* @param Request $request The current HTTP Request
|
|
||||||
* @param string $token The profiler token
|
|
||||||
*
|
|
||||||
* @return Response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function toolbarAction(Request $request, $token)
|
public function toolbarAction(Request $request, string $token = null)
|
||||||
{
|
{
|
||||||
if (null === $this->profiler) {
|
if (null === $this->profiler) {
|
||||||
throw new NotFoundHttpException('The profiler must be enabled.');
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
@ -210,14 +204,11 @@ class ProfilerController
|
|||||||
/**
|
/**
|
||||||
* Renders the search results.
|
* Renders the search results.
|
||||||
*
|
*
|
||||||
* @param Request $request The current HTTP Request
|
|
||||||
* @param string $token The token
|
|
||||||
*
|
|
||||||
* @return Response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function searchResultsAction(Request $request, $token)
|
public function searchResultsAction(Request $request, string $token)
|
||||||
{
|
{
|
||||||
$this->denyAccessIfProfilerDisabled();
|
$this->denyAccessIfProfilerDisabled();
|
||||||
|
|
||||||
|
@ -45,13 +45,11 @@ class RouterController
|
|||||||
/**
|
/**
|
||||||
* Renders the profiler panel for the given token.
|
* Renders the profiler panel for the given token.
|
||||||
*
|
*
|
||||||
* @param string $token The profiler token
|
|
||||||
*
|
|
||||||
* @return Response A Response instance
|
* @return Response A Response instance
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function panelAction($token)
|
public function panelAction(string $token)
|
||||||
{
|
{
|
||||||
if (null === $this->profiler) {
|
if (null === $this->profiler) {
|
||||||
throw new NotFoundHttpException('The profiler must be enabled.');
|
throw new NotFoundHttpException('The profiler must be enabled.');
|
||||||
|
@ -190,7 +190,7 @@ class ContentSecurityPolicyHandler
|
|||||||
*
|
*
|
||||||
* @return array The directive set
|
* @return array The directive set
|
||||||
*/
|
*/
|
||||||
private function parseDirectives($header)
|
private function parseDirectives(string $header)
|
||||||
{
|
{
|
||||||
$directives = [];
|
$directives = [];
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class ContentSecurityPolicyHandler
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function authorizesInline(array $directivesSet, $type)
|
private function authorizesInline(array $directivesSet, string $type)
|
||||||
{
|
{
|
||||||
if (isset($directivesSet[$type])) {
|
if (isset($directivesSet[$type])) {
|
||||||
$directives = $directivesSet[$type];
|
$directives = $directivesSet[$type];
|
||||||
|
@ -42,14 +42,11 @@ class TemplateManager
|
|||||||
/**
|
/**
|
||||||
* Gets the template name for a given panel.
|
* Gets the template name for a given panel.
|
||||||
*
|
*
|
||||||
* @param Profile $profile
|
|
||||||
* @param string $panel
|
|
||||||
*
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function getName(Profile $profile, $panel)
|
public function getName(Profile $profile, string $panel)
|
||||||
{
|
{
|
||||||
$templates = $this->getNames($profile);
|
$templates = $this->getNames($profile);
|
||||||
|
|
||||||
@ -97,7 +94,7 @@ class TemplateManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// to be removed when the minimum required version of Twig is >= 2.0
|
// to be removed when the minimum required version of Twig is >= 2.0
|
||||||
protected function templateExists($template)
|
protected function templateExists(string $template)
|
||||||
{
|
{
|
||||||
$loader = $this->twig->getLoader();
|
$loader = $this->twig->getLoader();
|
||||||
if ($loader instanceof ExistsLoaderInterface) {
|
if ($loader instanceof ExistsLoaderInterface) {
|
||||||
|
@ -69,7 +69,7 @@ class WebProfilerExtension extends ProfilerExtension
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dumpData(Environment $env, Data $data, $maxDepth = 0)
|
public function dumpData(Environment $env, Data $data, int $maxDepth = 0)
|
||||||
{
|
{
|
||||||
$this->dumper->setCharset($env->getCharset());
|
$this->dumper->setCharset($env->getCharset());
|
||||||
$this->dumper->dump($data, null, [
|
$this->dumper->dump($data, null, [
|
||||||
@ -83,7 +83,7 @@ class WebProfilerExtension extends ProfilerExtension
|
|||||||
return str_replace("\n</pre", '</pre', rtrim($dump));
|
return str_replace("\n</pre", '</pre', rtrim($dump));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dumpLog(Environment $env, $message, Data $context = null)
|
public function dumpLog(Environment $env, string $message, Data $context = null)
|
||||||
{
|
{
|
||||||
$message = twig_escape_filter($env, $message);
|
$message = twig_escape_filter($env, $message);
|
||||||
$message = preg_replace('/"(.*?)"/', '"<b>$1</b>"', $message);
|
$message = preg_replace('/"(.*?)"/', '"<b>$1</b>"', $message);
|
||||||
|
Reference in New Issue
Block a user