diff --git a/system/HTTP/Exceptions/RedirectException.php b/system/HTTP/Exceptions/RedirectException.php index a16dfc1a8a2d..b0452638f302 100644 --- a/system/HTTP/Exceptions/RedirectException.php +++ b/system/HTTP/Exceptions/RedirectException.php @@ -27,11 +27,9 @@ class RedirectException extends RuntimeException implements ExceptionInterface, ResponsableInterface, HTTPExceptionInterface { /** - * HTTP status code for redirects - * - * @var int + * Status code applied to a Response that arrives without a 3xx redirect status. */ - protected $code = 302; + protected int $defaultStatusCode = 302; protected ?ResponseInterface $response = null; @@ -61,7 +59,7 @@ public function __construct($message = '', int $code = 0, ?Throwable $previous = } if ($this->response->getStatusCode() < 301 || $this->response->getStatusCode() > 308) { - $this->response->setStatusCode($this->code); + $this->response->setStatusCode($this->defaultStatusCode); } } diff --git a/user_guide_src/source/changelogs/v4.8.0.rst b/user_guide_src/source/changelogs/v4.8.0.rst index 7f2bcb2d2155..fb4c615399e9 100644 --- a/user_guide_src/source/changelogs/v4.8.0.rst +++ b/user_guide_src/source/changelogs/v4.8.0.rst @@ -42,6 +42,7 @@ Behavior Changes - **Filters:** HTTP method matching for method-based filters is now case-sensitive. The keys in ``Config\Filters::$methods`` must exactly match the request method (e.g., ``GET``, ``POST``). Lowercase method names (e.g., ``post``) will no longer match. - **HTTP:** Routes defined with ``$routes->add()`` now also match HTTP ``QUERY`` requests. If the route has CSRF protection, remember that CSRF verification does not protect safe methods such as ``GET`` and ``QUERY``. +- **HTTP:** ``CodeIgniter\HTTP\Exceptions\RedirectException`` no longer redeclares the inherited ``$code`` property. The status applied to a ``Response`` passed to the constructor without a 3xx status now comes from the new ``protected int $defaultStatusCode = 302`` property. Subclasses that overrode ``$code`` to change that status must override ``$defaultStatusCode`` instead. - **Testing:** Tests using the ``FeatureTestTrait`` must now use uppercase HTTP method names when performing a request when using the ``call()`` method directly (e.g., ``$this->call('GET', '/path')`` instead of ``$this->call('get', '/path')``). Additionally, setting method-based routes using ``withRoutes()`` must also use uppercase method names (e.g., ``$this->withRoutes([['GET', 'home', 'Home::index']])``). diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 817b59589b65..2e31999878d3 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 1492 errors +# total 1491 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/property.phpDocType.neon b/utils/phpstan-baseline/property.phpDocType.neon index c9f237db3c76..00b0ebeb7e64 100644 --- a/utils/phpstan-baseline/property.phpDocType.neon +++ b/utils/phpstan-baseline/property.phpDocType.neon @@ -1,4 +1,4 @@ -# total 41 errors +# total 40 errors parameters: ignoreErrors: @@ -137,11 +137,6 @@ parameters: count: 1 path: ../../system/Exceptions/PageNotFoundException.php - - - message: '#^PHPDoc type int of property CodeIgniter\\HTTP\\Exceptions\\RedirectException\:\:\$code is not the same as PHPDoc type mixed of overridden property Exception\:\:\$code\.$#' - count: 1 - path: ../../system/HTTP/Exceptions/RedirectException.php - - message: '#^PHPDoc type string of property CodeIgniter\\HTTP\\Files\\UploadedFile\:\:\$originalMimeType is not the same as PHPDoc type string\|null of overridden property CodeIgniter\\Files\\File\:\:\$originalMimeType\.$#' count: 1