diff --git a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php index d8ecf9f3ea4c..552a4def37f7 100644 --- a/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php +++ b/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php @@ -138,11 +138,9 @@ public function hasAttribute(string $name) /** * Returns an attribute by its name. * - * @param mixed $default - * * @return mixed */ - public function getAttribute(string $name, $default = null) + public function getAttribute(string $name, mixed $default = null) { return $this->attributes[$name] ?? $default; } diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 908c16a0908e..cea0463981e5 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -44,7 +44,7 @@ class BinaryFileResponse extends Response * @param bool $autoEtag Whether the ETag header should be automatically set * @param bool $autoLastModified Whether the Last-Modified header should be automatically set */ - public function __construct($file, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true) + public function __construct(\SplFileInfo|string $file, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true) { parent::__construct(null, $status, $headers); @@ -58,13 +58,11 @@ public function __construct($file, int $status = 200, array $headers = [], bool /** * Sets the file to stream. * - * @param \SplFileInfo|string $file The file to stream - * * @return $this * * @throws FileException */ - public function setFile($file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true) + public function setFile(\SplFileInfo|string $file, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true) { if (!$file instanceof File) { if ($file instanceof \SplFileInfo) { diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index 03a49155ea20..f210eb5308eb 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -71,7 +71,7 @@ public static function fromString(string $cookie, bool $decode = false) return new static($name, $value, $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']); } - public static function create(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX): self + public static function create(string $name, string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = self::SAMESITE_LAX): self { return new self($name, $value, $expire, $path, $domain, $secure, $httpOnly, $raw, $sameSite); } @@ -89,7 +89,7 @@ public static function create(string $name, string $value = null, $expire = 0, ? * * @throws \InvalidArgumentException */ - public function __construct(string $name, string $value = null, $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = 'lax') + public function __construct(string $name, string $value = null, int|string|\DateTimeInterface $expire = 0, ?string $path = '/', string $domain = null, bool $secure = null, bool $httpOnly = true, bool $raw = false, ?string $sameSite = 'lax') { // from PHP source code if ($raw && false !== strpbrk($name, self::$reservedCharsList)) { @@ -140,11 +140,9 @@ public function withDomain(?string $domain): self /** * Creates a cookie copy with a new time the cookie expires. * - * @param int|string|\DateTimeInterface $expire - * * @return static */ - public function withExpires($expire = 0): self + public function withExpires(int|string|\DateTimeInterface $expire = 0): self { $cookie = clone $this; $cookie->expire = self::expiresTimestamp($expire); @@ -154,12 +152,8 @@ public function withExpires($expire = 0): self /** * Converts expires formats to a unix timestamp. - * - * @param int|string|\DateTimeInterface $expire - * - * @return int */ - private static function expiresTimestamp($expire = 0) + private static function expiresTimestamp(int|string|\DateTimeInterface $expire = 0): int { // convert expiration time to a Unix timestamp if ($expire instanceof \DateTimeInterface) { diff --git a/src/Symfony/Component/HttpFoundation/Exception/SessionNotFoundException.php b/src/Symfony/Component/HttpFoundation/Exception/SessionNotFoundException.php index eb7acbbafc38..9c719aa041be 100644 --- a/src/Symfony/Component/HttpFoundation/Exception/SessionNotFoundException.php +++ b/src/Symfony/Component/HttpFoundation/Exception/SessionNotFoundException.php @@ -20,7 +20,7 @@ */ class SessionNotFoundException extends \LogicException implements RequestExceptionInterface { - public function __construct($message = 'There is currently no session available.', $code = 0, \Throwable $previous = null) + public function __construct(string $message = 'There is currently no session available.', int $code = 0, \Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php index 26bed7d3713e..8451f9013608 100644 --- a/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php @@ -11,6 +11,7 @@ namespace Symfony\Component\HttpFoundation; +use Symfony\Component\ExpressionLanguage\Expression; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; /** @@ -23,7 +24,7 @@ class ExpressionRequestMatcher extends RequestMatcher private $language; private $expression; - public function setExpression(ExpressionLanguage $language, $expression) + public function setExpression(ExpressionLanguage $language, Expression|string $expression) { $this->language = $language; $this->expression = $expression; diff --git a/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php b/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php index 8533f99a8c9a..905bd5962881 100644 --- a/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php +++ b/src/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php @@ -13,7 +13,7 @@ class UnexpectedTypeException extends FileException { - public function __construct($value, string $expectedType) + public function __construct(mixed $value, string $expectedType) { parent::__construct(sprintf('Expected argument of type %s, %s given', $expectedType, get_debug_type($value))); } diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 1adc84156a3a..8aa2f03a33f1 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -231,7 +231,7 @@ public static function getMaxFilesize() * * @return int|float Returns float if size > PHP_INT_MAX */ - private static function parseFilesize($size) + private static function parseFilesize(string $size) { if ('' === $size) { return 0; diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index 14622b57a0f8..598a5fd04394 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -43,7 +43,7 @@ public function replace(array $files = []) /** * {@inheritdoc} */ - public function set(string $key, $value) + public function set(string $key, mixed $value) { if (!\is_array($value) && !$value instanceof UploadedFile) { throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.'); @@ -65,32 +65,28 @@ public function add(array $files = []) /** * Converts uploaded files to UploadedFile instances. * - * @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information - * * @return UploadedFile[]|UploadedFile|null A (multi-dimensional) array of UploadedFile instances */ - protected function convertFileInformation($file) + protected function convertFileInformation(array|UploadedFile $file) { if ($file instanceof UploadedFile) { return $file; } - if (\is_array($file)) { - $file = $this->fixPhpFilesArray($file); - $keys = array_keys($file); - sort($keys); - - if (self::FILE_KEYS == $keys) { - if (\UPLOAD_ERR_NO_FILE == $file['error']) { - $file = null; - } else { - $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); - } + $file = $this->fixPhpFilesArray($file); + $keys = array_keys($file); + sort($keys); + + if (self::FILE_KEYS == $keys) { + if (\UPLOAD_ERR_NO_FILE == $file['error']) { + $file = null; } else { - $file = array_map([$this, 'convertFileInformation'], $file); - if (array_keys($keys) === $keys) { - $file = array_filter($file); - } + $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false); + } + } else { + $file = array_map(function ($v) { return $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v; }, $file); + if (array_keys($keys) === $keys) { + $file = array_filter($file); } } @@ -109,11 +105,9 @@ protected function convertFileInformation($file) * It's safe to pass an already converted array, in which case this method * just returns the original array unmodified. * - * @param array $data - * * @return array */ - protected function fixPhpFilesArray($data) + protected function fixPhpFilesArray(array $data) { $keys = array_keys($data); sort($keys); diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index 20ef039efa80..a0938429f7f9 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -121,10 +121,10 @@ public function get(string $key, string $default = null) /** * Sets a header by name. * - * @param string|string[] $values The value or an array of values - * @param bool $replace Whether to replace the actual value or not (true by default) + * @param string|string[]|null $values The value or an array of values + * @param bool $replace Whether to replace the actual value or not (true by default) */ - public function set(string $key, $values, bool $replace = true) + public function set(string $key, string|array|null $values, bool $replace = true) { $key = strtr($key, self::UPPER, self::LOWER); @@ -186,7 +186,7 @@ public function remove(string $key) /** * Returns the HTTP header value converted to a date. * - * @return \DateTimeInterface|null The parsed DateTime or the default value if the header does not exist + * @return \DateTime|null The parsed DateTime or the default value if the header does not exist * * @throws \RuntimeException When the HTTP header is not parseable */ @@ -205,10 +205,8 @@ public function getDate(string $key, \DateTime $default = null) /** * Adds a custom Cache-Control directive. - * - * @param mixed $value The Cache-Control directive value */ - public function addCacheControlDirective(string $key, $value = true) + public function addCacheControlDirective(string $key, bool|string $value = true) { $this->cacheControl[$key] = $value; @@ -228,11 +226,11 @@ public function hasCacheControlDirective(string $key) /** * Returns a Cache-Control directive value by name. * - * @return mixed The directive value if defined, null otherwise + * @return bool|string|null The directive value if defined, null otherwise */ public function getCacheControlDirective(string $key) { - return \array_key_exists($key, $this->cacheControl) ? $this->cacheControl[$key] : null; + return $this->cacheControl[$key] ?? null; } /** diff --git a/src/Symfony/Component/HttpFoundation/InputBag.php b/src/Symfony/Component/HttpFoundation/InputBag.php index 6bec212c4590..3b96e4f5d22a 100644 --- a/src/Symfony/Component/HttpFoundation/InputBag.php +++ b/src/Symfony/Component/HttpFoundation/InputBag.php @@ -24,10 +24,8 @@ final class InputBag extends ParameterBag * Returns a scalar input value by name. * * @param string|int|float|bool|null $default The default value if the input key does not exist - * - * @return string|int|float|bool|null */ - public function get(string $key, $default = null) + public function get(string $key, mixed $default = null): string|int|float|bool|null { if (null !== $default && !is_scalar($default) && !$default instanceof \Stringable) { throw new \InvalidArgumentException(sprintf('Excepted a scalar value as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($default))); @@ -74,7 +72,7 @@ public function add(array $inputs = []) * * @param string|int|float|bool|array|null $value */ - public function set(string $key, $value) + public function set(string $key, mixed $value) { if (null !== $value && !is_scalar($value) && !\is_array($value) && !$value instanceof \Stringable) { throw new \InvalidArgumentException(sprintf('Excepted a scalar, or an array as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($value))); @@ -86,7 +84,7 @@ public function set(string $key, $value) /** * {@inheritdoc} */ - public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []) + public function filter(string $key, mixed $default = null, int $filter = \FILTER_DEFAULT, mixed $options = []) { $value = $this->has($key) ? $this->all()[$key] : $default; diff --git a/src/Symfony/Component/HttpFoundation/IpUtils.php b/src/Symfony/Component/HttpFoundation/IpUtils.php index 27fe725929f7..70738c8d5ed6 100644 --- a/src/Symfony/Component/HttpFoundation/IpUtils.php +++ b/src/Symfony/Component/HttpFoundation/IpUtils.php @@ -34,7 +34,7 @@ private function __construct() * * @return bool Whether the IP is valid */ - public static function checkIp(?string $requestIp, $ips) + public static function checkIp(?string $requestIp, string|array $ips) { if (!\is_array($ips)) { $ips = [$ips]; diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index d1565190e4e6..292e3937f44b 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -34,12 +34,9 @@ class JsonResponse extends Response protected $encodingOptions = self::DEFAULT_ENCODING_OPTIONS; /** - * @param mixed $data The response data - * @param int $status The response status code - * @param array $headers An array of response headers - * @param bool $json If the data is already a JSON string + * @param bool $json If the data is already a JSON string */ - public function __construct($data = null, int $status = 200, array $headers = [], bool $json = false) + public function __construct(mixed $data = null, int $status = 200, array $headers = [], bool $json = false) { parent::__construct('', $status, $headers); @@ -123,13 +120,11 @@ public function setJson(string $json) /** * Sets the data to be sent as JSON. * - * @param mixed $data - * * @return $this * * @throws \InvalidArgumentException */ - public function setData($data = []) + public function setData(mixed $data = []) { try { $data = json_encode($data, $this->encodingOptions); diff --git a/src/Symfony/Component/HttpFoundation/ParameterBag.php b/src/Symfony/Component/HttpFoundation/ParameterBag.php index 2f6db742364d..6cbd945c2dd5 100644 --- a/src/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/src/Symfony/Component/HttpFoundation/ParameterBag.php @@ -79,23 +79,14 @@ public function add(array $parameters = []) } /** - * Returns a parameter by name. - * - * @param mixed $default The default value if the parameter key does not exist - * * @return mixed */ - public function get(string $key, $default = null) + public function get(string $key, mixed $default = null) { return \array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default; } - /** - * Sets a parameter by name. - * - * @param mixed $value The value - */ - public function set(string $key, $value) + public function set(string $key, mixed $value) { $this->parameters[$key] = $value; } @@ -172,15 +163,13 @@ public function getBoolean(string $key, bool $default = false) /** * Filter key. * - * @param mixed $default Default = null - * @param int $filter FILTER_* constant - * @param mixed $options Filter options + * @param int $filter FILTER_* constant * * @see https://php.net/filter-var * * @return mixed */ - public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []) + public function filter(string $key, mixed $default = null, int $filter = \FILTER_DEFAULT, mixed $options = []) { $value = $this->get($key, $default); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 0e86148db82b..2e4954a967f7 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -693,11 +693,9 @@ public static function getHttpMethodParameterOverride() * * Order of precedence: PATH (routing placeholders or custom attributes), GET, POST * - * @param mixed $default The default value if the parameter key does not exist - * * @return mixed */ - public function get(string $key, $default = null) + public function get(string $key, mixed $default = null) { if ($this !== $result = $this->attributes->get($key, $this)) { return $result; @@ -1351,7 +1349,7 @@ public function getFormat(?string $mimeType) * * @param string|array $mimeTypes The associated mime types (the preferred one must be the first as it will be used as the content type) */ - public function setFormat(?string $format, $mimeTypes) + public function setFormat(?string $format, string|array $mimeTypes) { if (null === static::$formats) { static::initializeFormats(); diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index f02db30b1d95..1e686b1e1327 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -58,7 +58,7 @@ class RequestMatcher implements RequestMatcherInterface * @param string|string[]|null $ips * @param string|string[]|null $schemes */ - public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null) + public function __construct(string $path = null, string $host = null, string|array|null $methods = null, string|array|null $ips = null, array $attributes = [], string|array|null $schemes = null, int $port = null) { $this->matchPath($path); $this->matchHost($host); @@ -77,7 +77,7 @@ public function __construct(string $path = null, string $host = null, $methods = * * @param string|string[]|null $scheme An HTTP scheme or an array of HTTP schemes */ - public function matchScheme($scheme) + public function matchScheme(string|array|null $scheme) { $this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : []; } @@ -123,7 +123,7 @@ public function matchIp(string $ip) * * @param string|string[]|null $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 */ - public function matchIps($ips) + public function matchIps(string|array|null $ips) { $ips = null !== $ips ? (array) $ips : []; @@ -137,7 +137,7 @@ public function matchIps($ips) * * @param string|string[]|null $method An HTTP method or an array of HTTP methods */ - public function matchMethod($method) + public function matchMethod(string|array|null $method) { $this->methods = null !== $method ? array_map('strtoupper', (array) $method) : []; } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 4d47dfd05145..7c129f4f573a 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -441,7 +441,7 @@ public function getProtocolVersion(): string * * @final */ - public function setStatusCode(int $code, $text = null): object + public function setStatusCode(int $code, string $text = null): object { $this->statusCode = $code; if ($this->isInvalid()) { @@ -1034,14 +1034,13 @@ public function getVary(): array /** * Sets the Vary header. * - * @param string|array $headers - * @param bool $replace Whether to replace the actual value or not (true by default) + * @param bool $replace Whether to replace the actual value or not (true by default) * * @return $this * * @final */ - public function setVary($headers, bool $replace = true): object + public function setVary(string|array $headers, bool $replace = true): object { $this->headers->set('Vary', $headers, $replace); diff --git a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php index 780a5df6cd99..f8ff3ef7de0b 100644 --- a/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php @@ -108,7 +108,7 @@ public function all(string $key = null) /** * {@inheritdoc} */ - public function set(string $key, $values, bool $replace = true) + public function set(string $key, string|array|null $values, bool $replace = true) { $uniqueKey = strtr($key, self::UPPER, self::LOWER); diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php index aad6b610e7bb..54feb960d441 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php @@ -69,7 +69,7 @@ public function has(string $name) /** * {@inheritdoc} */ - public function get(string $name, $default = null) + public function get(string $name, mixed $default = null) { return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; } @@ -77,7 +77,7 @@ public function get(string $name, $default = null) /** * {@inheritdoc} */ - public function set(string $name, $value) + public function set(string $name, mixed $value) { $this->attributes[$name] = $value; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php index 7017b717e406..c94d65fed4ff 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php @@ -30,18 +30,14 @@ public function has(string $name); /** * Returns an attribute. * - * @param mixed $default The default value if not found - * * @return mixed */ - public function get(string $name, $default = null); + public function get(string $name, mixed $default = null); /** * Sets an attribute. - * - * @param mixed $value */ - public function set(string $name, $value); + public function set(string $name, mixed $value); /** * Returns attributes. diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php index 2707d64ec713..a860246148f5 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php @@ -60,7 +60,7 @@ public function initialize(array &$flashes) /** * {@inheritdoc} */ - public function add(string $type, $message) + public function add(string $type, mixed $message) { $this->flashes['new'][$type][] = $message; } @@ -122,7 +122,7 @@ public function setAll(array $messages) /** * {@inheritdoc} */ - public function set(string $type, $messages) + public function set(string $type, string|array $messages) { $this->flashes['new'][$type] = (array) $messages; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index 88df7508ac68..c01e61963d70 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -54,7 +54,7 @@ public function initialize(array &$flashes) /** * {@inheritdoc} */ - public function add(string $type, $message) + public function add(string $type, mixed $message) { $this->flashes[$type][] = $message; } @@ -105,7 +105,7 @@ public function all() /** * {@inheritdoc} */ - public function set(string $type, $messages) + public function set(string $type, string|array $messages) { $this->flashes[$type] = (array) $messages; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php index 8713e71d0f62..e1144cac839d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php @@ -22,17 +22,13 @@ interface FlashBagInterface extends SessionBagInterface { /** * Adds a flash message for the given type. - * - * @param mixed $message */ - public function add(string $type, $message); + public function add(string $type, mixed $message); /** * Registers one or more messages for a given type. - * - * @param string|array $messages */ - public function set(string $type, $messages); + public function set(string $type, string|array $messages); /** * Gets flash messages for a given type. diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index e4e25356376e..649850760af1 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -70,7 +70,7 @@ public function has(string $name) /** * {@inheritdoc} */ - public function get(string $name, $default = null) + public function get(string $name, mixed $default = null) { return $this->getAttributeBag()->get($name, $default); } @@ -78,7 +78,7 @@ public function get(string $name, $default = null) /** * {@inheritdoc} */ - public function set(string $name, $value) + public function set(string $name, mixed $value) { $this->getAttributeBag()->set($name, $value); } diff --git a/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php b/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php index b2f09fd0dc71..7c587efb34af 100644 --- a/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php +++ b/src/Symfony/Component/HttpFoundation/Session/SessionInterface.php @@ -101,18 +101,14 @@ public function has(string $name); /** * Returns an attribute. * - * @param mixed $default The default value if not found - * * @return mixed */ - public function get(string $name, $default = null); + public function get(string $name, mixed $default = null); /** * Sets an attribute. - * - * @param mixed $value */ - public function set(string $name, $value); + public function set(string $name, mixed $value); /** * Returns attributes. diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php index eaebd31c651d..c2a5aa9cf314 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php @@ -32,7 +32,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess * @return bool */ #[\ReturnTypeWillChange] - public function open($savePath, $sessionName) + public function open(string $savePath, string $sessionName) { $this->sessionName = $sessionName; if (!headers_sent() && !ini_get('session.cache_limiter') && '0' !== ini_get('session.cache_limiter')) { @@ -61,7 +61,7 @@ abstract protected function doDestroy(string $sessionId); * @return bool */ #[\ReturnTypeWillChange] - public function validateId($sessionId) + public function validateId(string $sessionId) { $this->prefetchData = $this->read($sessionId); $this->prefetchId = $sessionId; @@ -73,7 +73,7 @@ public function validateId($sessionId) * @return string */ #[\ReturnTypeWillChange] - public function read($sessionId) + public function read(string $sessionId) { if (null !== $this->prefetchId) { $prefetchId = $this->prefetchId; @@ -97,7 +97,7 @@ public function read($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function write($sessionId, $data) + public function write(string $sessionId, string $data) { if (null === $this->igbinaryEmptyData) { // see https://github.com/igbinary/igbinary/issues/146 @@ -115,7 +115,7 @@ public function write($sessionId, $data) * @return bool */ #[\ReturnTypeWillChange] - public function destroy($sessionId) + public function destroy(string $sessionId) { if (!headers_sent() && filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) { if (!$this->sessionName) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php index e1cad6a9454e..939495104eb5 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MarshallingSessionHandler.php @@ -30,7 +30,7 @@ public function __construct(AbstractSessionHandler $handler, MarshallerInterface /** * @return bool */ - public function open($savePath, $name) + public function open(string $savePath, string $name) { return $this->handler->open($savePath, $name); } @@ -46,7 +46,7 @@ public function close() /** * @return bool */ - public function destroy($sessionId) + public function destroy(string $sessionId) { return $this->handler->destroy($sessionId); } @@ -54,7 +54,7 @@ public function destroy($sessionId) /** * @return bool */ - public function gc($maxlifetime) + public function gc(int $maxlifetime) { return $this->handler->gc($maxlifetime); } @@ -62,7 +62,7 @@ public function gc($maxlifetime) /** * @return string */ - public function read($sessionId) + public function read(string $sessionId) { return $this->marshaller->unmarshall($this->handler->read($sessionId)); } @@ -70,7 +70,7 @@ public function read($sessionId) /** * @return bool */ - public function write($sessionId, $data) + public function write(string $sessionId, string $data) { $failed = []; $marshalledData = $this->marshaller->marshall(['data' => $data], $failed); @@ -85,7 +85,7 @@ public function write($sessionId, $data) /** * @return bool */ - public function validateId($sessionId) + public function validateId(string $sessionId) { return $this->handler->validateId($sessionId); } @@ -93,7 +93,7 @@ public function validateId($sessionId) /** * @return bool */ - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { return $this->handler->updateTimestamp($sessionId, $data); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index aeb9df60692d..a3313ac2da44 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -73,7 +73,7 @@ protected function doRead(string $sessionId) /** * @return bool */ - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { $this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl); @@ -101,7 +101,7 @@ protected function doDestroy(string $sessionId) /** * @return bool */ - public function gc($maxlifetime) + public function gc(int $maxlifetime) { // not required here because memcached will auto expire the records anyhow. return true; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php index c3e7ef6e60a3..50997bea4870 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php @@ -54,7 +54,7 @@ public function close() * @return bool */ #[\ReturnTypeWillChange] - public function destroy($sessionId) + public function destroy(string $sessionId) { $result = $this->currentHandler->destroy($sessionId); $this->writeOnlyHandler->destroy($sessionId); @@ -66,7 +66,7 @@ public function destroy($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function gc($maxlifetime) + public function gc(int $maxlifetime) { $result = $this->currentHandler->gc($maxlifetime); $this->writeOnlyHandler->gc($maxlifetime); @@ -78,7 +78,7 @@ public function gc($maxlifetime) * @return bool */ #[\ReturnTypeWillChange] - public function open($savePath, $sessionName) + public function open(string $savePath, string $sessionName) { $result = $this->currentHandler->open($savePath, $sessionName); $this->writeOnlyHandler->open($savePath, $sessionName); @@ -90,7 +90,7 @@ public function open($savePath, $sessionName) * @return string */ #[\ReturnTypeWillChange] - public function read($sessionId) + public function read(string $sessionId) { // No reading from new handler until switch-over return $this->currentHandler->read($sessionId); @@ -100,7 +100,7 @@ public function read($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function write($sessionId, $sessionData) + public function write(string $sessionId, string $sessionData) { $result = $this->currentHandler->write($sessionId, $sessionData); $this->writeOnlyHandler->write($sessionId, $sessionData); @@ -112,7 +112,7 @@ public function write($sessionId, $sessionData) * @return bool */ #[\ReturnTypeWillChange] - public function validateId($sessionId) + public function validateId(string $sessionId) { // No reading from new handler until switch-over return $this->currentHandler->validateId($sessionId); @@ -122,7 +122,7 @@ public function validateId($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function updateTimestamp($sessionId, $sessionData) + public function updateTimestamp(string $sessionId, string $sessionData) { $result = $this->currentHandler->updateTimestamp($sessionId, $sessionData); $this->writeOnlyHandler->updateTimestamp($sessionId, $sessionData); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 9a2d7919af90..e53a52bd70a9 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -102,7 +102,7 @@ protected function doDestroy(string $sessionId) /** * @return bool */ - public function gc($maxlifetime) + public function gc(int $maxlifetime) { $this->getCollection()->deleteMany([ $this->options['expiry_field'] => ['$lt' => new \MongoDB\BSON\UTCDateTime()], @@ -136,7 +136,7 @@ protected function doWrite(string $sessionId, string $data) /** * @return bool */ - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { $expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php index bb182cd1cf60..bae0aeea52ca 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php @@ -31,7 +31,7 @@ public function close() * @return bool */ #[\ReturnTypeWillChange] - public function validateId($sessionId) + public function validateId(string $sessionId) { return true; } @@ -48,7 +48,7 @@ protected function doRead(string $sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { return true; } @@ -73,7 +73,7 @@ protected function doDestroy(string $sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function gc($maxlifetime) + public function gc(int $maxlifetime) { return true; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 02811a6e68b4..84872224ae5d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -170,7 +170,7 @@ class PdoSessionHandler extends AbstractSessionHandler * * @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION */ - public function __construct($pdoOrDsn = null, array $options = []) + public function __construct(\PDO|string|null $pdoOrDsn = null, array $options = []) { if ($pdoOrDsn instanceof \PDO) { if (\PDO::ERRMODE_EXCEPTION !== $pdoOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) { @@ -263,7 +263,7 @@ public function isSessionExpired() * @return bool */ #[\ReturnTypeWillChange] - public function open($savePath, $sessionName) + public function open(string $savePath, string $sessionName) { $this->sessionExpired = false; @@ -278,7 +278,7 @@ public function open($savePath, $sessionName) * @return string */ #[\ReturnTypeWillChange] - public function read($sessionId) + public function read(string $sessionId) { try { return parent::read($sessionId); @@ -293,7 +293,7 @@ public function read($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function gc($maxlifetime) + public function gc(int $maxlifetime) { // We delay gc() to close() so that it is executed outside the transactional and blocking read-write process. // This way, pruning expired sessions does not block them from being started while the current session is used. @@ -373,7 +373,7 @@ protected function doWrite(string $sessionId, string $data) * @return bool */ #[\ReturnTypeWillChange] - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { $expiry = time() + (int) ini_get('session.gc_maxlifetime'); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index 61714f1743cb..f5ffa886b001 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -40,11 +40,9 @@ class RedisSessionHandler extends AbstractSessionHandler * * prefix: The prefix to use for the keys in order to avoid collision on the Redis server * * ttl: The time to live in seconds. * - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis - * * @throws \InvalidArgumentException When unsupported client or options are passed */ - public function __construct($redis, array $options = []) + public function __construct(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis, array $options = []) { if ( !$redis instanceof \Redis && @@ -117,7 +115,7 @@ public function close(): bool /** * {@inheritdoc} */ - public function gc($maxlifetime): bool + public function gc(int $maxlifetime): bool { return true; } @@ -125,7 +123,7 @@ public function gc($maxlifetime): bool /** * @return bool */ - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { return (bool) $this->redis->expire($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime'))); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php index 93e403777aa7..e5a5abfc55c9 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php @@ -21,10 +21,7 @@ */ class SessionHandlerFactory { - /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy|\Memcached|\PDO|string $connection Connection or DSN - */ - public static function createHandler($connection): AbstractSessionHandler + public static function createHandler(object|string $connection): AbstractSessionHandler { if (!\is_string($connection) && !\is_object($connection)) { throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, get_debug_type($connection))); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php index 0461e997e21c..84b7b80c9e48 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php @@ -34,7 +34,7 @@ public function __construct(\SessionHandlerInterface $handler) * @return bool */ #[\ReturnTypeWillChange] - public function open($savePath, $sessionName) + public function open(string $savePath, string $sessionName) { parent::open($savePath, $sessionName); @@ -53,7 +53,7 @@ protected function doRead(string $sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { return $this->write($sessionId, $data); } @@ -70,7 +70,7 @@ protected function doWrite(string $sessionId, string $data) * @return bool */ #[\ReturnTypeWillChange] - public function destroy($sessionId) + public function destroy(string $sessionId) { $this->doDestroy = true; $destroyed = parent::destroy($sessionId); @@ -101,7 +101,7 @@ public function close() * @return int|false */ #[\ReturnTypeWillChange] - public function gc($maxlifetime) + public function gc(int $maxlifetime) { return $this->handler->gc($maxlifetime); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 1bdd2e75fe46..e95a2cfc51af 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -95,10 +95,8 @@ class NativeSessionStorage implements SessionStorageInterface * sid_bits_per_character, "5" * trans_sid_hosts, $_SERVER['HTTP_HOST'] * trans_sid_tags, "a=href,area=href,frame=src,form=" - * - * @param AbstractProxy|\SessionHandlerInterface|null $handler */ - public function __construct(array $options = [], $handler = null, MetadataBag $metaBag = null) + public function __construct(array $options = [], AbstractProxy|\SessionHandlerInterface|null $handler = null, MetadataBag $metaBag = null) { if (!\extension_loaded('session')) { throw new \LogicException('PHP extension "session" is required.'); @@ -385,11 +383,9 @@ public function setOptions(array $options) * @see https://php.net/sessionhandlerinterface * @see https://php.net/sessionhandler * - * @param AbstractProxy|\SessionHandlerInterface|null $saveHandler - * * @throws \InvalidArgumentException */ - public function setSaveHandler($saveHandler = null) + public function setSaveHandler(AbstractProxy|\SessionHandlerInterface|null $saveHandler = null) { if (!$saveHandler instanceof AbstractProxy && !$saveHandler instanceof \SessionHandlerInterface && diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorageFactory.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorageFactory.php index a7d7411ff3fc..8b68447dc450 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorageFactory.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorageFactory.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; // Help opcache.preload discover always-needed symbols class_exists(NativeSessionStorage::class); @@ -29,7 +30,7 @@ class NativeSessionStorageFactory implements SessionStorageFactoryInterface /** * @see NativeSessionStorage constructor. */ - public function __construct(array $options = [], $handler = null, MetadataBag $metaBag = null, bool $secure = false) + public function __construct(array $options = [], AbstractProxy|\SessionHandlerInterface|null $handler = null, MetadataBag $metaBag = null, bool $secure = false) { $this->options = $options; $this->handler = $handler; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php index 72dbef134671..dac89267c9e6 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php @@ -20,10 +20,7 @@ */ class PhpBridgeSessionStorage extends NativeSessionStorage { - /** - * @param AbstractProxy|\SessionHandlerInterface|null $handler - */ - public function __construct($handler = null, MetadataBag $metaBag = null) + public function __construct(AbstractProxy|\SessionHandlerInterface|null $handler = null, MetadataBag $metaBag = null) { if (!\extension_loaded('session')) { throw new \LogicException('PHP extension "session" is required.'); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorageFactory.php b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorageFactory.php index 173ef71dea42..c7e0c9b0caac 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorageFactory.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorageFactory.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy; // Help opcache.preload discover always-needed symbols class_exists(PhpBridgeSessionStorage::class); @@ -25,10 +26,7 @@ class PhpBridgeSessionStorageFactory implements SessionStorageFactoryInterface private $metaBag; private $secure; - /** - * @see PhpBridgeSessionStorage constructor. - */ - public function __construct($handler = null, MetadataBag $metaBag = null, bool $secure = false) + public function __construct(AbstractProxy|\SessionHandlerInterface|null $handler = null, MetadataBag $metaBag = null, bool $secure = false) { $this->handler = $handler; $this->metaBag = $metaBag; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php index 5535bc96441d..ddfbdad98722 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php @@ -39,7 +39,7 @@ public function getHandler() * @return bool */ #[\ReturnTypeWillChange] - public function open($savePath, $sessionName) + public function open(string $savePath, string $sessionName) { return (bool) $this->handler->open($savePath, $sessionName); } @@ -57,7 +57,7 @@ public function close() * @return string */ #[\ReturnTypeWillChange] - public function read($sessionId) + public function read(string $sessionId) { return (string) $this->handler->read($sessionId); } @@ -66,7 +66,7 @@ public function read($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function write($sessionId, $data) + public function write(string $sessionId, string $data) { return (bool) $this->handler->write($sessionId, $data); } @@ -75,7 +75,7 @@ public function write($sessionId, $data) * @return bool */ #[\ReturnTypeWillChange] - public function destroy($sessionId) + public function destroy(string $sessionId) { return (bool) $this->handler->destroy($sessionId); } @@ -84,7 +84,7 @@ public function destroy($sessionId) * @return int|false */ #[\ReturnTypeWillChange] - public function gc($maxlifetime) + public function gc(int $maxlifetime) { return $this->handler->gc($maxlifetime); } @@ -93,7 +93,7 @@ public function gc($maxlifetime) * @return bool */ #[\ReturnTypeWillChange] - public function validateId($sessionId) + public function validateId(string $sessionId) { return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId); } @@ -102,7 +102,7 @@ public function validateId($sessionId) * @return bool */ #[\ReturnTypeWillChange] - public function updateTimestamp($sessionId, $data) + public function updateTimestamp(string $sessionId, string $data) { return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php index 57c4b948a91b..0bef08970679 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php @@ -122,7 +122,7 @@ public function testUpdateTimestamp() $lowTtl = 10; $this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo'); - $this->storage->updateTimestamp('id', []); + $this->storage->updateTimestamp('id', 'data'); $this->assertGreaterThan($lowTtl, $this->redisClient->ttl(self::PREFIX.'id')); } diff --git a/src/Symfony/Component/RateLimiter/Exception/RateLimitExceededException.php b/src/Symfony/Component/RateLimiter/Exception/RateLimitExceededException.php index e991a4897927..95ffadadcd47 100644 --- a/src/Symfony/Component/RateLimiter/Exception/RateLimitExceededException.php +++ b/src/Symfony/Component/RateLimiter/Exception/RateLimitExceededException.php @@ -22,7 +22,7 @@ class RateLimitExceededException extends \RuntimeException { private $rateLimit; - public function __construct(RateLimit $rateLimit, int|string $code = 0, \Throwable $previous = null) + public function __construct(RateLimit $rateLimit, int $code = 0, \Throwable $previous = null) { parent::__construct('Rate Limit Exceeded', $code, $previous);