Req #10657 [Opn]: Add warning about overflow to settype()

From: Date: Fri, 20 Jan 2017 17:43:56 +0000
Subject: Req #10657 [Opn]: Add warning about overflow to settype()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206776@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=10657&edit=1 ID: 10657 Updated by: nikic@php.net Reported by: tf at tfromm dot com Summary: Add warning about overflow to settype() Status: Open Type: Feature/Change Request Package: Variables related Operating System: linux PHP Version: 7.1.1 Block user comment: N Private report: N New Comment: settype() behaves the same as an (int) cast. I highly doubt that we'd add such a warning for (int) casting. Previous Comments: ------------------------------------------------------------------------ [2017-01-20 17:30:39] requinix@php.net settype is not issuing warnings. https://3v4l.org/LSBfU - numeric string >PHP_INT_MAX to int https://3v4l.org/LT5dX - non-numeric string to int ------------------------------------------------------------------------ [2017-01-20 17:05:31] heiglandreas@php.net Is this still relevant? ------------------------------------------------------------------------ [2014-11-06 19:28:25] requinix@php.net Can't be closed quite yet, Edgar: you're using a 64-bit PHP which can handle 11111111112 as an integer. Try with 9999999999999999999. ------------------------------------------------------------------------ [2014-11-05 20:55:14] edgar dot r dot sandi at gmail dot com Related To: Bug #10657 ------------------------------------------------------------------------ [2014-11-05 20:55:13] edgar dot r dot sandi at gmail dot com This script was created and tested in PHP 5.5.8 and PHP 5.6.2 with both situations described in this Request and the outputs were correct with expected. This request can be closed. --TEST-- // phpt file: request10657.phpt Request #10657 Add warning about overflow to settype() --FILE-- <?php // overflow integer $foo = '11111111112'; settype($foo, "integer"); var_dump($foo); // string -> integer $bar = 'fjsfjsdh'; settype($bar, "integer"); var_dump($bar); ?> --EXPECT-- int(11111111112) int(0) ------------------------------------------------------------------------ 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=10657 -- Edit this bug report at https://bugs.php.net/bug.php?id=10657&edit=1

« previous php.bugs (#206776) next »