Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6bae9bc

Browse filesBrowse files
andreianicolas-grekas
authored andcommitted
[Security][Http] Add type-hints
1 parent f6c5848 commit 6bae9bc
Copy full SHA for 6bae9bc

8 files changed

+15
-40
lines changed

‎src/Symfony/Component/Security/Http/AccessMap.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/AccessMap.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AccessMap implements AccessMapInterface
2828
* @param array $attributes An array of attributes to pass to the access decision manager (like roles)
2929
* @param string|null $channel The channel to enforce (http, https, or null)
3030
*/
31-
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], $channel = null)
31+
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], string $channel = null)
3232
{
3333
$this->map[] = [$requestMatcher, $attributes, $channel];
3434
}

‎src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authentication/AuthenticationUtils.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ public function __construct(RequestStack $requestStack)
3131
}
3232

3333
/**
34-
* @param bool $clearSession
35-
*
3634
* @return AuthenticationException|null
3735
*/
38-
public function getLastAuthenticationError($clearSession = true)
36+
public function getLastAuthenticationError(bool $clearSession = true)
3937
{
4038
$request = $this->getRequest();
4139
$authenticationException = null;

‎src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,7 @@ public function getProviderKey()
8181
return $this->providerKey;
8282
}
8383

84-
/**
85-
* Set the provider key.
86-
*
87-
* @param string $providerKey
88-
*/
89-
public function setProviderKey($providerKey)
84+
public function setProviderKey(string $providerKey)
9085
{
9186
$this->providerKey = $providerKey;
9287
}

‎src/Symfony/Component/Security/Http/HttpUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/HttpUtils.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatc
5858
*
5959
* @return RedirectResponse A RedirectResponse instance
6060
*/
61-
public function createRedirectResponse(Request $request, $path, $status = 302)
61+
public function createRedirectResponse(Request $request, string $path, int $status = 302)
6262
{
6363
if (null !== $this->secureDomainRegexp && 'https' === $this->urlMatcher->getContext()->getScheme() && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path, $host) && !preg_match(sprintf($this->secureDomainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
6464
$path = '/';
@@ -77,7 +77,7 @@ public function createRedirectResponse(Request $request, $path, $status = 302)
7777
*
7878
* @return Request A Request instance
7979
*/
80-
public function createRequest(Request $request, $path)
80+
public function createRequest(Request $request, string $path)
8181
{
8282
$newRequest = Request::create($this->generateUri($request, $path), 'get', [], $request->cookies->all(), [], $request->server->all());
8383

@@ -115,7 +115,7 @@ public function createRequest(Request $request, $path)
115115
*
116116
* @return bool true if the path is the same as the one from the Request, false otherwise
117117
*/
118-
public function checkRequestPath(Request $request, $path)
118+
public function checkRequestPath(Request $request, string $path)
119119
{
120120
if ('/' !== $path[0]) {
121121
try {
@@ -146,7 +146,7 @@ public function checkRequestPath(Request $request, $path)
146146
*
147147
* @throws \LogicException
148148
*/
149-
public function generateUri(Request $request, $path)
149+
public function generateUri(Request $request, string $path)
150150
{
151151
if (0 === strpos($path, 'http') || !$path) {
152152
return $path;

‎src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php
+3-11Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,24 @@ public function registerListener($key, $logoutPath, $csrfTokenId, $csrfParameter
5555
/**
5656
* Generates the absolute logout path for the firewall.
5757
*
58-
* @param string|null $key The firewall key or null to use the current firewall key
59-
*
6058
* @return string The logout path
6159
*/
62-
public function getLogoutPath($key = null)
60+
public function getLogoutPath(string $key = null)
6361
{
6462
return $this->generateLogoutUrl($key, UrlGeneratorInterface::ABSOLUTE_PATH);
6563
}
6664

6765
/**
6866
* Generates the absolute logout URL for the firewall.
6967
*
70-
* @param string|null $key The firewall key or null to use the current firewall key
71-
*
7268
* @return string The logout URL
7369
*/
74-
public function getLogoutUrl($key = null)
70+
public function getLogoutUrl(string $key = null)
7571
{
7672
return $this->generateLogoutUrl($key, UrlGeneratorInterface::ABSOLUTE_URL);
7773
}
7874

79-
/**
80-
* @param string|null $key The current firewall key
81-
* @param string|null $context The current firewall context
82-
*/
83-
public function setCurrentFirewall($key, $context = null)
75+
public function setCurrentFirewall(?string $key, string $context = null)
8476
{
8577
$this->currentFirewall = [$key, $context];
8678
}

‎src/Symfony/Component/Security/Http/ParameterBagUtils.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/ParameterBagUtils.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ final class ParameterBagUtils
2929
*
3030
* Paths like foo[bar] will be evaluated to find deeper items in nested data structures.
3131
*
32-
* @param string $path The key
33-
*
3432
* @return mixed
3533
*
3634
* @throws InvalidArgumentException when the given path is malformed
3735
*/
38-
public static function getParameterBagValue(ParameterBag $parameters, $path)
36+
public static function getParameterBagValue(ParameterBag $parameters, string $path)
3937
{
4038
if (false === $pos = strpos($path, '[')) {
4139
return $parameters->get($path);
@@ -63,13 +61,11 @@ public static function getParameterBagValue(ParameterBag $parameters, $path)
6361
*
6462
* Paths like foo[bar] will be evaluated to find deeper items in nested data structures.
6563
*
66-
* @param string $path The key
67-
*
6864
* @return mixed
6965
*
7066
* @throws InvalidArgumentException when the given path is malformed
7167
*/
72-
public static function getRequestParameterValue(Request $request, $path)
68+
public static function getRequestParameterValue(Request $request, string $path)
7369
{
7470
if (false === $pos = strpos($path, '[')) {
7571
return $request->get($path);

‎src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,9 @@ final protected function getUserProvider($class)
235235
/**
236236
* Decodes the raw cookie value.
237237
*
238-
* @param string $rawCookie
239-
*
240238
* @return array
241239
*/
242-
protected function decodeCookie($rawCookie)
240+
protected function decodeCookie(string $rawCookie)
243241
{
244242
return explode(self::COOKIE_DELIMITER, base64_decode($rawCookie));
245243
}

‎src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ protected function onLoginSuccess(Request $request, Response $response, TokenInt
9191
/**
9292
* Generates the cookie value.
9393
*
94-
* @param string $class
95-
* @param string $username The username
9694
* @param int $expires The Unix timestamp when the cookie expires
9795
* @param string $password The encoded password
9896
*
9997
* @return string
10098
*/
101-
protected function generateCookieValue($class, $username, $expires, $password)
99+
protected function generateCookieValue(string $class, string $username, int $expires, string $password)
102100
{
103101
// $username is encoded because it might contain COOKIE_DELIMITER,
104102
// we assume other values don't
@@ -113,14 +111,12 @@ protected function generateCookieValue($class, $username, $expires, $password)
113111
/**
114112
* Generates a hash for the cookie to ensure it is not being tampered with.
115113
*
116-
* @param string $class
117-
* @param string $username The username
118114
* @param int $expires The Unix timestamp when the cookie expires
119115
* @param string $password The encoded password
120116
*
121117
* @return string
122118
*/
123-
protected function generateCookieHash($class, $username, $expires, $password)
119+
protected function generateCookieHash(string $class, string $username, int $expires, string $password)
124120
{
125121
return hash_hmac('sha256', $class.self::COOKIE_DELIMITER.$username.self::COOKIE_DELIMITER.$expires.self::COOKIE_DELIMITER.$password, $this->getSecret());
126122
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.