Skip to content

Commit d134539

Browse files
authored
Merge pull request #25 from nanasess/bcmath-architecture-refactor
refactor(BCMath): major architecture refactoring with DRY principle and unified structure
2 parents 8661914 + 0eabb4f commit d134539

File tree

7 files changed

+566
-496
lines changed

7 files changed

+566
-496
lines changed

.php-cs-fixer.dist.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@
1919
'ordered_class_elements' => false,
2020
'increment_style' => false,
2121
'@PhpCsFixer:risky' => true,
22-
'strict_comparison' => false,
23-
'is_null' => false,
2422
'native_function_invocation' => false,
25-
'error_suppression' => true,
2623
'php_unit_test_case_static_method_calls' => false,
27-
'final_internal_class' => false,
28-
'php_unit_data_provider_name' => false,
2924
])
3025
->setFinder($finder)
3126
;

lib/bcmath.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function bcpowmod($base, $exponent, $modulus, $scale = null): string
123123
*
124124
* @param null|int $scale
125125
*/
126-
function bcscale($scale = null): int
126+
function bcscale($scale = null): ?int
127127
{
128128
return BCMath::scale($scale);
129129
}
@@ -157,11 +157,10 @@ function bcsub($left_operand, $right_operand, $scale = null): string
157157
* Round down to the nearest integer (PHP 8.4+).
158158
*
159159
* @param string $operand
160-
* @param null|int $scale optional
161160
*/
162-
function bcfloor($operand, $scale = null): string
161+
function bcfloor($operand): string
163162
{
164-
return BCMath::floor($operand, $scale);
163+
return BCMath::floor($operand);
165164
}
166165
}
167166

@@ -170,11 +169,10 @@ function bcfloor($operand, $scale = null): string
170169
* Round up to the nearest integer (PHP 8.4+).
171170
*
172171
* @param string $operand
173-
* @param null|int $scale optional
174172
*/
175-
function bcceil($operand, $scale = null): string
173+
function bcceil($operand): string
176174
{
177-
return BCMath::ceil($operand, $scale);
175+
return BCMath::ceil($operand);
178176
}
179177
}
180178

phpstan.neon.dist

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
parameters:
2-
level: 6
2+
level: max
33
paths:
44
- src
55
- tests
66
- lib
77
ignoreErrors:
8-
-
9-
message: '#^Static method bcmath_compat\\BCMath::[a-zA-Z_]+\(\) is unused\.$#'
10-
identifier: method.unused

rector.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector;
7-
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
8-
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
96
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
10-
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
117

128
return RectorConfig::configure()
139
->withPaths([
@@ -19,11 +15,5 @@
1915
->withComposerBased(phpunit: true)
2016
->withPreparedSets(typeDeclarations: true, deadCode: true, codeQuality: true)
2117
->withSkip([
22-
RemoveAlwaysTrueIfConditionRector::class => [
23-
__DIR__ . '/tests/BCMathTest.php',
24-
],
2518
UnwrapFutureCompatibleIfPhpVersionRector::class,
26-
RemoveUnusedPrivateMethodParameterRector::class,
27-
RemoveUnusedPrivateMethodRector::class,
28-
AddMethodCallBasedStrictParamTypeRector::class, // FIXME BCMath::comp() で誤検出されるため暫定的に追加
2919
]);

0 commit comments

Comments
 (0)