Skip to content

PHP 8.4: trigger_error() updates #4063

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

Merged
merged 3 commits into from
Nov 14, 2024
Merged
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
31 changes: 29 additions & 2 deletions reference/errorfunc/functions/trigger-error.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
The designated error type for this error. It only works with the <constant>E_USER_<replaceable>*</replaceable></constant>
family of constants, and will default to <constant>E_USER_NOTICE</constant>.
</para>
<warning>
<simpara>
Passing <constant>E_USER_ERROR</constant> as the
<parameter>error_level</parameter> is now deprecated.
Throw an <exceptionname>Exception</exceptionname> or
call <function>exit</function> instead.
</simpara>
</warning>
</listitem>
</varlistentry>
</variablelist>
Expand Down Expand Up @@ -80,6 +88,22 @@
</row>
</thead>
<tbody>
<row>
<entry>8.4.0</entry>
<entry>
Passing <constant>E_USER_ERROR</constant> as the
<parameter>error_level</parameter> is now deprecated.
Throw an <exceptionname>Exception</exceptionname> or
call <function>exit</function> instead.
</entry>
</row>
<row>
<entry>8.4.0</entry>
<entry>
The function now has a return type of <type>true</type>
instead of <type>bool</type>.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Expand All @@ -103,9 +127,11 @@
<programlisting role="php">
<![CDATA[
<?php
if ($divisor == 0) {
trigger_error("Cannot divide by zero", E_USER_ERROR);
$password = $_POST['password'] ?? '';
if ($password === '') {
trigger_error("Using an empty password is unsafe", E_USER_WARNING);
}
$hash = password_hash($password, PASSWORD_DEFAULT);
?>
]]>
</programlisting>
Expand All @@ -132,6 +158,7 @@ if ($divisor == 0) {
<member><function>set_error_handler</function></member>
<member><function>restore_error_handler</function></member>
<member>The <link linkend="errorfunc.constants">error level constants</link></member>
<member>The <classname>Deprecated</classname> attribute</member>
</simplelist>
</para>
</refsect1>
Expand Down