|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Bug14136Nsrt; |
| 4 | + |
| 5 | +use function PHPStan\Testing\assertType; |
| 6 | + |
| 7 | +$xml = <<<'EOT' |
| 8 | +<?xml version="1.0"?><item>3</item> |
| 9 | +EOT; |
| 10 | + |
| 11 | +$xml = simplexml_load_string($xml); |
| 12 | +assertType('int', intval($xml)); |
| 13 | +assertType('int', intval(gmp_init(42))); |
| 14 | +assertType('int', (int) ($xml)); |
| 15 | +assertType('int', (int) (gmp_init(42))); |
| 16 | + |
| 17 | +assertType('float', floatval($xml)); |
| 18 | +assertType('float', floatval(gmp_init(42))); |
| 19 | +assertType('float', (float) ($xml)); |
| 20 | +assertType('float', (float) (gmp_init(42))); |
| 21 | + |
| 22 | +assertType('string', strval($xml)); |
| 23 | +assertType('non-empty-string&numeric-string', strval(gmp_init(42))); |
| 24 | +assertType('non-empty-string&numeric-string', strval(new \BCMath\Number(99))); |
| 25 | +assertType('string', (string) ($xml)); |
| 26 | +assertType('non-empty-string&numeric-string', (string) (gmp_init(42))); |
| 27 | +assertType('non-empty-string&numeric-string', (string) new \BCMath\Number(99)); |
| 28 | + |
| 29 | +assertType('bool', boolval($xml)); |
| 30 | +assertType('bool', boolval(gmp_init(0))); |
| 31 | +assertType('bool', boolval(new \BCMath\Number(0))); |
| 32 | +assertType('bool', (bool) ($xml)); |
| 33 | +assertType('bool', (bool) (gmp_init(0))); |
| 34 | +assertType('bool', (bool) (new \BCMath\Number(0))); |
0 commit comments