Skip to content

Commit 72b70d7

Browse files
authored
PHP 8.4: trigger_error() updates (#4063)
1 parent 9cd8eb0 commit 72b70d7

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

reference/errorfunc/functions/trigger-error.xml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
The designated error type for this error. It only works with the <constant>E_USER_<replaceable>*</replaceable></constant>
4747
family of constants, and will default to <constant>E_USER_NOTICE</constant>.
4848
</para>
49+
<warning>
50+
<simpara>
51+
Passing <constant>E_USER_ERROR</constant> as the
52+
<parameter>error_level</parameter> is now deprecated.
53+
Throw an <exceptionname>Exception</exceptionname> or
54+
call <function>exit</function> instead.
55+
</simpara>
56+
</warning>
4957
</listitem>
5058
</varlistentry>
5159
</variablelist>
@@ -80,6 +88,22 @@
8088
</row>
8189
</thead>
8290
<tbody>
91+
<row>
92+
<entry>8.4.0</entry>
93+
<entry>
94+
Passing <constant>E_USER_ERROR</constant> as the
95+
<parameter>error_level</parameter> is now deprecated.
96+
Throw an <exceptionname>Exception</exceptionname> or
97+
call <function>exit</function> instead.
98+
</entry>
99+
</row>
100+
<row>
101+
<entry>8.4.0</entry>
102+
<entry>
103+
The function now has a return type of <type>true</type>
104+
instead of <type>bool</type>.
105+
</entry>
106+
</row>
83107
<row>
84108
<entry>8.0.0</entry>
85109
<entry>
@@ -103,9 +127,11 @@
103127
<programlisting role="php">
104128
<![CDATA[
105129
<?php
106-
if ($divisor == 0) {
107-
trigger_error("Cannot divide by zero", E_USER_ERROR);
130+
$password = $_POST['password'] ?? '';
131+
if ($password === '') {
132+
trigger_error("Using an empty password is unsafe", E_USER_WARNING);
108133
}
134+
$hash = password_hash($password, PASSWORD_DEFAULT);
109135
?>
110136
]]>
111137
</programlisting>
@@ -132,6 +158,7 @@ if ($divisor == 0) {
132158
<member><function>set_error_handler</function></member>
133159
<member><function>restore_error_handler</function></member>
134160
<member>The <link linkend="errorfunc.constants">error level constants</link></member>
161+
<member>The <classname>Deprecated</classname> attribute</member>
135162
</simplelist>
136163
</para>
137164
</refsect1>

0 commit comments

Comments
 (0)