|
| 1 | +--TEST-- |
| 2 | +Test bool ZPP specifier (strict_mode) |
| 3 | +--EXTENSIONS-- |
| 4 | +zend_test |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +$types = require 'types.inc'; |
| 11 | + |
| 12 | +foreach ($types as $name => $type) { |
| 13 | + echo "Using $name:\n"; |
| 14 | + try { |
| 15 | + var_dump(zend_bool($type)); |
| 16 | + } catch (Throwable $e) { |
| 17 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 18 | + } |
| 19 | + try { |
| 20 | + var_dump(zend_bool_or_null($type)); |
| 21 | + } catch (Throwable $e) { |
| 22 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 23 | + } |
| 24 | + try { |
| 25 | + var_dump(zend_bool_slow_zpp($type)); |
| 26 | + } catch (Throwable $e) { |
| 27 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 28 | + } |
| 29 | + try { |
| 30 | + var_dump(zend_bool_or_null_slow_zpp($type)); |
| 31 | + } catch (Throwable $e) { |
| 32 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 33 | + } |
| 34 | + $ref =& $type; |
| 35 | + try { |
| 36 | + var_dump(zend_bool($ref)); |
| 37 | + } catch (Throwable $e) { |
| 38 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 39 | + } |
| 40 | + try { |
| 41 | + var_dump(zend_bool_or_null($ref)); |
| 42 | + } catch (Throwable $e) { |
| 43 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 44 | + } |
| 45 | + try { |
| 46 | + var_dump(zend_bool_slow_zpp($ref)); |
| 47 | + } catch (Throwable $e) { |
| 48 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 49 | + } |
| 50 | + try { |
| 51 | + var_dump(zend_bool_or_null_slow_zpp($ref)); |
| 52 | + } catch (Throwable $e) { |
| 53 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +?> |
| 58 | +--EXPECT-- |
| 59 | +Using null: |
| 60 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, null given |
| 61 | +NULL |
| 62 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, null given |
| 63 | +NULL |
| 64 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, null given |
| 65 | +NULL |
| 66 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, null given |
| 67 | +NULL |
| 68 | +Using false: |
| 69 | +bool(false) |
| 70 | +bool(false) |
| 71 | +bool(false) |
| 72 | +bool(false) |
| 73 | +bool(false) |
| 74 | +bool(false) |
| 75 | +bool(false) |
| 76 | +bool(false) |
| 77 | +Using true: |
| 78 | +bool(true) |
| 79 | +bool(true) |
| 80 | +bool(true) |
| 81 | +bool(true) |
| 82 | +bool(true) |
| 83 | +bool(true) |
| 84 | +bool(true) |
| 85 | +bool(true) |
| 86 | +Using 42: |
| 87 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, int given |
| 88 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, int given |
| 89 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, int given |
| 90 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, int given |
| 91 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, int given |
| 92 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, int given |
| 93 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, int given |
| 94 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, int given |
| 95 | +Using 73.5: |
| 96 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, float given |
| 97 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, float given |
| 98 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, float given |
| 99 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, float given |
| 100 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, float given |
| 101 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, float given |
| 102 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, float given |
| 103 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, float given |
| 104 | +Using 'string': |
| 105 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 106 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 107 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 108 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 109 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 110 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 111 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 112 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 113 | +Using '15': |
| 114 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 115 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 116 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 117 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 118 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 119 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 120 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 121 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 122 | +Using '56.7': |
| 123 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 124 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 125 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 126 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 127 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 128 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 129 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 130 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 131 | +Using 'stdClass': |
| 132 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 133 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 134 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 135 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 136 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 137 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 138 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 139 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 140 | +Using anon class name: |
| 141 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 142 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 143 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 144 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 145 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, string given |
| 146 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, string given |
| 147 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, string given |
| 148 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, string given |
| 149 | +Using []: |
| 150 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given |
| 151 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given |
| 152 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given |
| 153 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given |
| 154 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, array given |
| 155 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, array given |
| 156 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, array given |
| 157 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, array given |
| 158 | +Using new stdClass(): |
| 159 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given |
| 160 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given |
| 161 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given |
| 162 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given |
| 163 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, stdClass given |
| 164 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, stdClass given |
| 165 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, stdClass given |
| 166 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, stdClass given |
| 167 | +Using new S(): |
| 168 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given |
| 169 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given |
| 170 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given |
| 171 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given |
| 172 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, S given |
| 173 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, S given |
| 174 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, S given |
| 175 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, S given |
| 176 | +Using STDOUT: |
| 177 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given |
| 178 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given |
| 179 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given |
| 180 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given |
| 181 | +TypeError: zend_bool(): Argument #1 ($param) must be of type bool, resource given |
| 182 | +TypeError: zend_bool_or_null(): Argument #1 ($param) must be of type ?bool, resource given |
| 183 | +TypeError: zend_bool_slow_zpp(): Argument #1 ($param) must be of type bool, resource given |
| 184 | +TypeError: zend_bool_or_null_slow_zpp(): Argument #1 ($param) must be of type ?bool, resource given |
0 commit comments