Skip to content

Commit db51081

Browse files
committed
feat(rector): add strict parameter type enforcement for method calls
Added `AddMethodCallBasedStrictParamTypeRector` to the Rector configuration to enforce strict parameter types based on method calls. This is a temporary measure to address false positives with `BCMath::comp()`. fix(BCMath): adjust parameter types in `comp` method Updated the `comp` method in `BCMath` to align parameter types with strict type enforcement.
1 parent b4b5d7d commit db51081

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
88
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
99
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
10+
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
1011

1112
return RectorConfig::configure()
1213
->withPaths([
@@ -24,4 +25,5 @@
2425
UnwrapFutureCompatibleIfPhpVersionRector::class,
2526
RemoveUnusedPrivateMethodParameterRector::class,
2627
RemoveUnusedPrivateMethodRector::class,
28+
AddMethodCallBasedStrictParamTypeRector::class, // FIXME BCMath::comp() で誤検出されるため暫定的に追加
2729
]);

src/BCMath.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ private static function mod($x, $y, $scale, $pad = 0): string
199199
* Compare two arbitrary precision numbers.
200200
*
201201
* @param string $x
202+
* @param string $y
202203
* @param ?int $scale
203204
* @param int $pad
204205
*/
205-
private static function comp($x, string $y, $scale = 0, $pad = 0): int
206+
private static function comp($x, $y, $scale = 0, $pad = 0): int
206207
{
207208
$x = new BigInteger($x[0].substr($x[1], 0, $scale));
208209
$y = new BigInteger($y[0].substr($y[1], 0, $scale));

0 commit comments

Comments
 (0)