Req #77010 [Opn->Csd]: is_numeric with numeric strings suffixed with a string should return true

From: Date: Sun, 14 Oct 2018 15:16:25 +0000
Subject: Req #77010 [Opn->Csd]: is_numeric with numeric strings suffixed with a string should return true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217554@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77010&edit=1

 ID:                 77010
 Updated by:         carusogabriel@php.net
 Reported by:        carusogabriel@php.net
 Summary:            is_numeric with numeric strings suffixed with a
                     string should return true
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   Irrelevant
 PHP Version:        Next major version
-Assigned To:        
+Assigned To:        carusogabriel
 Block user comment: N
 Private report:     N

 New Comment:

> Supporting non-numeric suffixes will conflict with https://wiki.php.net/rfc/invalid_strings_in_arithmetic

Indeed, we had that RFC. I'll close this ticket and refactor the current implementation on that
issue.

Thanks for the discussion.


Previous Comments:
------------------------------------------------------------------------
[2018-10-13 21:24:37] requinix@php.net

> we'd also consider a numeric string with a string suffixed
That I can understand.

Supporting non-numeric suffixes will conflict with https://wiki.php.net/rfc/invalid_strings_in_arithmetic
so I think this would have to go to an RFC.

------------------------------------------------------------------------
[2018-10-13 21:05:12] carusogabriel@php.net

> Numeric strings consist of optional sign, any number of digits, optional decimal part and
> optional exponential
> part. Thus +0123.45e6 is a valid numeric value.

Gotcha. So if we're going to take this further, we'd also consider a numeric string with a
string suffixed, for example: "7.3.0-beta1".

> (int)"x" === 0. Does that mean "x" is numeric?

Let's pretend I've never used that argument :P

------------------------------------------------------------------------
[2018-10-13 21:00:13] requinix@php.net

Well, according to the docs,
> Numeric strings consist of optional sign, any number of digits, optional decimal part and
> optional exponential
> part. Thus +0123.45e6 is a valid numeric value.

> I current judge everything that we can cast for an integer number, for example, as numeric
> numbers.
(int)"x" === 0. Does that mean "x" is numeric?

------------------------------------------------------------------------
[2018-10-13 20:56:43] carusogabriel@php.net

@requinix What do we consider as numbers, better, as numeric numbers in PHP?

I current judge everything that we can cast for an integer number, for example, as numeric numbers.

------------------------------------------------------------------------
[2018-10-13 20:49:47] requinix@php.net

"2.14.0-DEV" doesn't look like any number I've seen before.

So... what, if it starts with a digit then it's numeric? Should "1a" be numeric?

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=77010


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


Thread (7 messages)

« previous php.bugs (#217554) next »