Bug #71100 [Wfx->Csd]: long2ip() doesn't accept integers in strict mode
Edit report at https://bugs.php.net/bug.php?id=71100&edit=1
ID: 71100
Updated by: laruence@php.net
Reported by: anthonyryan1 at gmail dot com
Summary: long2ip() doesn't accept integers in strict mode
-Status: Wont fix
+Status: Closed
Type: Bug
Package: *Network Functions
Operating System: Linux
PHP Version: 7.0.0
Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9b148d31d3e19ce8c726ebbab3ba6a9a24979a2f
Log: Fixed bug #71100 (long2ip() doesn't accept integers in strict mode)
Previous Comments:
------------------------------------------------------------------------
[2015-12-13 18:14:50] anthonyryan1 at gmail dot com
I see your point. What is the next PHP version this change could be considered for?
Based on what you're saying, am I correct in understanding a pull request fixing this would be
accepted into master for a future (major) PHP release?
------------------------------------------------------------------------
[2015-12-13 05:32:56] laruence@php.net
hmm, changing long2ip accept integer instead of string will break something in non strict_types
like:
long2ip("");
thus I will only fixed this in master
------------------------------------------------------------------------
[2015-12-12 06:35:49] laruence@php.net
That is why it cause "strict_types"
from doc:
string long2ip ( string $proper_address )
and
int ip2long ( string $ip_address )
it's better we change long2ip accept long instead of string.
anyway, this is a little similar with #71053, I will also considered this case
thanks
------------------------------------------------------------------------
[2015-12-12 06:21:51] anthonyryan1 at gmail dot com
Description:
------------
long2ip()'s expected input type does not match up with the output type of ip2long(), in strict
mode passing an integer causes a TypeError to be thrown.
Test script:
---------------
<?php
declare(strict_types=1);
var_dump(long2ip(ip2long('127.0.0.1')));
Expected result:
----------------
long2ip()'s expected input type to be an integer in strict mode.
Actual result:
--------------
PHP Fatal error: Uncaught TypeError: long2ip() expects parameter 1 to be string, integer given in
test-script.php:4
Stack trace:
#0 test-script.php(4): long2ip(2130706433)
#1 {main}
thrown in test-script.php on line 4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71100&edit=1
Thread (5 messages)