php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81609 NO string casting/comparison WITH strict_types=1
Submitted: 2021-11-11 04:13 UTC Modified: 2021-11-11 10:31 UTC
From: gib-o-master at mail dot ru Assigned:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gib-o-master at mail dot ru
New email:
PHP Version: OS:

 

 [2021-11-11 04:13 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-11 10:31 UTC] 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-13 00:55 UTC] gib-o-master at mail dot ru
i'll try
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Jan 23 05:03:35 2022 UTC