|
| 1 | +<?php declare(strict_types = 1); |
| 2 | + |
| 3 | +namespace ForbidArithmeticOperationOnNonNumberRule; |
| 4 | + |
| 5 | +use BcMath\Number; |
| 6 | + |
| 7 | +class BcMathNumber { |
| 8 | + |
| 9 | + /** |
| 10 | + * @param numeric-string $ns |
| 11 | + */ |
| 12 | + public function testBcMathNumbers( |
| 13 | + object $object, |
| 14 | + Number $number, |
| 15 | + string $ns, |
| 16 | + int $int, |
| 17 | + float $float, |
| 18 | + bool|float $boolFloat, |
| 19 | + int|float $intFloat, |
| 20 | + Number|int $nInt, |
| 21 | + Number|float $nFloat, |
| 22 | + Number|int|float $nIntFloat, |
| 23 | + Number|int|float|bool $nIntFloatBool |
| 24 | + ): void { |
| 25 | + +$number; |
| 26 | + -$number; |
| 27 | + |
| 28 | + $x = $object + $float; // error: Using + over non-number (object + float) |
| 29 | + $x = $object + $number; // error: Using + over non-number (object + BcMath\Number) |
| 30 | + |
| 31 | + $x = $number + $number; |
| 32 | + $x = $number - $number; |
| 33 | + $x = $number * $number; |
| 34 | + $x = $number / $number; |
| 35 | + |
| 36 | + $x = $number / $boolFloat; // error: Using / over BcMath\Number and float (BcMath\Number / bool|float) |
| 37 | + |
| 38 | + $x = $number + $int; |
| 39 | + $x = $int + $number; |
| 40 | + $x = $number + $ns; |
| 41 | + $x = $ns + $number; |
| 42 | + $x = $number - $int; |
| 43 | + $x = $int - $number; |
| 44 | + $x = $number - $ns; |
| 45 | + $x = $ns - $number; |
| 46 | + $x = $number * $int; |
| 47 | + $x = $int * $number; |
| 48 | + $x = $number * $ns; |
| 49 | + $x = $ns * $number; |
| 50 | + $x = $number / $int; |
| 51 | + $x = $int / $number; |
| 52 | + $x = $number / $ns; |
| 53 | + $x = $ns / $number; |
| 54 | + |
| 55 | + $x = $nInt + $int; |
| 56 | + $x = $int + $nInt; |
| 57 | + $x = $nInt + $ns; |
| 58 | + $x = $ns + $nInt; |
| 59 | + $x = $nInt - $int; |
| 60 | + $x = $int - $nInt; |
| 61 | + $x = $nInt - $ns; |
| 62 | + $x = $ns - $nInt; |
| 63 | + $x = $nInt * $int; |
| 64 | + $x = $int * $nInt; |
| 65 | + $x = $nInt * $ns; |
| 66 | + $x = $ns * $nInt; |
| 67 | + $x = $nInt / $int; |
| 68 | + $x = $int / $nInt; |
| 69 | + $x = $nInt / $ns; |
| 70 | + $x = $ns / $nInt; |
| 71 | + |
| 72 | + $x = $nFloat + $int; |
| 73 | + $x = $int + $nFloat; |
| 74 | + $x = $nFloat + $ns; |
| 75 | + $x = $ns + $nFloat; |
| 76 | + $x = $nFloat - $int; |
| 77 | + $x = $int - $nFloat; |
| 78 | + $x = $nFloat - $ns; |
| 79 | + $x = $ns - $nFloat; |
| 80 | + $x = $nFloat * $int; |
| 81 | + $x = $int * $nFloat; |
| 82 | + $x = $nFloat * $ns; |
| 83 | + $x = $ns * $nFloat; |
| 84 | + $x = $nFloat / $int; |
| 85 | + $x = $int / $nFloat; |
| 86 | + $x = $nFloat / $ns; |
| 87 | + $x = $ns / $nFloat; |
| 88 | + |
| 89 | + $x = $nIntFloat + $int; |
| 90 | + $x = $int + $nIntFloat; |
| 91 | + $x = $nIntFloat + $ns; |
| 92 | + $x = $ns + $nIntFloat; |
| 93 | + $x = $nIntFloat - $int; |
| 94 | + $x = $int - $nIntFloat; |
| 95 | + $x = $nIntFloat - $ns; |
| 96 | + $x = $ns - $nIntFloat; |
| 97 | + $x = $nIntFloat * $int; |
| 98 | + $x = $int * $nIntFloat; |
| 99 | + $x = $nIntFloat * $ns; |
| 100 | + $x = $ns * $nIntFloat; |
| 101 | + $x = $nIntFloat / $int; |
| 102 | + $x = $int / $nIntFloat; |
| 103 | + $x = $nIntFloat / $ns; |
| 104 | + $x = $ns / $nIntFloat; |
| 105 | + |
| 106 | + $x = $number + $float; // error: Using + over BcMath\Number and float (BcMath\Number + float) |
| 107 | + $x = $float + $number; // error: Using + over BcMath\Number and float (float + BcMath\Number) |
| 108 | + $x = $number - $float; // error: Using - over BcMath\Number and float (BcMath\Number - float) |
| 109 | + $x = $float - $number; // error: Using - over BcMath\Number and float (float - BcMath\Number) |
| 110 | + $x = $number * $float; // error: Using * over BcMath\Number and float (BcMath\Number * float) |
| 111 | + $x = $float * $number; // error: Using * over BcMath\Number and float (float * BcMath\Number) |
| 112 | + $x = $number / $float; // error: Using / over BcMath\Number and float (BcMath\Number / float) |
| 113 | + $x = $float / $number; // error: Using / over BcMath\Number and float (float / BcMath\Number) |
| 114 | + $x = $number % $float; // error: Using % over BcMath\Number and float (BcMath\Number % float) |
| 115 | + $x = $float % $number; // error: Using % over BcMath\Number and float (float % BcMath\Number) |
| 116 | + $x = $number ** $float; // error: Using ** over BcMath\Number and float (BcMath\Number ** float) |
| 117 | + $x = $float ** $number; // error: Using ** over BcMath\Number and float (float ** BcMath\Number) |
| 118 | + $x = $number + $intFloat; // error: Using + over BcMath\Number and float (BcMath\Number + float|int) |
| 119 | + $x = $intFloat + $number; // error: Using + over BcMath\Number and float (float|int + BcMath\Number) |
| 120 | + |
| 121 | + $x = $nInt + $float; // error: Using + over BcMath\Number and float (BcMath\Number|int + float) |
| 122 | + $x = $float + $nInt; // error: Using + over BcMath\Number and float (float + BcMath\Number|int) |
| 123 | + $x = $nInt - $float; // error: Using - over BcMath\Number and float (BcMath\Number|int - float) |
| 124 | + $x = $float - $nInt; // error: Using - over BcMath\Number and float (float - BcMath\Number|int) |
| 125 | + $x = $nInt * $float; // error: Using * over BcMath\Number and float (BcMath\Number|int * float) |
| 126 | + $x = $float * $nInt; // error: Using * over BcMath\Number and float (float * BcMath\Number|int) |
| 127 | + $x = $nInt / $float; // error: Using / over BcMath\Number and float (BcMath\Number|int / float) |
| 128 | + $x = $float / $nInt; // error: Using / over BcMath\Number and float (float / BcMath\Number|int) |
| 129 | + $x = $nInt % $float; // error: Using % over BcMath\Number and float (BcMath\Number|int % float) |
| 130 | + $x = $float % $nInt; // error: Using % over BcMath\Number and float (float % BcMath\Number|int) |
| 131 | + $x = $nInt ** $float; // error: Using ** over BcMath\Number and float (BcMath\Number|int ** float) |
| 132 | + $x = $float ** $nInt; // error: Using ** over BcMath\Number and float (float ** BcMath\Number|int) |
| 133 | + $x = $nInt + $intFloat; // error: Using + over BcMath\Number and float (BcMath\Number|int + float|int) |
| 134 | + $x = $intFloat + $nInt; // error: Using + over BcMath\Number and float (float|int + BcMath\Number|int) |
| 135 | + |
| 136 | + $x = $nFloat + $float; // error: Using + over BcMath\Number and float (BcMath\Number|float + float) |
| 137 | + $x = $float + $nFloat; // error: Using + over BcMath\Number and float (float + BcMath\Number|float) |
| 138 | + $x = $nFloat - $float; // error: Using - over BcMath\Number and float (BcMath\Number|float - float) |
| 139 | + $x = $float - $nFloat; // error: Using - over BcMath\Number and float (float - BcMath\Number|float) |
| 140 | + $x = $nFloat * $float; // error: Using * over BcMath\Number and float (BcMath\Number|float * float) |
| 141 | + $x = $float * $nFloat; // error: Using * over BcMath\Number and float (float * BcMath\Number|float) |
| 142 | + $x = $nFloat / $float; // error: Using / over BcMath\Number and float (BcMath\Number|float / float) |
| 143 | + $x = $float / $nFloat; // error: Using / over BcMath\Number and float (float / BcMath\Number|float) |
| 144 | + $x = $nFloat % $float; // error: Using % over BcMath\Number and float (BcMath\Number|float % float) |
| 145 | + $x = $float % $nFloat; // error: Using % over BcMath\Number and float (float % BcMath\Number|float) |
| 146 | + $x = $nFloat ** $float; // error: Using ** over BcMath\Number and float (BcMath\Number|float ** float) |
| 147 | + $x = $float ** $nFloat; // error: Using ** over BcMath\Number and float (float ** BcMath\Number|float) |
| 148 | + $x = $nFloat + $intFloat; // error: Using + over BcMath\Number and float (BcMath\Number|float + float|int) |
| 149 | + $x = $intFloat + $nFloat; // error: Using + over BcMath\Number and float (float|int + BcMath\Number|float) |
| 150 | + |
| 151 | + $x = $nIntFloat + $float; // error: Using + over BcMath\Number and float (BcMath\Number|float|int + float) |
| 152 | + $x = $float + $nIntFloat; // error: Using + over BcMath\Number and float (float + BcMath\Number|float|int) |
| 153 | + $x = $nIntFloat - $float; // error: Using - over BcMath\Number and float (BcMath\Number|float|int - float) |
| 154 | + $x = $float - $nIntFloat; // error: Using - over BcMath\Number and float (float - BcMath\Number|float|int) |
| 155 | + $x = $nIntFloat * $float; // error: Using * over BcMath\Number and float (BcMath\Number|float|int * float) |
| 156 | + $x = $float * $nIntFloat; // error: Using * over BcMath\Number and float (float * BcMath\Number|float|int) |
| 157 | + $x = $nIntFloat / $float; // error: Using / over BcMath\Number and float (BcMath\Number|float|int / float) |
| 158 | + $x = $float / $nIntFloat; // error: Using / over BcMath\Number and float (float / BcMath\Number|float|int) |
| 159 | + $x = $nIntFloat % $float; // error: Using % over BcMath\Number and float (BcMath\Number|float|int % float) |
| 160 | + $x = $float % $nIntFloat; // error: Using % over BcMath\Number and float (float % BcMath\Number|float|int) |
| 161 | + $x = $nIntFloat ** $float; // error: Using ** over BcMath\Number and float (BcMath\Number|float|int ** float) |
| 162 | + $x = $float ** $nIntFloat; // error: Using ** over BcMath\Number and float (float ** BcMath\Number|float|int) |
| 163 | + $x = $nIntFloat + $intFloat; // error: Using + over BcMath\Number and float (BcMath\Number|float|int + float|int) |
| 164 | + $x = $intFloat + $nIntFloat; // error: Using + over BcMath\Number and float (float|int + BcMath\Number|float|int) |
| 165 | + |
| 166 | + $x = $nIntFloatBool + $float; // error: Using + over BcMath\Number and float (BcMath\Number|bool|float|int + float) |
| 167 | + $x = $float + $nIntFloatBool; // error: Using + over BcMath\Number and float (float + BcMath\Number|bool|float|int) |
| 168 | + $x = $nIntFloatBool - $float; // error: Using - over BcMath\Number and float (BcMath\Number|bool|float|int - float) |
| 169 | + $x = $float - $nIntFloatBool; // error: Using - over BcMath\Number and float (float - BcMath\Number|bool|float|int) |
| 170 | + $x = $nIntFloatBool * $float; // error: Using * over BcMath\Number and float (BcMath\Number|bool|float|int * float) |
| 171 | + $x = $float * $nIntFloatBool; // error: Using * over BcMath\Number and float (float * BcMath\Number|bool|float|int) |
| 172 | + $x = $nIntFloatBool / $float; // error: Using / over BcMath\Number and float (BcMath\Number|bool|float|int / float) |
| 173 | + $x = $float / $nIntFloatBool; // error: Using / over BcMath\Number and float (float / BcMath\Number|bool|float|int) |
| 174 | + $x = $nIntFloatBool % $float; // error: Using % over BcMath\Number and float (BcMath\Number|bool|float|int % float) |
| 175 | + $x = $float % $nIntFloatBool; // error: Using % over BcMath\Number and float (float % BcMath\Number|bool|float|int) |
| 176 | + $x = $nIntFloatBool ** $float; // error: Using ** over BcMath\Number and float (BcMath\Number|bool|float|int ** float) |
| 177 | + $x = $float ** $nIntFloatBool; // error: Using ** over BcMath\Number and float (float ** BcMath\Number|bool|float|int) |
| 178 | + $x = $nIntFloatBool + $intFloat; // error: Using + over BcMath\Number and float (BcMath\Number|bool|float|int + float|int) |
| 179 | + $x = $intFloat + $nIntFloatBool; // error: Using + over BcMath\Number and float (float|int + BcMath\Number|bool|float|int) |
| 180 | + } |
| 181 | +} |
| 182 | + |
0 commit comments