[doc-en] master: Clarify arguments passed to set_error_handler callbacks (#6143)

From: Date: Wed, 25 Nov 2026 12:15:34 +0000
Subject: [doc-en] master: Clarify arguments passed to set_error_handler callbacks (#6143)
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-24019@lists.php.net to get a copy of this message
Author: Malek Kadri (malekkadri) Committer: GitHub (web-flow) Pusher: lacatoire Date: 2026-11-25T13:15:29+01:00 Commit: https://github.com/php/doc-en/commit/763f3fae91fae0061ac6525a29506d4e160bd0a6 Raw diff: https://github.com/php/doc-en/commit/763f3fae91fae0061ac6525a29506d4e160bd0a6.diff Clarify arguments passed to set_error_handler callbacks (#6143) * Clarify arguments passed to set_error_handler callbacks * Fix invalid DocBook paragraph nesting * Remove unnecessary paragraph around callback parameter list Changed paths: M reference/errorfunc/functions/set-error-handler.xml Diff: diff --git a/reference/errorfunc/functions/set-error-handler.xml b/reference/errorfunc/functions/set-error-handler.xml index aa620d26cc20..7ad3dbdfd93a 100644 --- a/reference/errorfunc/functions/set-error-handler.xml +++ b/reference/errorfunc/functions/set-error-handler.xml @@ -77,70 +77,71 @@ <type>bool</type><methodname><replaceable>handler</replaceable></methodname> <methodparam><type>int</type><parameter>errno</parameter></methodparam> <methodparam><type>string</type><parameter>errstr</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>errfile</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>errline</parameter></methodparam> - <methodparam choice="opt"><type>array</type><parameter>errcontext</parameter></methodparam> + <methodparam><type>string</type><parameter>errfile</parameter></methodparam> + <methodparam><type>int</type><parameter>errline</parameter></methodparam> </methodsynopsis> - <variablelist> - <varlistentry> - <term><parameter>errno</parameter></term> - <listitem> - <simpara> - The first parameter, <parameter>errno</parameter>, will be passed the - level of the error raised, as an integer. - </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>errstr</parameter></term> - <listitem> - <simpara> - The second parameter, <parameter>errstr</parameter>, will be passed the - error message, as a string. - </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>errfile</parameter></term> - <listitem> - <simpara> - If the callback accepts a third parameter, <parameter>errfile</parameter>, - it will be passed the filename that the error was raised in, as a string. - </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>errline</parameter></term> - <listitem> - <simpara> - If the callback accepts a fourth parameter, <parameter>errline</parameter>, - it will be passed the line number where the error was raised, as an integer. - </simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><parameter>errcontext</parameter></term> - <listitem> + </para> + <simpara> + As of PHP 8.0.0, four arguments are passed to the handler. + A user-defined handler does not need to declare parameters for + arguments it does not use. + These arguments remain accessible through <function>func_get_args</function>. + </simpara> + <variablelist> + <varlistentry> + <term><parameter>errno</parameter></term> + <listitem> + <simpara> + The first parameter, <parameter>errno</parameter>, will be passed the + level of the error raised, as an integer. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>errstr</parameter></term> + <listitem> + <simpara> + The second parameter, <parameter>errstr</parameter>, will be passed the + error message, as a string. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>errfile</parameter></term> + <listitem> + <simpara> + The third argument is the filename in which the error was raised. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>errline</parameter></term> + <listitem> + <simpara> + The fourth argument is the line number at which the error was raised. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>errcontext</parameter></term> + <listitem> + <simpara> + Prior to PHP 8.0.0, a fifth parameter, <parameter>errcontext</parameter>, + could receive an array of variables in the scope in which the error + was raised. + User error handlers were not permitted to modify the error context. + </simpara> + <warning xmlns="http://docbook.org/ns/docbook"> <simpara> - If the callback accepts a fifth parameter, <parameter>errcontext</parameter>, - it will be passed an array that points to the active symbol table at the - point the error occurred. In other words, <parameter>errcontext</parameter> - will contain an array of every variable that existed in the scope the - error was triggered in. - User error handlers must not modify the error context. + This parameter has been <emphasis>DEPRECATED</emphasis> as of PHP 7.2.0, + and <emphasis>REMOVED</emphasis> as of PHP 8.0.0. If the function defines + this parameter without a default, an error of "too few arguments" will be + raised when it is called. </simpara> - <warning xmlns="http://docbook.org/ns/docbook"> - <simpara> - This parameter has been <emphasis>DEPRECATED</emphasis> as of PHP 7.2.0, - and <emphasis>REMOVED</emphasis> as of PHP 8.0.0. If the function defines - this parameter without a default, an error of "too few arguments" will be - raised when it is called. - </simpara> - </warning> - </listitem> - </varlistentry> - </variablelist> - </para> + </warning> + </listitem> + </varlistentry> + </variablelist> <para> If the function returns &false; then the normal error handler continues. </para>

« previous php.doc.cvs (#24019) next »