| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | namespace Samsara\Fermat\Provider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Samsara\Exceptions\SystemError\PlatformError\MissingPackage; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Samsara\Exceptions\UsageError\IntegrityConstraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Samsara\Fermat\Enums\CalcMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Samsara\Fermat\Enums\NumberBase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Samsara\Fermat\Numbers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Samsara\Fermat\Types\Base\Interfaces\Numbers\DecimalInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Samsara\Fermat\Values\ImmutableDecimal; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class ConstantProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private static DecimalInterface $pi; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private static DecimalInterface $e; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     private static DecimalInterface $ln10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private static DecimalInterface $ln2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     private static DecimalInterface $ln1p1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @param int $digits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @throws IntegrityConstraint | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @throws MissingPackage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 4 |  |     public static function makePi(int $digits): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 4 |  |         if (isset(self::$pi) && self::$pi->numberOfDecimalDigits() >= $digits) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 1 |  |             return self::$pi->truncateToScale($digits)->getValue(NumberBase::Ten); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 4 |  |         $internalScale = ($digits*2) + 10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 4 |  |         $C = Numbers::make(Numbers::IMMUTABLE, '10005', $internalScale)->setMode(CalcMode::Precision)->sqrt($internalScale)->multiply(426880); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 4 |  |         $M = Numbers::make(Numbers::IMMUTABLE, '1', $internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 4 |  |         $L = Numbers::make(Numbers::IMMUTABLE, '13591409', $internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 4 |  |         $K = Numbers::make(Numbers::IMMUTABLE, '6', $internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 4 |  |         $X = Numbers::make(Numbers::IMMUTABLE, '1')->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 4 |  |         $sum = Numbers::make(Numbers::MUTABLE,'0', $internalScale + 2)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 4 |  |         $termNum = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 4 |  |         $one = Numbers::makeOne($internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 4 |  |         $continue = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 4 |  |         while ($continue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 4 |  |             $term = $M->multiply($L)->divide($X, $internalScale); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 4 |  |             if ($termNum > $internalScale) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 4 |  |                 $continue = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 | 4 |  |             $sum->add($term); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 4 |  |             $M = $M->multiply($K->pow(3)->subtract($K->multiply(16))->divide($one->add($termNum)->pow(3), $internalScale)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 4 |  |             $L = $L->add(545140134); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 4 |  |             $X = $X->multiply('-262537412640768000'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 4 |  |             $K = $K->add(12); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 4 |  |             $termNum++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 4 |  |         $pi = $C->divide($sum, $internalScale); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 4 |  |         self::$pi = $pi->truncateToScale($digits); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 4 |  |         return $pi->truncateToScale($digits)->getValue(NumberBase::Ten); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * Consider also: sum [0 -> INF] { (2n + 2) / (2n + 1)! } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * This converges faster (though it's unclear if the calculation is actually faster), and can be represented by this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * set of Fermat calls: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * SequenceProvider::nthEvenNumber($n + 1)->divide(SequenceProvider::nthOddNumber($n)->factorial()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * Perhaps by substituting the nthOddNumber()->factorial() call with something tracked locally, the performance can | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * be improved. Current performance is acceptable even out past 200 digits. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @param int $digits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @throws IntegrityConstraint | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 2 |  |     public static function makeE(int $digits): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 2 |  |         if (isset(self::$e) && self::$e->numberOfDecimalDigits() >= $digits) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             return self::$e->truncateToScale($digits)->getValue(NumberBase::Ten); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 2 |  |         $internalScale = $digits + 3; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 2 |  |         $one = Numbers::makeOne($internalScale+5)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 2 |  |         $denominator = Numbers::make(Numbers::MUTABLE, '1', $internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 2 |  |         $e = Numbers::make(NUmbers::MUTABLE, '2', $internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 2 |  |         $n = Numbers::make(Numbers::MUTABLE, '2', $internalScale)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 2 |  |         $continue = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 2 |  |         while ($continue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 | 2 |  |             $denominator->multiply($n); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 2 |  |             $n->add($one); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 2 |  |             $term = $one->divide($denominator); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 2 |  |             if ($term->numberOfLeadingZeros() > $internalScale || $term->isEqual(0)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 2 |  |                 $continue = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 2 |  |             $e->add($term); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 2 |  |         self::$e = $e->truncateToScale($digits); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 2 |  |         return $e->truncateToScale($digits)->getValue(NumberBase::Ten); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * The lnScale() implementation is very efficient, so this is probably our best bet for computing more digits of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * ln(10) to provide. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * @param int $digits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * @throws IntegrityConstraint | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 1 |  |     public static function makeLn10(int $digits): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 1 |  |         if (isset(self::$ln10) && self::$ln10->numberOfDecimalDigits() >= $digits) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             return self::$ln10->truncateToScale($digits)->getValue(NumberBase::Ten); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 1 |  |         $ln10 = Numbers::make(Numbers::IMMUTABLE, 10, $digits+2)->setMode(CalcMode::Precision); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 1 |  |         $ln10 = $ln10->ln(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 1 |  |         self::$ln10 = $ln10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 1 |  |         return $ln10->truncateToScale($digits)->getValue(NumberBase::Ten); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * This function is a special case of the ln() function where x can be represented by (n + 1)/n, where n is an | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      * integer. This particular special case converges extremely rapidly. For ln(2), n = 1. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * @param int $digits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      * @return string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 156 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 157 | 4 |  |     public static function makeLn2(int $digits): string | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 160 | 4 |  |         if (isset(self::$ln2) && self::$ln2->numberOfDecimalDigits() >= $digits) { | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |             return self::$ln2->truncateToScale($digits)->getValue(NumberBase::Ten); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 164 | 4 |  |         $twoThirds = Numbers::make(Numbers::IMMUTABLE, str_pad('0.', $digits+3, '6')); | 
            
                                                                        
                            
            
                                    
            
            
                | 165 | 4 |  |         $nine = Numbers::make(Numbers::IMMUTABLE, 9, $digits+3); | 
            
                                                                        
                            
            
                                    
            
            
                | 166 | 4 |  |         $ln2 = self::_makeLnSpecial($digits, $nine, $twoThirds); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 168 | 4 |  |         self::$ln2 = $ln2; | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 170 | 4 |  |         return $ln2->getValue(NumberBase::Ten); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * This function is a special case of the ln() function where x can be represented by (n + 1)/n, where n is an | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * integer. This particular special case converges extremely rapidly. For ln(1.1), n = 10. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * @param int $digits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 | 9 |  |     public static function makeLn1p1(int $digits): string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 9 |  |         if (isset(self::$ln1p1) && self::$ln1p1->numberOfDecimalDigits() >= $digits) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 3 |  |             return self::$ln1p1->truncateToScale($digits)->getValue(NumberBase::Ten); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 9 |  |         $two = Numbers::make(Numbers::IMMUTABLE, 2, $digits+3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 | 9 |  |         $twentyOne = Numbers::make(Numbers::IMMUTABLE, 21, $digits+3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 9 |  |         $fourFortyOne = Numbers::make(Numbers::IMMUTABLE, 441, $digits+3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 | 9 |  |         $twoDivTwentyOne = $two->divide($twentyOne); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 9 |  |         $ln1p1 = self::_makeLnSpecial($digits, $fourFortyOne, $twoDivTwentyOne); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 9 |  |         self::$ln1p1 = $ln1p1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 9 |  |         return $ln1p1->getValue(NumberBase::Ten); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      * @param int $digits | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      * @param ImmutableDecimal $innerNum | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      * @param ImmutableDecimal $outerNum | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      * @return ImmutableDecimal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 10 |  |     private static function _makeLnSpecial(int $digits, ImmutableDecimal $innerNum, ImmutableDecimal $outerNum): ImmutableDecimal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 | 10 |  |         $one = Numbers::makeOne($digits+3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 | 10 |  |         $two = Numbers::make(Numbers::IMMUTABLE, 2, $digits+3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 | 10 |  |         $sum = Numbers::makeZero($digits+3); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 10 |  |         $k = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         do { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 | 10 |  |             $diff = $one->divide($one->add($two->multiply($k))->multiply($innerNum->pow($k)), $digits+3)->truncate($digits+2); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 10 |  |             $sum = $sum->add($diff); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 | 10 |  |             $k++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 | 10 |  |         } while (!$diff->isEqual(0)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 10 |  |         $lnSpecial = $outerNum->multiply($sum); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 | 10 |  |         return $lnSpecial->truncateToScale($digits); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 227 |  |  | } | 
            
                        
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.