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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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
 [2023-07-31 10:35 UTC] georgtr6574 at gmail dot com
Here information is given by you is too great it is very help for me thank you for this. (https://github.com.php)(https://www.myjdfaccount.net/)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC