xref: /PHP-8.1/Zend/tests/increment_001.phpt (revision fbe30592)
1--TEST--
2incrementing different variables
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?>
5--INI--
6precision=14
7--FILE--
8<?php
9
10$a = array(
11    array(1,2,3),
12    "",
13    1,
14    2.5,
15    0,
16    "string",
17    "123",
18    "2.5",
19    NULL,
20    true,
21    false,
22    new stdclass,
23    array(),
24    PHP_INT_MAX,
25    (string)PHP_INT_MAX
26);
27
28foreach ($a as $var) {
29    try {
30        $var++;
31    } catch (TypeError $e) {
32        echo $e->getMessage(), "\n";
33    }
34    var_dump($var);
35}
36
37echo "Done\n";
38?>
39--EXPECTF--
40Cannot increment array
41array(3) {
42  [0]=>
43  int(1)
44  [1]=>
45  int(2)
46  [2]=>
47  int(3)
48}
49string(1) "1"
50int(2)
51float(3.5)
52int(1)
53string(6) "strinh"
54int(124)
55float(3.5)
56int(1)
57bool(true)
58bool(false)
59Cannot increment stdClass
60object(stdClass)#%d (0) {
61}
62Cannot increment array
63array(0) {
64}
65float(2147483648)
66float(2147483648)
67Done
68