-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[5.4][PHP8.5] Using null as an array offset is now deprecated #46201
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
Conversation
|
Strange, based on the method docblock it's not allowed to provide NULL, I would prefere a user deprecation warning and check why we provide a NULL here. |
@HLeithner Did you mean "provide" instead of "prove"? |
|
updated my comment |
Do you mean something like this. What should the target version be?
/**
* Get menu item by id
*
* @param integer $id The item id
*
* @return MenuItem|null The item object if the ID exists or null if not found
*
* @since 1.5
*/
public function getItem($id)
{
$result = null;
+ if ($id === null) {
+ @trigger_error(\sprintf('The value for $id must not be null in %s', __METHOD__), E_USER_DEPRECATED);
+
+ return $result;
+ }
+
if (isset($this->getMenu()[$id])) {
$result = &$this->getMenu()[$id];
}
return $result;
}
|
|
thanks |
|
✅ Tested with JBT php8.5-rc
|
|
Thank you @heelc29 for your contribution. Thank you @HLeithner for your support. |
Summary of Changes
https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists
Testing Instructions
Open frontend and open login form
index.php/component/users/loginActual result BEFORE applying this Pull Request
deprecation message (possibly further)

Expected result AFTER applying this Pull Request
no deprecation message about
using null as an array offsetfromAbstractMenu.phpLink to documentations