Skip to content

Commit 67d26c6

Browse files
committed
Updated to support PHP 8.4
1 parent ce8a6b3 commit 67d26c6

161 files changed

Lines changed: 702 additions & 736 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"opis/closure": "3.x-dev as 3.6.x-dev",
6666
"cache/array-adapter": "*",
6767
"matthiasnoback/behat-expect-exception": "^v0.3.0",
68-
"behat/gherkin": "~v4.11.0"
68+
"behat/gherkin": "~v4.11.0",
69+
"rector/rector": "dev-main"
6970
},
7071
"suggest": {
7172
"ext-intl": "intl extension is required for formula support",

rector.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
6+
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
7+
use Rector\CodeQuality\Rector\Concat\JoinStringConcatRector;
8+
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
9+
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
10+
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
11+
use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
12+
use Rector\Config\RectorConfig;
13+
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
14+
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
15+
use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector;
16+
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
17+
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
18+
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;
19+
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
20+
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
21+
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
22+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
23+
24+
/**
25+
* How to run:
26+
*
27+
* ```bash
28+
* composer require rector/rector --dev
29+
* ./vendor/bin/rector process
30+
* ```
31+
*/
32+
return RectorConfig::configure()
33+
->withAutoloadPaths([
34+
file_exists(__DIR__ . '/../../autoload.php') ? __DIR__ . '/../../autoload.php' : null,
35+
file_exists(__DIR__ . '/vendor/autoload.php') ? __DIR__ . '/vendor/autoload.php' : null,
36+
])
37+
->withCache(__DIR__ . '/../../../runtime/cache/rector', FileCacheStorage::class)
38+
->withPreparedSets(deadCode: true, codeQuality: true)
39+
->withPhpSets(php83: true, php84: true)
40+
->withPhpVersion(\Rector\ValueObject\PhpVersion::PHP_84)
41+
->withoutParallel()
42+
->withPaths([
43+
__DIR__ . '/src',
44+
])
45+
->withRules([
46+
RemoveAlwaysElseRector::class,
47+
ChangeNestedIfsToEarlyReturnRector::class,
48+
ChangeIfElseValueAssignToEarlyReturnRector::class,
49+
ChangeNestedForeachIfsToEarlyContinueRector::class,
50+
])
51+
->withSkip([
52+
// Too many places where json_decode was used intentionally on wrong data =\
53+
JsonThrowOnErrorRector::class,
54+
55+
// Frequently used for debug. Maybe, such places should be annotated with @noRector?
56+
SimplifyUselessVariableRector::class,
57+
58+
// Legacy modules are full of `_doSomeShit()` methods that are likely called as `$this->_do{$operation}`
59+
RemoveUnusedPrivateMethodRector::class,
60+
61+
// Does not make sense for us
62+
SimplifyRegexPatternRector::class,
63+
64+
// Requires whole project autoloaded to work well
65+
RemoveUnusedPrivateClassConstantRector::class,
66+
67+
// don't refactor with `empty` check function
68+
DisallowedEmptyRuleFixerRector::class,
69+
SimplifyEmptyArrayCheckRector::class,
70+
SimplifyEmptyCheckOnEmptyArrayRector::class,
71+
72+
// do not refactor `query` attribute like " . '$select' . " to 'SELECT $select ...'
73+
JoinStringConcatRector::class,
74+
75+
// do not refactor php version id checkers
76+
RemovePhpVersionIdCheckRector::class,
77+
RemoveExtraParametersRector::class,
78+
79+
SwitchNegatedTernaryRector::class,
80+
]);

src/EntityInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* PHP Billing Library
47
*
@@ -7,7 +10,6 @@
710
* @license BSD-3-Clause
811
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
912
*/
10-
1113
namespace hiqdev\php\billing;
1214

1315
/**

src/Exception/CannotReassignException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* PHP Billing Library
47
*
@@ -7,7 +10,6 @@
710
* @license BSD-3-Clause
811
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
912
*/
10-
1113
namespace hiqdev\php\billing\Exception;
1214

1315
use Exception;

src/Exception/EntityNotFoundException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* PHP Billing Library
47
*
@@ -7,7 +10,6 @@
710
* @license BSD-3-Clause
811
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
912
*/
10-
1113
namespace hiqdev\php\billing\Exception;
1214

1315
use hiqdev\php\billing\ExceptionInterface;

src/Exception/NotSupportedException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* PHP Billing Library
47
*
@@ -7,7 +10,6 @@
710
* @license BSD-3-Clause
811
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
912
*/
10-
1113
namespace hiqdev\php\billing\Exception;
1214

1315
use Exception;

src/Exception/UnknownEntityException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* PHP Billing Library
47
*
@@ -7,7 +10,6 @@
710
* @license BSD-3-Clause
811
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
912
*/
10-
1113
namespace hiqdev\php\billing\Exception;
1214

1315
use hiqdev\php\billing\ExceptionInterface;

src/ExceptionInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/**
36
* PHP Billing Library
47
*
@@ -7,7 +10,6 @@
710
* @license BSD-3-Clause
811
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
912
*/
10-
1113
namespace hiqdev\php\billing;
1214

1315
/**

src/Money/MultipliedMoney.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ private function __construct(
3535

3636
/**
3737
* @param numeric-string $amount
38-
* @param string $currencyCode
3938
*/
4039
public static function create(string $amount, string $currencyCode): MultipliedMoney
4140
{
@@ -87,7 +86,7 @@ private static function calculateMultiplierToInteger(string $amount): int
8786
}
8887

8988
[, $fraction] = explode('.', $amount, 2);
90-
return (int)('1' . implode(array_fill(0, strlen($fraction), 0)));
89+
return (int)('1' . implode('', array_fill(0, strlen($fraction), 0)));
9190
}
9291

9392
/**

src/action/AbstractAction.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
*/
2929
abstract class AbstractAction implements \JsonSerializable, ActionInterface
3030
{
31-
/** @var int */
32-
protected $id;
33-
3431
/** @var TypeInterface */
3532
protected $type;
3633

@@ -55,25 +52,21 @@ abstract class AbstractAction implements \JsonSerializable, ActionInterface
5552
/** @var ActionInterface */
5653
protected $parent;
5754

58-
protected float $fractionOfMonth = 0.0;
59-
6055
/**
61-
* @param SaleInterface $sale
62-
* @param ActionInterface $parent
56+
* @param int $id
6357
*/
6458
public function __construct(
65-
$id,
59+
protected $id,
6660
TypeInterface $type,
6761
TargetInterface $target,
6862
QuantityInterface $quantity,
6963
CustomerInterface $customer,
7064
DateTimeImmutable $time,
71-
SaleInterface $sale = null,
72-
ActionState $state = null,
73-
ActionInterface $parent = null,
74-
float $fractionOfMonth = 0.0
65+
?SaleInterface $sale = null,
66+
?ActionState $state = null,
67+
?ActionInterface $parent = null,
68+
protected float $fractionOfMonth = 0.0
7569
) {
76-
$this->id = $id;
7770
$this->type = $type;
7871
$this->target = $target;
7972
$this->quantity = $quantity;
@@ -82,7 +75,6 @@ public function __construct(
8275
$this->sale = $sale;
8376
$this->state = $state;
8477
$this->parent = $parent;
85-
$this->fractionOfMonth = $fractionOfMonth;
8678
}
8779

8880
/**

0 commit comments

Comments
 (0)