|
| 1 | +--TEST-- |
| 2 | +Test Z_PARAM_OBJ_OF_CLASS_OR_LONG() and Z_PARAM_OBJ_OF_CLASS_OR_LONG_OR_NULL() (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_obj_stdclass_or_int($type)); |
| 16 | + } catch (Throwable $e) { |
| 17 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 18 | + } |
| 19 | + try { |
| 20 | + var_dump(zend_obj_stdclass_or_int_or_null($type)); |
| 21 | + } catch (Throwable $e) { |
| 22 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +?> |
| 27 | +--EXPECT-- |
| 28 | +Using null: |
| 29 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, null given |
| 30 | +NULL |
| 31 | +Using false: |
| 32 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, false given |
| 33 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, false given |
| 34 | +Using true: |
| 35 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, true given |
| 36 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, true given |
| 37 | +Using 42: |
| 38 | +int(42) |
| 39 | +int(42) |
| 40 | +Using 73.5: |
| 41 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, float given |
| 42 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, float given |
| 43 | +Using 'string': |
| 44 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given |
| 45 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given |
| 46 | +Using '15': |
| 47 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given |
| 48 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given |
| 49 | +Using '56.7': |
| 50 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given |
| 51 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given |
| 52 | +Using 'stdClass': |
| 53 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given |
| 54 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given |
| 55 | +Using anon class name: |
| 56 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, string given |
| 57 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, string given |
| 58 | +Using []: |
| 59 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, array given |
| 60 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, array given |
| 61 | +Using new stdClass(): |
| 62 | +object(stdClass)#2 (0) { |
| 63 | +} |
| 64 | +object(stdClass)#2 (0) { |
| 65 | +} |
| 66 | +Using new S(): |
| 67 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, S given |
| 68 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, S given |
| 69 | +Using STDOUT: |
| 70 | +TypeError: zend_obj_stdclass_or_int(): Argument #1 ($param) must be of type stdClass|int, resource given |
| 71 | +TypeError: zend_obj_stdclass_or_int_or_null(): Argument #1 ($param) must be of type stdClass|int|null, resource given |
0 commit comments