diff --git a/system/Cookie/Cookie.php b/system/Cookie/Cookie.php index df75c03c7bcb..ad461c721112 100644 --- a/system/Cookie/Cookie.php +++ b/system/Cookie/Cookie.php @@ -99,7 +99,16 @@ class Cookie implements ArrayAccess, CloneableCookieInterface * Default attributes for a Cookie object. The keys here are the * lowercase attribute names. Do not camelCase! * - * @var array + * @var array{ + * prefix: string, + * expires: int, + * path: string, + * domain: string, + * secure: bool, + * httponly: bool, + * samesite: string, + * raw: bool, + * } */ private static array $defaults = [ 'prefix' => '', @@ -127,9 +136,27 @@ class Cookie implements ArrayAccess, CloneableCookieInterface * * This method is called from Response::__construct(). * - * @param array|CookieConfig $config + * @param array{ + * prefix?: string, + * expires?: int, + * path?: string, + * domain?: string, + * secure?: bool, + * httponly?: bool, + * samesite?: string, + * raw?: bool, + * }|CookieConfig $config * - * @return array The old defaults array. Useful for resetting. + * @return array{ + * prefix: string, + * expires: int, + * path: string, + * domain: string, + * secure: bool, + * httponly: bool, + * samesite: string, + * raw: bool, + * } The old defaults array. Useful for resetting. */ public static function setDefaults($config = []) { @@ -198,9 +225,9 @@ public static function fromHeaderString(string $cookie, bool $raw = false) /** * Construct a new Cookie instance. * - * @param string $name The cookie's name - * @param string $value The cookie's value - * @param array $options The cookie's options + * @param string $name The cookie's name + * @param string $value The cookie's value + * @param array{prefix?: string, max-age?: int|numeric-string, expires?: DateTimeInterface|int|string, path?: string, domain?: string, secure?: bool, httponly?: bool, samesite?: string, raw?: bool} $options The cookie's options * * @throws CookieException */ diff --git a/system/Cookie/CookieInterface.php b/system/Cookie/CookieInterface.php index c848fa8884ec..b4a7ea3d7320 100644 --- a/system/Cookie/CookieInterface.php +++ b/system/Cookie/CookieInterface.php @@ -145,7 +145,14 @@ public function isRaw(): bool; * Gets the options that are passable to the `setcookie` variant * available on PHP 7.3+ * - * @return array + * @return array{ + * expires: int, + * path: string, + * domain: string, + * secure: bool, + * httponly: bool, + * samesite: string, + * } */ public function getOptions(): array; @@ -164,7 +171,18 @@ public function __toString(); /** * Returns the array representation of the Cookie object. * - * @return array + * @return array{ + * name: string, + * value: string, + * prefix: string, + * raw: bool, + * expires: int, + * path: string, + * domain: string, + * secure: bool, + * httponly: bool, + * samesite: string, + * } */ public function toArray(): array; } diff --git a/tests/system/Cookie/CookieStoreTest.php b/tests/system/Cookie/CookieStoreTest.php index 7e752fde5da5..60498052ee93 100644 --- a/tests/system/Cookie/CookieStoreTest.php +++ b/tests/system/Cookie/CookieStoreTest.php @@ -78,7 +78,7 @@ public function testCookieStoreInitViaHeaders(): void public function testInvalidCookieStored(): void { $this->expectException(CookieException::class); - new CookieStore([new DateTimeImmutable('now')]); + new CookieStore([new DateTimeImmutable('now')]); // @phpstan-ignore argument.type } public function testPutRemoveCookiesInStore(): void diff --git a/utils/phpstan-baseline/argument.type.neon b/utils/phpstan-baseline/argument.type.neon index 7301faeae35d..34a1a8c9986e 100644 --- a/utils/phpstan-baseline/argument.type.neon +++ b/utils/phpstan-baseline/argument.type.neon @@ -1,4 +1,4 @@ -# total 138 errors +# total 136 errors parameters: ignoreErrors: @@ -82,16 +82,6 @@ parameters: count: 2 path: ../../tests/system/Config/FactoriesTest.php - - - message: '#^Parameter \#1 \$cookies of class CodeIgniter\\Cookie\\CookieStore constructor expects array\, array\ given\.$#' - count: 1 - path: ../../tests/system/Cookie/CookieStoreTest.php - - - - message: '#^Parameter \#3 \$options of class CodeIgniter\\Cookie\\Cookie constructor expects array\, array\ given\.$#' - count: 1 - path: ../../tests/system/Cookie/CookieTest.php - - message: '#^Parameter \#1 \$from of method CodeIgniter\\Database\\BaseBuilder\:\:from\(\) expects array\|string, null given\.$#' count: 1 diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index c715fc07bd3b..e54589fea853 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 3273 errors +# total 3271 errors includes: - argument.type.neon - assign.propertyType.neon