Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #20282: Fix compatibility with PHP 8.4: deprecated constant E_STRICT #20285

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Yii Framework 2 Change Log
- Enh #20268: Minor optimisation in `\yii\helpers\BaseArrayHelper::map` (chriscpty)
- Enh #20273: Remove unnecessary `paragonie/random_compat` dependency (timwolla)
- Chg #20276: Removed autogenerated migration phpdoc (userator)
- Bug #20282: Fix compatibility with PHP 8.4: deprecated constant E_STRICT (Izumi-kun)
- Bug #20284: Revert punycode to 1.4.x which supports pre ES6 format (mtangoo)
- New #20279: Add to the `\yii\web\Request` CSRF validation by custom HTTP header (olegbaturin)
- Enh #20279: Add to the `\yii\web\Request` `csrfHeader` property to configure a custom HTTP header for CSRF validation (olegbaturin)
Expand Down
5 changes: 2 additions & 3 deletions framework/base/ErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,14 @@ public function getName()
E_NOTICE => 'PHP Notice',
E_PARSE => 'PHP Parse Error',
E_RECOVERABLE_ERROR => 'PHP Recoverable Error',
E_STRICT => 'PHP Strict Warning',
E_USER_DEPRECATED => 'PHP User Deprecated Warning',
E_USER_ERROR => 'PHP User Error',
E_USER_NOTICE => 'PHP User Notice',
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 isset($names[$this->getCode()]) ? $names[$this->getCode()] : 'Error';
return $names[$this->getCode()] ?? 'Error';
}
}
9 changes: 9 additions & 0 deletions tests/framework/base/ErrorExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ public function testXdebugTrace()
$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());
}
}
Loading