Req #81609 [Com]: NO string casting/comparison WITH strict_types=1

From: Date: Sat, 13 Nov 2021 00:55:56 +0000
Subject: Req #81609 [Com]: NO string casting/comparison WITH strict_types=1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237742@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81609&edit=1

 ID:                 81609
 Comment by:         gib-o-master at mail dot ru
 Reported by:        gib-o-master at mail dot ru
 Summary:            NO string casting/comparison WITH strict_types=1
 Status:             Open
 Type:               Feature/Change Request
 Package:            *General Issues
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

i'll try


Previous Comments:
------------------------------------------------------------------------
[2021-11-11 10:31:11] cmb@php.net

That change would certainly require the RFC process[1].  Maybe you
want to pursue it?

[1] <https://wiki.php.net/rfc/howto>

------------------------------------------------------------------------
[2021-11-11 04:13:30] gib-o-master at mail dot ru

Description:
------------
if there is a declare(strict_types=1); string to number casting should be avoided, for
example:

var_dump('20' < '3');// is false

Pros/Cons:

+ it will be faster (no if string is a number check, no casting)
+ it will be common (with strings, compat with other langs like JS, Python)
+ it will be more error prone (because it's common)

- some old code which rely on this feature will break (does it exist?)









Test script:
---------------
var_dump('20' < '3');

Expected result:
----------------
true

Actual result:
--------------
false


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81609&edit=1


Thread (4 messages)

« previous php.bugs (#237742) next »