Disallow dynamic calls to assert()?

From: Date: Fri, 09 May 2025 07:32:17 +0000
Subject: Disallow dynamic calls to assert()?
Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi

I noticed that dynamic calls to the assert() function do not take the zend.assertions into account, since for static calls zend.assertions is checked inside the compiler to completely bypass the call to assert() including the evaluation of all arguments. I created a PR to fix that, making dynamic calls to assert always return true just like static calls:

https://github.com/php/php-src/pull/18521

However these dynamic calls still evaluate their arguments, which makes for a behavioral difference that might be confusing. Niels rightfully pointed out that it is possible to forbid dynamic calls to a given function, this is already used for things like compact() or func_get_args(). Disallowing dynamic calls to assert() would completely bypass this problem.

Does anyone have an opinion either way? Please comment on the GitHub issue if you do so: https://github.com/php/php-src/pull/18521#pullrequestreview-2825782965

Best regards
Tim Düsterhus


Thread (3 messages)

« previous php.internals (#127327) next »