1--TEST-- 2Test decoct() function : usage variations - different data types as $number arg 3--INI-- 4precision=14 5--SKIPIF-- 6<?php 7if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); 8?> 9--FILE-- 10<?php 11echo "*** Testing decoct() : usage variations ***\n"; 12//get an unset variable 13$unset_var = 10; 14unset ($unset_var); 15 16 17// heredoc string 18$heredoc = <<<EOT 19abc 20xyz 21EOT; 22 23// get a class 24class classA 25{ 26} 27 28// get a resource variable 29$fp = fopen(__FILE__, "r"); 30 31$inputs = array( 32 // int data 33/*1*/ 0, 34 1, 35 12345, 36 -2345, 37 18446744073709551615, // largest decimal 38 18446744073709551616, 39 40 // float data 41/*7*/ 10.5, 42 -10.5, 43 12.3456789000e10, 44 12.3456789000E-10, 45 .5, 46 47 // null data 48/*12*/ NULL, 49 null, 50 51 // boolean data 52/*14*/ true, 53 false, 54 TRUE, 55 FALSE, 56 57 // empty data 58/*18*/ "", 59 '', 60 array(), 61 62 // string data 63/*21*/ "abcxyz", 64 'abcxyz', 65 $heredoc, 66 67 // object data 68/*24*/ new classA(), 69 70 // undefined data 71/*25*/ @$undefined_var, 72 73 // unset data 74/*26*/ @$unset_var, 75 76 // resource variable 77/*27*/ $fp 78); 79 80// loop through each element of $inputs to check the behaviour of decoct() 81foreach($inputs as $i => $input) { 82 $iterator = $i + 1; 83 echo "\n-- Iteration $iterator --\n"; 84 try { 85 var_dump(decoct($input)); 86 } catch (TypeError $exception) { 87 echo $exception->getMessage() . "\n"; 88 } 89} 90fclose($fp); 91 92?> 93--EXPECT-- 94*** Testing decoct() : usage variations *** 95 96-- Iteration 1 -- 97string(1) "0" 98 99-- Iteration 2 -- 100string(1) "1" 101 102-- Iteration 3 -- 103string(5) "30071" 104 105-- Iteration 4 -- 106string(22) "1777777777777777773327" 107 108-- Iteration 5 -- 109decoct(): Argument #1 ($num) must be of type int, float given 110 111-- Iteration 6 -- 112decoct(): Argument #1 ($num) must be of type int, float given 113 114-- Iteration 7 -- 115string(2) "12" 116 117-- Iteration 8 -- 118string(22) "1777777777777777777766" 119 120-- Iteration 9 -- 121string(13) "1627646215010" 122 123-- Iteration 10 -- 124string(1) "0" 125 126-- Iteration 11 -- 127string(1) "0" 128 129-- Iteration 12 -- 130string(1) "0" 131 132-- Iteration 13 -- 133string(1) "0" 134 135-- Iteration 14 -- 136string(1) "1" 137 138-- Iteration 15 -- 139string(1) "0" 140 141-- Iteration 16 -- 142string(1) "1" 143 144-- Iteration 17 -- 145string(1) "0" 146 147-- Iteration 18 -- 148decoct(): Argument #1 ($num) must be of type int, string given 149 150-- Iteration 19 -- 151decoct(): Argument #1 ($num) must be of type int, string given 152 153-- Iteration 20 -- 154decoct(): Argument #1 ($num) must be of type int, array given 155 156-- Iteration 21 -- 157decoct(): Argument #1 ($num) must be of type int, string given 158 159-- Iteration 22 -- 160decoct(): Argument #1 ($num) must be of type int, string given 161 162-- Iteration 23 -- 163decoct(): Argument #1 ($num) must be of type int, string given 164 165-- Iteration 24 -- 166decoct(): Argument #1 ($num) must be of type int, classA given 167 168-- Iteration 25 -- 169string(1) "0" 170 171-- Iteration 26 -- 172string(1) "0" 173 174-- Iteration 27 -- 175decoct(): Argument #1 ($num) must be of type int, resource given 176