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 fe406fe

Browse filesBrowse files
andreiaRobin Chalas
authored and
Robin Chalas
committed
[Security][Http] Add type-hints
1 parent eca1f03 commit fe406fe
Copy full SHA for fe406fe

8 files changed

+16
-44
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
@@ -29,7 +29,7 @@ class AccessMap implements AccessMapInterface
2929
* @param array $attributes An array of attributes to pass to the access decision manager (like roles)
3030
* @param string|null $channel The channel to enforce (http, https, or null)
3131
*/
32-
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], $channel = null)
32+
public function add(RequestMatcherInterface $requestMatcher, array $attributes = [], string $channel = null)
3333
{
3434
$this->map[] = [$requestMatcher, $attributes, $channel];
3535
}

‎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
@@ -82,12 +82,7 @@ public function getProviderKey()
8282
return $this->providerKey;
8383
}
8484

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/HttpUtils.php
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator = null, $urlMatc
6060
*
6161
* @return RedirectResponse A RedirectResponse instance
6262
*/
63-
public function createRedirectResponse(Request $request, $path, $status = 302)
63+
public function createRedirectResponse(Request $request, string $path, int $status = 302)
6464
{
6565
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])) {
6666
$path = '/';
@@ -80,7 +80,7 @@ public function createRedirectResponse(Request $request, $path, $status = 302)
8080
*
8181
* @return Request A Request instance
8282
*/
83-
public function createRequest(Request $request, $path)
83+
public function createRequest(Request $request, string $path)
8484
{
8585
$newRequest = Request::create($this->generateUri($request, $path), 'get', [], $request->cookies->all(), [], $request->server->all());
8686

@@ -119,7 +119,7 @@ public function createRequest(Request $request, $path)
119119
*
120120
* @return bool true if the path is the same as the one from the Request, false otherwise
121121
*/
122-
public function checkRequestPath(Request $request, $path)
122+
public function checkRequestPath(Request $request, string $path)
123123
{
124124
if ('/' !== $path[0]) {
125125
try {
@@ -144,14 +144,13 @@ public function checkRequestPath(Request $request, $path)
144144
/**
145145
* Generates a URI, based on the given path or absolute URL.
146146
*
147-
* @param Request $request A Request instance
148-
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
147+
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
149148
*
150149
* @return string An absolute URL
151150
*
152151
* @throws \LogicException
153152
*/
154-
public function generateUri($request, $path)
153+
public function generateUri(Request $request, string $path)
155154
{
156155
if (0 === strpos($path, 'http') || !$path) {
157156
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
@@ -56,32 +56,24 @@ public function registerListener($key, $logoutPath, $csrfTokenId, $csrfParameter
5656
/**
5757
* Generates the absolute logout path for the firewall.
5858
*
59-
* @param string|null $key The firewall key or null to use the current firewall key
60-
*
6159
* @return string The logout path
6260
*/
63-
public function getLogoutPath($key = null)
61+
public function getLogoutPath(?string $key = null)
6462
{
6563
return $this->generateLogoutUrl($key, UrlGeneratorInterface::ABSOLUTE_PATH);
6664
}
6765

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

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/ParameterBagUtils.php
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +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 ParameterBag $parameters The parameter bag
33-
* @param string $path The key
34-
*
3532
* @return mixed
3633
*
3734
* @throws InvalidArgumentException when the given path is malformed
3835
*/
39-
public static function getParameterBagValue(ParameterBag $parameters, $path)
36+
public static function getParameterBagValue(ParameterBag $parameters, string $path)
4037
{
4138
if (false === $pos = strpos($path, '[')) {
4239
return $parameters->get($path);
@@ -64,14 +61,11 @@ public static function getParameterBagValue(ParameterBag $parameters, $path)
6461
*
6562
* Paths like foo[bar] will be evaluated to find deeper items in nested data structures.
6663
*
67-
* @param Request $request The request
68-
* @param string $path The key
69-
*
7064
* @return mixed
7165
*
7266
* @throws InvalidArgumentException when the given path is malformed
7367
*/
74-
public static function getRequestParameterValue(Request $request, $path)
68+
public static function getRequestParameterValue(Request $request, string $path)
7569
{
7670
if (false === $pos = strpos($path, '[')) {
7771
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.