From 86691e2e4856f36ced94d7f93cdcb41a0707e9f6 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com> Date: Tue, 10 Jun 2025 04:48:05 -0400 Subject: [PATCH] Remove used code `E_STRICT` handling in `ErrorException` class and update tests to reflect changes. (#20402) --- framework/CHANGELOG.md | 1 + framework/base/ErrorException.php | 2 +- tests/framework/base/ErrorExceptionTest.php | 9 --------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 60c9d7d254..1ce1f5fa25 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -7,6 +7,7 @@ Yii Framework 2 Change Log - Chg #19902: Remove support for CUBRID (mtangoo) - Chg #19891: Remove XCache and ZendDataCache support (mtangoo) - Enh #20368: Refactor asset management: Migrate from `Bower` to `NPM` for package dependencies and update related documentation (terabytesoftw) +- Bug #20242: Remove used code `E_STRICT` handling in `ErrorException` class and update tests to reflect changes (terabytesoftw) 2.0.53 under development diff --git a/framework/base/ErrorException.php b/framework/base/ErrorException.php index a5af2a8027..3eb1f42f52 100644 --- a/framework/base/ErrorException.php +++ b/framework/base/ErrorException.php @@ -130,7 +130,7 @@ class ErrorException extends \ErrorException E_USER_WARNING => 'PHP User Warning', E_WARNING => 'PHP Warning', self::E_HHVM_FATAL_ERROR => 'HHVM Fatal Error', - ] + (PHP_VERSION_ID < 80400 ? [E_STRICT => 'PHP Strict Warning'] : []); + ]; return $names[$this->getCode()] ?? 'Error'; } diff --git a/tests/framework/base/ErrorExceptionTest.php b/tests/framework/base/ErrorExceptionTest.php index 493325a27a..0a2d9b2b3b 100644 --- a/tests/framework/base/ErrorExceptionTest.php +++ b/tests/framework/base/ErrorExceptionTest.php @@ -41,13 +41,4 @@ class ErrorExceptionTest extends TestCase $this->assertEquals(__FUNCTION__, $e->getTrace()[0]['function']); } } - - public function testStrictError() - { - if (!defined('E_STRICT')) { - $this->markTestSkipped('E_STRICT has been removed.'); - } - $e = new ErrorException('', @E_STRICT); - $this->assertEquals(PHP_VERSION_ID < 80400 ? 'PHP Strict Warning' : 'Error', $e->getName()); - } }