Bug #71100 [Opn]: long2ip() doesn't accept integers in strict mode
| From: | laruence@php.net | Date: | Sat, 12 Dec 2015 06:35:50 +0000 |
| Subject: | Bug #71100 [Opn]: long2ip() doesn't accept integers in strict mode | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197826@lists.php.net to get a copy of this message | ||
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: Open
Type: Bug
Package: *Network Functions
Operating System: Linux
PHP Version: 7.0.0
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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