Am 26.06.2025 um 14:04 schrieb Gina P. Banyard <intern...@gpb.moe>:
> On Monday, 2 June 2025 at 17:11, Gina P. Banyard <intern...@gpb.moe> wrote:
> 
>> Hello internals,
>> 
>> This is the first RFC out of a set of type system related RFCs I want to 
>> propose for PHP 8.5.
>> It also used the recently enabled Markdown support on the wiki, so there 
>> might be a few oddities.
>> 
>> The RFC proposes to deprecate implicit type coercions to and from the bool 
>> type for other scalar types.
>> This a "weak" mode change only, as when strict_types are enabled none of 
>> these coercions can happen.
>> 
>> Let me know what you think about it.
>> 
>> RFC: https://wiki.php.net/rfc/deprecate-function-bool-type-juggling
> 
> I have updated the RFC to version 0.2 that expands on it and addresses some 
> of the counterarguments which were said during the discussion.
> RFC: https://wiki.php.net/rfc/deprecate-function-bool-type-juggling
> 
> If there is no-follow up feedback, I will open the vote for it sometime next 
> week.

The RFC talks about "from" AND "to" bool conversion but the examples under 
Backward Incompatible Changes only seem mention "from" bool, is that correct?

I tried the implementation in branch bool-juggling-dep-poc on 
https://github.com/Girgias/php-src.git and encountered two things:
- php -r 'strlen(false);' produced a core dump with Zend/zend_API.c:561: 
zend_arg_from_bool_deprecated: Assertion `func->common.fn_flags & (1 << 14)' 
failed.
- array_slice($a, 1, preserve_keys:"a") did not produce a warning even though I 
would have thought that is a "to" bool conversion. Am I wrong? What should I 
test instead?

So far the "from" conversion warnings need changes in very few places in our 
setup (we very occasionally use false as out-of-band signalling and use the 
side-effect that strlen() can check both for empty string and false at the same 
time but that can be easily adapted), our lesson from the nullable parameter 
that composer packages are the more interesting caveat than our our own but so 
far nothing popped up.

Summary: I am mostly positive about the "from" part, I don't think I was able 
to test the "to" part and I'm not sure why I triggered an assertion.

Regards,
- Chris

Reply via email to