1--TEST--
2Acceptance of whitespace in numeric strings
3--FILE--
4<?php
5
6$strings = [
7    "123",
8    "123   ",
9    "123 \t\n\r\v\f",
10    "   123",
11    " \t\n\r\v\f123",
12    "   123   ",
13    " \t\n\r\v\f123 \t\n\r\v\f",
14    "123.0",
15    "123.0   ",
16    "123.0 \t\n\r\v\f",
17    "   123.0",
18    " \t\n\r\v\f123.0",
19    "   123.0   ",
20    " \t\n\r\v\f123 \t\n\r\v\f",
21    "123e0",
22    "123e0   ",
23    "123e0 \t\n\r\v\f",
24    "   123e0",
25    " \t\n\r\v\f123e0",
26    "   123e0   ",
27    " \t\n\r\v\f123e0 \t\n\r\v\f"
28];
29
30function takes_integer(int $i) {
31    \assert($i === 123);
32}
33function takes_float(float $f) {
34    \assert($f === 123.0);
35}
36
37foreach ($strings as $string) {
38    \assert($string == 123);
39    $num = +$string;
40    \assert($num == 123);
41    takes_integer($string);
42    takes_float($string);
43    \assert(\intdiv($string, 1) === 123);
44    \assert(\is_numeric($string));
45    $incremented = $string;
46    ++$incremented;
47    \assert(\is_int($incremented) || \is_float($incremented));
48    \assert($incremented == 124);
49    $decremented = $string;
50    --$decremented;
51    \assert(\is_int($decremented) || \is_float($decremented));
52    \assert($decremented == 122);
53}
54
55echo "OK!", PHP_EOL;
56
57?>
58--EXPECT--
59OK!
60