refactor: Remove deprecation related to cookies (#9406)

* refactor: Remove deprecated `Config\Security::$samesite`

* refactor: Remove deprecated methods in `CookieStore`

* docs: Update changelog

* refactor: Update phpstan baseline

* docs: Update userguide

* refactor: Remove deprecated  `Cookie::withNeverExpiring()`

* docs: Update changelog, userguide
This commit is contained in:
neznaika0 2025-01-14 08:50:28 +03:00 committed by GitHub
parent 35321ac6c2
commit 17d6adeee4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 7 additions and 103 deletions

View File

@ -83,21 +83,4 @@ class Security extends BaseConfig
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
*/
public bool $redirect = (ENVIRONMENT === 'production');
/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token.
*
* Allowed values are: None - Lax - Strict - ''.
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @deprecated `Config\Cookie` $samesite property is used.
*/
public string $samesite = 'Lax';
}

View File

@ -58,15 +58,6 @@ interface CloneableCookieInterface extends CookieInterface
*/
public function withExpired();
/**
* Creates a new Cookie that will virtually never expire from the browser.
*
* @return static
*
* @deprecated See https://github.com/codeigniter4/CodeIgniter4/pull/6413
*/
public function withNeverExpiring();
/**
* Creates a new Cookie with a new path on the server the cookie is available.
*

View File

@ -465,18 +465,6 @@ class Cookie implements ArrayAccess, CloneableCookieInterface
return $cookie;
}
/**
* @deprecated See https://github.com/codeigniter4/CodeIgniter4/pull/6413
*/
public function withNeverExpiring()
{
$cookie = clone $this;
$cookie->expires = Time::now()->getTimestamp() + 5 * YEAR;
return $cookie;
}
/**
* {@inheritDoc}
*/

View File

@ -159,28 +159,6 @@ class CookieStore implements Countable, IteratorAggregate
return $store;
}
/**
* Dispatches all cookies in store.
*
* @deprecated Response should dispatch cookies.
*/
public function dispatch(): void
{
foreach ($this->cookies as $cookie) {
$name = $cookie->getPrefixedName();
$value = $cookie->getValue();
$options = $cookie->getOptions();
if ($cookie->isRaw()) {
$this->setRawCookie($name, $value, $options);
} else {
$this->setCookie($name, $value, $options);
}
}
$this->clear();
}
/**
* Returns all cookie instances in store.
*
@ -232,28 +210,4 @@ class CookieStore implements Countable, IteratorAggregate
}
}
}
/**
* Extracted call to `setrawcookie()` in order to run unit tests on it.
*
* @codeCoverageIgnore
*
* @deprecated
*/
protected function setRawCookie(string $name, string $value, array $options): void
{
setrawcookie($name, $value, $options);
}
/**
* Extracted call to `setcookie()` in order to run unit tests on it.
*
* @codeCoverageIgnore
*
* @deprecated
*/
protected function setCookie(string $name, string $value, array $options): void
{
setcookie($name, $value, $options);
}
}

View File

@ -235,7 +235,6 @@ final class CookieTest extends CIUnitTestCase
$e = $a->withValue('muffin');
$f = $a->withExpires('+30 days');
$g = $a->withExpired();
$h = $a->withNeverExpiring();
$i = $a->withDomain('localhost');
$j = $a->withPath('/web');
$k = $a->withSecure();
@ -248,7 +247,6 @@ final class CookieTest extends CIUnitTestCase
$this->assertNotSame($a, $e);
$this->assertNotSame($a, $f);
$this->assertNotSame($a, $g);
$this->assertNotSame($a, $h);
$this->assertNotSame($a, $i);
$this->assertNotSame($a, $j);
$this->assertNotSame($a, $k);

View File

@ -203,6 +203,8 @@ Removed Deprecated Items
- **View:** The deprecated property ``CodeIgniter\View\View::$currentSection`` has been removed.
- **Config:** The deprecated property ``Config\Cache::$storePath`` has been removed. Use ``Config\Cache::$file['storePath']`` instead.
- **Formatter:** The deprecated ``Config\Format::getFormatter()`` has been removed. Use ``CodeIgniter\Format\Format::getFormatter()`` instead.
- **Security:** ``Config\Security::$samesite`` has been removed. Use ``Config\Cookie::$samesite`` instead.
- **Cookie:** Methods ``dispatch()``, ``setRawCookie()``, ``setCookie()`` in ``CodeIgniter\Cookie\CookieStore`` has been removed. They are now part of ``CodeIgniter\HTTP\ResponseTrait``.
************
Enhancements

View File

@ -228,9 +228,7 @@ the instance with the modified instance.
Dispatching Cookies in Store
============================
.. deprecated:: 4.1.6
.. important:: This method is deprecated. It will be removed in future releases.
.. important:: This method was deprecated as of version 4.1.6 and was removed in 4.6.0.
More often than not, you do not need to concern yourself in manually sending cookies. CodeIgniter will do this
for you. However, if you really need to manually send cookies, you can use the ``dispatch`` method. Just like
@ -369,9 +367,7 @@ Class Reference
.. php:method:: withNeverExpiring()
.. deprecated:: 4.2.6
.. important:: This method is deprecated. It will be removed in future releases.
.. important:: This method was deprecated as of version 4.2.6 and was removed in 4.6.0.
:param string $name:
:rtype: ``Cookie``
@ -484,6 +480,8 @@ Class Reference
.. php:method:: dispatch(): void
.. important:: This method was deprecated as of version 4.1.6 and was removed in 4.6.0.
:rtype: void
Dispatches all cookies in store.

View File

@ -1,4 +1,4 @@
# total 1667 errors
# total 1665 errors
parameters:
ignoreErrors:
@ -852,16 +852,6 @@ parameters:
count: 1
path: ../../system/Controller.php
-
message: '#^Method CodeIgniter\\Cookie\\CookieStore\:\:setCookie\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Cookie/CookieStore.php
-
message: '#^Method CodeIgniter\\Cookie\\CookieStore\:\:setRawCookie\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Cookie/CookieStore.php
-
message: '#^Method CodeIgniter\\Cookie\\CookieStore\:\:validateCookies\(\) has parameter \$cookies with no value type specified in iterable type array\.$#'
count: 1