Bug->Doc #80234 [Opn]: user-defined error handler and string numeric keys in $errcontext
| From: | cmb@php.net | Date: | Tue, 24 Aug 2021 12:20:39 +0000 |
| Subject: | Bug->Doc #80234 [Opn]: user-defined error handler and string numeric keys in $errcontext | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-19102@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80234&edit=1
ID: 80234
Updated by: cmb@php.net
Reported by: david at grudl dot com
Summary: user-defined error handler and string numeric keys
in $errcontext
Status: Open
-Type: Bug
+Type: Documentation Problem
Package: Scripting Engine problem
PHP Version: 7.4.11
Block user comment: N
Private report: N
New Comment:
> Array $context passed to custom error handler is non-standard
> because contains string numeric keys.
Well, get_defined_vars() has the same behavior[1] (and maybe
others as well), and generally this may happen when casting
objects to array prior to PHP 7.2.0[2]. It might be worthwhile to
address the future scope section of the respective RFC[3], but I'm
changing to doc problem for now.
[1] <https://3v4l.org/Z1YPI>
[2] <https://www.php.net/manual/en/language.types.object.php#language.types.object.casting>
[3] <https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts#future_scope>
Previous Comments:
------------------------------------------------------------------------
[2020-10-14 11:36:06] david at grudl dot com
Description:
------------
Array $context passed to custom error handler is non-standard because contains string numeric keys.
Example: https://3v4l.org/BR04H
Because $context is deprecated, there is no need to fix it, I just wanted to document it.
Test script:
---------------
<?php
set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
var_dump($context);
});
$a = 1;
$$a = 2;
Expected result:
----------------
array(3) { [1]=> int(2), ... }
Actual result:
--------------
array(3) { ["1"]=> int(2), ... }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80234&edit=1