diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 133805a6a585..92995a81c0d3 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -101,7 +101,7 @@ * @method static CURLRequest curlrequest($options = [], ResponseInterface $response = null, App $config = null, $getShared = true) * @method static Email email($config = null, $getShared = true) * @method static EncrypterInterface encrypter(Encryption $config = null, $getShared = false) - * @method static Exceptions exceptions(ConfigExceptions $config = null, IncomingRequest $request = null, ResponseInterface $response = null, $getShared = true) + * @method static Exceptions exceptions(ConfigExceptions $config = null, $getShared = true) * @method static Filters filters(ConfigFilters $config = null, $getShared = true) * @method static Format format(ConfigFormat $config = null, $getShared = true) * @method static Honeypot honeypot(ConfigHoneyPot $config = null, $getShared = true) diff --git a/system/Config/Services.php b/system/Config/Services.php index 2004b6dcd2a8..ca2d700b3b14 100644 --- a/system/Config/Services.php +++ b/system/Config/Services.php @@ -257,25 +257,18 @@ public static function encrypter(?EncryptionConfig $config = null, $getShared = * - register_shutdown_function * * @return Exceptions - * - * @deprecated The parameter $request and $response are deprecated. */ public static function exceptions( ?ExceptionsConfig $config = null, - ?IncomingRequest $request = null, - ?ResponseInterface $response = null, bool $getShared = true ) { if ($getShared) { - return static::getSharedInstance('exceptions', $config, $request, $response); + return static::getSharedInstance('exceptions', $config); } $config ??= config(ExceptionsConfig::class); - // @TODO remove instantiation of Response in the future. - $response ??= AppServices::response(); - - return new Exceptions($config, $request, $response); + return new Exceptions($config); } /** diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 8f07681f3a31..356c9d7fa0d1 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -37,7 +37,7 @@ class Exceptions * * @var int * - * @deprecated No longer used. Moved to BaseExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler. */ public $ob_level; @@ -47,7 +47,7 @@ class Exceptions * * @var string * - * @deprecated No longer used. Moved to BaseExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler. */ protected $viewPath; @@ -74,12 +74,7 @@ class Exceptions private ?Throwable $exceptionCaughtByExceptionHandler = null; - /** - * @param RequestInterface|null $request - * - * @deprecated The parameter $request and $response are deprecated. No longer used. - */ - public function __construct(ExceptionsConfig $config, $request, ResponseInterface $response) /** @phpstan-ignore-line */ + public function __construct(ExceptionsConfig $config) { // For backward compatibility $this->ob_level = ob_get_level(); @@ -240,7 +235,7 @@ public function shutdownHandler() * * @return string The path and filename of the view file to use * - * @deprecated No longer used. Moved to ExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to ExceptionHandler. */ protected function determineView(Throwable $exception, string $templatePath): string { @@ -268,7 +263,7 @@ protected function determineView(Throwable $exception, string $templatePath): st /** * Given an exception and status code will display the error to the client. * - * @deprecated No longer used. Moved to BaseExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler. */ protected function render(Throwable $exception, int $statusCode) { @@ -310,7 +305,7 @@ protected function render(Throwable $exception, int $statusCode) /** * Gathers the variables that will be made available to the view. * - * @deprecated No longer used. Moved to BaseExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler. */ protected function collectVars(Throwable $exception, int $statusCode): array { @@ -471,7 +466,7 @@ public static function cleanPath(string $file): string * Describes memory usage in real-world units. Intended for use * with memory_get_usage, etc. * - * @deprecated No longer used. Moved to BaseExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler. */ public static function describeMemory(int $bytes): string { @@ -491,7 +486,7 @@ public static function describeMemory(int $bytes): string * * @return bool|string * - * @deprecated No longer used. Moved to BaseExceptionHandler. + * @deprecated 4.4.0 No longer used. Moved to BaseExceptionHandler. */ public static function highlightFile(string $file, int $lineNumber, int $lines = 15) { diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index e1ef2ef28da2..b22995b5b218 100644 --- a/tests/system/Config/ServicesTest.php +++ b/tests/system/Config/ServicesTest.php @@ -127,13 +127,13 @@ public function testNewUnsharedEmailWithNonEmptyConfig(): void public function testNewExceptions(): void { - $actual = Services::exceptions(new Exceptions(), Services::request(), Services::response()); + $actual = Services::exceptions(new Exceptions()); $this->assertInstanceOf(\CodeIgniter\Debug\Exceptions::class, $actual); } public function testNewExceptionsWithNullConfig(): void { - $actual = Services::exceptions(null, null, null, false); + $actual = Services::exceptions(null, false); $this->assertInstanceOf(\CodeIgniter\Debug\Exceptions::class, $actual); } diff --git a/tests/system/Debug/ExceptionsTest.php b/tests/system/Debug/ExceptionsTest.php index a77745ba8a78..4a30a32f1133 100644 --- a/tests/system/Debug/ExceptionsTest.php +++ b/tests/system/Debug/ExceptionsTest.php @@ -19,7 +19,6 @@ use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\ReflectionHelper; use Config\Exceptions as ExceptionsConfig; -use Config\Services; use ErrorException; use RuntimeException; @@ -52,7 +51,7 @@ protected function setUp(): void { parent::setUp(); - $this->exception = new Exceptions(new ExceptionsConfig(), Services::request(), Services::response()); + $this->exception = new Exceptions(new ExceptionsConfig()); } /** @@ -65,7 +64,7 @@ public function testDeprecationsOnPhp81DoNotThrow(): void $config->logDeprecations = true; $config->deprecationLogLevel = 'error'; - $this->exception = new Exceptions($config, Services::request(), Services::response()); + $this->exception = new Exceptions($config); $this->exception->initialize(); // this is only needed for IDEs not to complain that strlen does not accept explicit null @@ -89,7 +88,7 @@ public function testSuppressedDeprecationsAreLogged(): void $config->logDeprecations = true; $config->deprecationLogLevel = 'error'; - $this->exception = new Exceptions($config, Services::request(), Services::response()); + $this->exception = new Exceptions($config); $this->exception->initialize(); @trigger_error('Hello! I am a deprecation!', E_USER_DEPRECATED); diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index 5cf06105d29f..a9feb1198a9c 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -109,6 +109,14 @@ Added Parameters - **Routing:** The third parameter ``Routing $routing`` has been added to ``RouteCollection::__construct()``. +Removed Parameters +------------------ + +- **Services:** The second parameter ``$request`` and the third parameter + ``$response`` in ``Services::exceptions()`` have been removed. +- **Error Handling:** The second parameter ``$request`` and the third parameter + ``$response`` in ``CodeIgniter\Debug\Exceptions::__construct()`` have been removed. + Return Type Changes -------------------