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: 2024-07-28 04:22 UTC
From: gib-o-master at mail dot ru Assigned: cmb (profile)
Status: No Feedback Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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
 [2024-07-19 21:29 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2024-07-19 21:29 UTC] cmb@php.net
> i'll try

Did you succeed?
 [2024-07-28 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC