1--TEST-- 2Inc/dec various types 3--FILE-- 4<?php 5 6/* Type errors */ 7$types = [[], new stdClass(), fopen(__FILE__, 'r')]; 8 9foreach ($types as $type) { 10 try { 11 $type++; 12 } catch (\TypeError $e) { 13 echo $e->getMessage(), PHP_EOL; 14 } 15 try { 16 $type--; 17 } catch (\TypeError $e) { 18 echo $e->getMessage(), PHP_EOL; 19 } 20} 21 22echo "Using increment:\n"; 23$values = [null, false, true, 0, 0.0, '', ' ', '0']; 24foreach ($values as $value) { 25 echo "Initial value:"; 26 var_dump($value); 27 $value++; 28 echo "Result value:"; 29 var_dump($value); 30} 31 32echo "Using decrement:\n"; 33$values = [null, false, true, 0, 0.0, '', ' ', '0']; 34foreach ($values as $value) { 35 echo "Initial value:"; 36 var_dump($value); 37 $value--; 38 echo "Result value:"; 39 var_dump($value); 40} 41?> 42--EXPECTF-- 43Cannot increment array 44Cannot decrement array 45Cannot increment stdClass 46Cannot decrement stdClass 47Cannot increment resource 48Cannot decrement resource 49Using increment: 50Initial value:NULL 51Result value:int(1) 52Initial value:bool(false) 53 54Warning: Increment on type bool has no effect, this will change in the next major version of PHP in %s on line %d 55Result value:bool(false) 56Initial value:bool(true) 57 58Warning: Increment on type bool has no effect, this will change in the next major version of PHP in %s on line %d 59Result value:bool(true) 60Initial value:int(0) 61Result value:int(1) 62Initial value:float(0) 63Result value:float(1) 64Initial value:string(0) "" 65 66Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d 67Result value:string(1) "1" 68Initial value:string(1) " " 69 70Deprecated: Increment on non-alphanumeric string is deprecated in %s on line %d 71Result value:string(1) " " 72Initial value:string(1) "0" 73Result value:int(1) 74Using decrement: 75Initial value:NULL 76 77Warning: Decrement on type null has no effect, this will change in the next major version of PHP in %s on line %d 78Result value:NULL 79Initial value:bool(false) 80 81Warning: Decrement on type bool has no effect, this will change in the next major version of PHP in %s on line %d 82Result value:bool(false) 83Initial value:bool(true) 84 85Warning: Decrement on type bool has no effect, this will change in the next major version of PHP in %s on line %d 86Result value:bool(true) 87Initial value:int(0) 88Result value:int(-1) 89Initial value:float(0) 90Result value:float(-1) 91Initial value:string(0) "" 92 93Deprecated: Decrement on empty string is deprecated as non-numeric in %s on line %d 94Result value:int(-1) 95Initial value:string(1) " " 96 97Deprecated: Decrement on non-numeric string has no effect and is deprecated in %s on line %d 98Result value:string(1) " " 99Initial value:string(1) "0" 100Result value:int(-1) 101