Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ PHP NEWS
. Added support for negative string offsets in string offset syntax and
various string functions. (Francois)
. Added a form of the list() construct where keys can be specified. (Andrea)
. Number operators taking numeric strings now emit E_NOTICEs or E_WARNINGs
when given malformed numeric strings. (Andrea)
. (int), intval() where $base is 10 or unspecified, settype(), integer
operators and other conversions now always respect scientific notation in
numeric strings. (Andrea)

- FTP:
. Implemented FR #55651 (Option to ignore the returned FTP PASV address).
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ PHP 7.1 UPGRADE NOTES
- Core:
. 'void' can no longer be used as the name of a class, interface, or trait.
This applies to declarations, class_alias() and use statements.
. (int), intval() where $base is 10 or unspecified, settype(), integer
operators and other conversions now always respect scientific notation in
numeric strings.
(RFC: https://wiki.php.net/rfc/invalid_strings_in_arithmetic)

- JSON:
. When calling json_encode with JSON_UNESCAPED_UNICODE option, U+2028 and
Expand All @@ -37,6 +41,10 @@ PHP 7.1 UPGRADE NOTES
(RFC: https://wiki.php.net/rfc/negative-string-offsets)
. Added a form of the list() construct where keys can be specified.
(RFC: https://wiki.php.net/rfc/list_keys)
. Number operators taking numeric strings now emit "A non well formed numeric
string encountered" E_NOTICEs for leading-numeric strings, and "A
non-numeric string encountered" E_WARNINGs for non-numeric strings.
(RFC: https://wiki.php.net/rfc/invalid_strings_in_arithmetic)

========================================
3. Changes in SAPI modules
Expand Down
8 changes: 8 additions & 0 deletions Zend/tests/add_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--

Warning: A non-numeric value encountered in %s on line %d
int(75636)

Notice: A non well formed numeric value encountered in %s on line %d
int(951858)
int(48550510)
float(75661.68)

Warning: A non-numeric value encountered in %s on line %d
int(75636)

Notice: A non well formed numeric value encountered in %s on line %d
int(951858)
int(48550510)
float(75661.68)
Expand Down
5 changes: 5 additions & 0 deletions Zend/tests/add_007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--

Warning: A non-numeric value encountered in %s on line %d

Exception: Unsupported operand types

Warning: A non-numeric value encountered in %s on line %d

Fatal error: Uncaught Error: Unsupported operand types in %s:%d
Stack trace:
#0 {main}
Expand Down
4 changes: 3 additions & 1 deletion Zend/tests/constant_expressions_dynamic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ var_dump(
);

?>
--EXPECT--
--EXPECTF--

Warning: A non-numeric value encountered in %s on line %d
int(3)
string(4) "1foo"
bool(false)
Expand Down
52 changes: 52 additions & 0 deletions Zend/tests/int_conversion_exponents.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--TEST--
Integer conversion from scientific notation
--FILE--
<?php

var_dump((int)"1.2345e9");
var_dump((int)"-1.2345e9");
var_dump(intval("1.2345e9"));
var_dump(intval("-1.2345e9"));
var_dump("1.2345e9" % PHP_INT_MAX);
var_dump("-1.2345e9" % PHP_INT_MIN);
var_dump("1.2345e9" | 0);
var_dump("-1.2345e9" | 0);

echo PHP_EOL;

var_dump((int)" 1.2345e9 abc");
var_dump((int)" -1.2345e9 abc");
var_dump(intval(" 1.2345e9 abc"));
var_dump(intval(" -1.2345e9 abc"));
var_dump(" 1.2345e9 abc" % PHP_INT_MAX);
var_dump(" -1.2345e9 abc" % PHP_INT_MIN);
var_dump(" 1.2345e9 abc" | 0);
var_dump(" -1.2345e9 abc" | 0);

?>
--EXPECTF--
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)

int(1234500000)
int(-1234500000)
int(1234500000)
int(-1234500000)

Notice: A non well formed numeric value encountered in %s on line %d
int(1234500000)

Notice: A non well formed numeric value encountered in %s on line %d
int(-1234500000)

Notice: A non well formed numeric value encountered in %s on line %d
int(1234500000)

Notice: A non well formed numeric value encountered in %s on line %d
int(-1234500000)
195 changes: 195 additions & 0 deletions Zend/tests/numeric_string_errors.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
--TEST--
Invalid numeric string E_WARNINGs and E_NOTICEs
--FILE--
<?php

var_dump("2 Lorem" + "3 ipsum");
var_dump("dolor" + "sit");
echo "---", PHP_EOL;
var_dump("5 amet," - "7 consectetur");
var_dump("adipiscing" - "elit,");
echo "---", PHP_EOL;
var_dump("11 sed" * "13 do");
var_dump("eiusmod" * "tempor");
echo "---", PHP_EOL;
var_dump("17 incididunt" / "19 ut");
var_dump("labore" / "et");
echo "---", PHP_EOL;
var_dump("23 dolore" ** "29 magna");
var_dump("aliqua." ** "Ut");
echo "---", PHP_EOL;
var_dump("31 enim" % "37 ad");
try {
var_dump("minim" % "veniam,");
} catch (DivisionByZeroError $e) {
}
echo "---", PHP_EOL;
var_dump("41 minim" << "43 veniam,");
var_dump("quis" << "nostrud");
echo "---", PHP_EOL;
var_dump("47 exercitation" >> "53 ullamco");
var_dump("laboris" >> "nisi");
echo "---", PHP_EOL;
var_dump("59 ut" | 61);
var_dump(67 | "71 aliquip");
var_dump("ex" | 73);
var_dump(79 | "ea");
echo "---", PHP_EOL;
var_dump("83 commodo" & 89);
var_dump(97 & "101 consequat.");
var_dump("Duis" & 103);
var_dump(107 & "aute");
echo "---", PHP_EOL;
var_dump("109 irure" ^ 113);
var_dump(127 ^ "131 dolor");
var_dump("in" ^ 137);
var_dump(139 ^ "reprehenderit");
echo "---", PHP_EOL;
var_dump(+"149 in");
var_dump(+"voluptate");
echo "---", PHP_EOL;
var_dump(-"151 velit");
var_dump(-"esse");
?>
--EXPECTF--

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
int(5)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
int(-2)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
int(143)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
float(0.89473684210526)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d

Warning: Division by zero in %s on line %d
float(NAN)
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
float(3.0910586430935E+39)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
int(1)
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
int(31)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
int(360639813910528)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d

Notice: A non well formed numeric value encountered in %s on line %d
int(0)

Warning: A non-numeric value encountered in %s on line %d

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d
int(63)

Notice: A non well formed numeric value encountered in %s on line %d
int(71)

Warning: A non-numeric value encountered in %s on line %d
int(73)

Warning: A non-numeric value encountered in %s on line %d
int(79)
---

Notice: A non well formed numeric value encountered in %s on line %d
int(81)

Notice: A non well formed numeric value encountered in %s on line %d
int(97)

Warning: A non-numeric value encountered in %s on line %d
int(0)

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d
int(28)

Notice: A non well formed numeric value encountered in %s on line %d
int(252)

Warning: A non-numeric value encountered in %s on line %d
int(137)

Warning: A non-numeric value encountered in %s on line %d
int(139)
---

Notice: A non well formed numeric value encountered in %s on line %d
int(149)

Warning: A non-numeric value encountered in %s on line %d
int(0)
---

Notice: A non well formed numeric value encountered in %s on line %d
int(-151)

Warning: A non-numeric value encountered in %s on line %d
int(0)
Loading