|
| 1 | +<?php |
| 2 | + |
| 3 | +// Verification for constant types: https://3v4l.org/96GSj |
| 4 | + |
| 5 | +/** @var mixed $mixed */ |
| 6 | +$mixed = getMixed(); |
| 7 | + |
| 8 | +/** @var int $iUnknown */ |
| 9 | +$iUnknown = getInt(); |
| 10 | + |
| 11 | +/** @var string $string */ |
| 12 | +$string = getString(); |
| 13 | + |
| 14 | +$iNeg = -5; |
| 15 | +$iPos = 5; |
| 16 | +$nonNumeric = 'foo'; |
| 17 | + |
| 18 | + |
| 19 | +// bcdiv ( string $dividend , string $divisor [, ?int $scale = null ] ) : string |
| 20 | +// Returns the result of the division as a numeric-string. |
| 21 | +\PHPStan\Testing\assertType('*NEVER*', bcdiv('10', '0')); // DivisionByZeroError |
| 22 | +\PHPStan\Testing\assertType('*NEVER*', bcdiv('10', '0.0')); // DivisionByZeroError |
| 23 | +\PHPStan\Testing\assertType('*NEVER*', bcdiv('10', 0.0)); // DivisionByZeroError |
| 24 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', '1')); |
| 25 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', '-1')); |
| 26 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', '2', 0)); |
| 27 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', '2', 1)); |
| 28 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', $iNeg)); |
| 29 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', $iPos)); |
| 30 | +\PHPStan\Testing\assertType('numeric-string', bcdiv($iPos, $iPos)); |
| 31 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', $mixed)); |
| 32 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', $iPos, $iPos)); |
| 33 | +\PHPStan\Testing\assertType('numeric-string', bcdiv('10', $iUnknown)); |
| 34 | +\PHPStan\Testing\assertType('*NEVER*', bcdiv('10', $iPos, $nonNumeric)); // ValueError argument 3 |
| 35 | +\PHPStan\Testing\assertType('*NEVER*', bcdiv('10', $nonNumeric)); // ValueError argument 2 |
| 36 | + |
| 37 | +// bcmod ( string $dividend , string $divisor [, ?int $scale = null ] ) : string |
| 38 | +// Returns the modulus as a numeric-string. |
| 39 | +\PHPStan\Testing\assertType('*NEVER*', bcmod('10', '0')); // DivisionByZeroError |
| 40 | +\PHPStan\Testing\assertType('*NEVER*', bcmod($iPos, '0')); // DivisionByZeroError |
| 41 | +\PHPStan\Testing\assertType('*NEVER*', bcmod('10', $nonNumeric)); // ValueError argument 2 |
| 42 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', '1')); |
| 43 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', '2', 0)); |
| 44 | +\PHPStan\Testing\assertType('numeric-string', bcmod('5.7', '1.3', 1)); |
| 45 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', 2.2)); |
| 46 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', $iUnknown)); |
| 47 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', '-1')); |
| 48 | +\PHPStan\Testing\assertType('numeric-string', bcmod($iPos, '-1')); |
| 49 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', $iNeg)); |
| 50 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', $iPos)); |
| 51 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', -$iNeg)); |
| 52 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', -$iPos)); |
| 53 | +\PHPStan\Testing\assertType('numeric-string', bcmod('10', $mixed)); |
| 54 | + |
| 55 | +// bcpowmod ( string $base , string $exponent , string $modulus [, ?int $scale = null ] ) : string |
| 56 | +// Returns the result as a numeric-string, or FALSE if modulus is 0 or exponent is negative. |
| 57 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '-2', '0')); // ValueError argument 2 |
| 58 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '-2', '1')); // ValueError argument 2 |
| 59 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '2', $nonNumeric)); // ValueError argument 3 |
| 60 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '-2', '-1')); // ValueError argument 2 |
| 61 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '-2', -1.3)); // ValueError argument 2 |
| 62 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', -$iPos, '-1')); // ValueError argument 2 |
| 63 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', -$iPos, '1')); // ValueError argument 2 |
| 64 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', $nonNumeric, $nonNumeric)); // ValueError argument 2 |
| 65 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod($iPos, $nonNumeric, $nonNumeric)); |
| 66 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '2', '0')); // modulus is 0 |
| 67 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', 2.3, '0')); // modulus is 0 |
| 68 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', '0', '0')); // modulus is 0 |
| 69 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', '0', '-2')); |
| 70 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', '2', '2')); |
| 71 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', $iUnknown, '2')); |
| 72 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod($iPos, '2', '2')); |
| 73 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', $mixed, $mixed)); |
| 74 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', '2', '2')); |
| 75 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', -$iNeg, '2')); |
| 76 | +\PHPStan\Testing\assertType('*NEVER*', bcpowmod('10', $nonNumeric, '2')); // ValueError argument 2 |
| 77 | +\PHPStan\Testing\assertType('numeric-string', bcpowmod('10', $iUnknown, $iUnknown)); |
| 78 | + |
| 79 | +// bcsqrt ( string $operand [, ?int $scale = null ] ) : string |
| 80 | +// Returns the square root as a numeric-string. |
| 81 | +\PHPStan\Testing\assertType('*NEVER*', bcsqrt('10', $iNeg)); // ValueError argument 2 |
| 82 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt('10', 1)); |
| 83 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt('0.00', 1)); |
| 84 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt(0.0, 1)); |
| 85 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt('0', 1)); |
| 86 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt($iUnknown, $iUnknown)); |
| 87 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt('10', $iPos)); |
| 88 | +\PHPStan\Testing\assertType('*NEVER*', bcsqrt('-10', 0)); // ValueError argument 1 |
| 89 | +\PHPStan\Testing\assertType('*NEVER*', bcsqrt($iNeg, null)); // ValueError argument 1 |
| 90 | +\PHPStan\Testing\assertType('*NEVER*', bcsqrt('10', $nonNumeric)); // ValueError argument 2 |
| 91 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt('10')); |
| 92 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt($iUnknown)); |
| 93 | +\PHPStan\Testing\assertType('*NEVER*', bcsqrt('-10')); // ValueError argument 1 |
| 94 | + |
| 95 | +\PHPStan\Testing\assertType('*NEVER*', bcsqrt($nonNumeric, -1)); // ValueError argument 1 |
| 96 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt('10', $mixed)); |
| 97 | +\PHPStan\Testing\assertType('numeric-string', bcsqrt($iPos)); |
0 commit comments