-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
The framework currently uses #[\ReturnTypeWillChange] in 17 files (72 methods) to suppress PHP 8.1+ deprecation warnings. This attribute will stop working in PHP 9.0, causing fatal errors for any method with an incompatible return type.
- https://wiki.php.net/rfc/internal_method_return_types
- https://php.watch/versions/8.1/ReturnTypeWillChange
- https://www.php.net/manual/en/class.returntypewillchange.php
In PHP 9.0, incompatible return types in methods overriding internal methods will result in a fatal error, regardless of whether
#[\ReturnTypeWillChange]is present.
Affected files
| File | Methods | Risk |
|---|---|---|
web/SessionIterator.php |
5 | Low (internal class) |
web/SessionHandler.php |
5 | Low (internal class) |
web/HeaderCollection.php |
5 | Low |
web/CookieCollection.php |
5 | Low |
web/Session.php |
5 | Medium |
db/BatchQueryResult.php |
5 | Low (internal class) |
db/DataReader.php |
5 | Low |
db/JsonExpression.php |
1 | Low |
db/ArrayExpression.php |
5 | Low |
db/SqlToken.php |
5 | Low |
db/mssql/DBLibPDO.php |
2 | Low (internal class) |
db/mssql/PDO.php |
2 | Low (internal class) |
db/mssql/SqlsrvPDO.php |
2 | Low (internal class) |
db/BaseActiveRecord.php |
5 | High (widely extended) |
base/Model.php |
5 | High (widely extended) |
base/ArrayAccessTrait.php |
5 | High (used by Model) |
caching/Cache.php |
5 | Medium |
BC impact
Adding return types to non-final classes is technically a minor BC break: any child class overriding these methods without matching return types will get a fatal error. However, most of these methods implement PHP built-in interfaces (Iterator, ArrayAccess, Countable) and child classes will need the same return types anyway for PHP 9.0 compatibility.