Skip to content

Commit

Permalink
assert() no longer evaluates strings as of PHP 8.0.0
Browse files Browse the repository at this point in the history
As per the PHP changelog, the functionality to use a string for `assert` has been removed in PHP 8.0: https://github.com/php/php-src/blob/69888c3ff1f2301ead8e37b23ff8481d475e29d2/UPGRADING#L350-L354

Co-authored-by: Christoph M. Becker <[email protected]>

Closes phpGH-1471.
  • Loading branch information
braders authored and cmb69 committed Mar 20, 2022
1 parent 443531f commit 883d2fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion appendices/ini.list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<entry><link linkend="ini.assert.quiet-eval">assert.quiet_eval</link></entry>
<entry>"0"</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
<entry>Removed as of PHP 8.0.0</entry>
</row>
<row>
<entry><link linkend="ini.assert.warning">assert.warning</link></entry>
Expand Down
1 change: 1 addition & 0 deletions reference/info/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<entry>assert.quiet_eval</entry>
<entry>
Disable <literal>error_reporting</literal> during assertion expression evaluation.
Removed as of PHP 8.0.0.
</entry>
</row>
</tbody>
Expand Down
12 changes: 11 additions & 1 deletion reference/info/functions/assert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<warning>
<para>
Using <type>string</type> as the <parameter>assertion</parameter> is
<emphasis>DEPRECATED</emphasis> as of PHP 7.2.
<emphasis>DEPRECATED</emphasis> as of PHP 7.2.0 and <emphasis>REMOVED</emphasis> as of PHP 8.0.0.
</para>
</warning>
</listitem>
Expand Down Expand Up @@ -224,6 +224,16 @@
</row>
</thead>
<tbody>
<row>
<entry>8.0.0</entry>
<entry>
<function>assert()</function> will no longer evaluate string arguments, instead they will be
treated like any other argument. <code>assert($a == $b)</code> should be used instead of
<code>assert('$a == $b')</code>. The <literal>assert.quiet_eval</literal> &php.ini; directive and
the <constant>ASSERT_QUIET_EVAL</constant> constant have also been removed, as they would no longer
have any effect.
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Expand Down

0 comments on commit 883d2fe

Please sign in to comment.