8000 [5.0] [WebProfilerBundle] Add parameter type-hints where possible by Matts · Pull Request #32216 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[5.0] [WebProfilerBundle] Add parameter type-hints where possible #32216

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

Merged
merged 1 commit into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[WebProfilerBundle] Use scalar type-hints where possible
  • Loading branch information
Matthew Smeets committed Jun 27, 2019
commit 8f33c6f1f3ffca1c9d0415d72cea8519b58891f5
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ public function __construct(Profiler $profiler = null, Environment $twig, bool $
/**
* Renders the exception panel for the given token.
*
* @param string $token The profiler token
*
* @return Response A Response instance
*
* @throws NotFoundHttpException
*/
public function showAction($token)
public function showAction(string $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
Expand Down Expand Up @@ -83,13 +81,11 @@ public function showAction($token)
/**
* Renders the exception panel stylesheet for the given token.
*
* @param string $token The profiler token
*
* @return Response A Response instance
*
* @throws NotFoundHttpException
*/
public function cssAction($token)
public function cssAction(string $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
Expand All @@ -115,7 +111,7 @@ protected function getTemplate()
}

// 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();
if ($loader instanceof ExistsLoaderInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ public function homeAction()
/**
* 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
*
* @throws NotFoundHttpException
*/
public function panelAction(Request $request, $token)
public function panelAction(Request $request, string $token)
{
$this->denyAccessIfProfilerDisabled();

Expand Down Expand Up @@ -108,14 +105,11 @@ public function panelAction(Request $request, $token)
/**
* Renders the Web Debug Toolbar.
*
* @param Request $request The current HTTP Request
* @param string $token The profiler token
*
* @return Response A Response instance
*
* @throws NotFoundHttpException
*/
public function toolbarAction(Request $request, $token)
public function toolbarAction(Request $request, string $token = null)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
Expand Down Expand Up @@ -210,14 +204,11 @@ public function searchBarAction(Request $request)
/**
* Renders the search results.
*
* @param Request $request The current HTTP Request
* @param string $token The token
*
* @return Response A Response instance
*
* @throws NotFoundHttpException
*/
public function searchResultsAction(Request $request, $token)
public function searchResultsAction(Request $request, string $token)
{
$this->denyAccessIfProfilerDisabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ public function __construct(Profiler $profiler = null, Environment $twig, UrlMat
/**
* Renders the profiler panel for the given token.
*
* @param string $token The profiler token
*
* @return Response A Response instance
*
* @throws NotFoundHttpException
*/
public function panelAction($token)
public function panelAction(string $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function generateCspHeader(array $directives)
*
* @return array The directive set
*/
private function parseDirectives($header)
private function parseDirectives(string $header)
{
$directives = [];

Expand All @@ -214,7 +214,7 @@ private function parseDirectives($header)
*
* @return bool
*/
private function authorizesInline(array $directivesSet, $type)
private function authorizesInline(array $directivesSet, string $type)
{
if (isset($directivesSet[$type])) {
$directives = $directivesSet[$type];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ public function __construct(Profiler $profiler, Environment $twig, array $templa
/**
* Gets the template name for a given panel.
*
* @param Profile $profile
* @param string $panel
*
* @return mixed
*
* @throws NotFoundHttpException
*/
public function getName(Profile $profile, $panel)
public function getName(Profile $profile, string $panel)
{
$templates = $this->getNames($profile);

Expand Down Expand Up @@ -97,7 +94,7 @@ public function getNames(Profile $profile)
}

// 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();
if ($loader instanceof ExistsLoaderInterface) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getFunctions()
];
}

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->dump($data, null, [
Expand All @@ -83,7 +83,7 @@ public function dumpData(Environment $env, Data $data, $maxDepth = 0)
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 = preg_replace('/&quot;(.*?)&quot;/', '&quot;<b>$1</b>&quot;', $message);
Expand Down
0