xref: /PHP-8.1/Zend/tests/decrement_001.phpt (revision fbe30592)
1--TEST--
2decrementing 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-1,
25    (string)(-PHP_INT_MAX-1),
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 decrement array
41array(3) {
42  [0]=>
43  int(1)
44  [1]=>
45  int(2)
46  [2]=>
47  int(3)
48}
49int(-1)
50int(0)
51float(1.5)
52int(-1)
53string(6) "string"
54int(122)
55float(1.5)
56NULL
57bool(true)
58bool(false)
59Cannot decrement stdClass
60object(stdClass)#%d (0) {
61}
62Cannot decrement array
63array(0) {
64}
65float(-2147483649)
66float(-2147483649)
67Done
68