Skip to content

Commit 25b88d6

Browse files
committed
fix: apply rector
1 parent 7744e99 commit 25b88d6

File tree

13 files changed

+51
-30
lines changed

13 files changed

+51
-30
lines changed

.php-cs-fixer.dist.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PhpCsFixer\Config;
66
use PhpCsFixer\Finder;
7+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
78

89
$finder = Finder::create()
910
->files()
@@ -12,16 +13,21 @@
1213
->in(__DIR__ . '/tests');
1314

1415
return (new Config())
16+
->setParallelConfig(ParallelConfigFactory::detect())
1517
->setFinder($finder)
1618
->setRiskyAllowed(true)
1719
->setRules([
1820
'@PSR12' => true,
1921
'array_syntax' => ['syntax' => 'short'],
2022
'backtick_to_shell_exec' => true,
21-
'braces' => [
22-
'allow_single_line_closure' => true,
23-
'allow_single_line_anonymous_class_with_empty_body' => true,
24-
],
23+
'single_space_around_construct' => true,
24+
'control_structure_braces' => true,
25+
'control_structure_continuation_position' => true,
26+
'declare_parentheses' => true,
27+
'no_multiple_statements_per_line' => true,
28+
'braces_position' => true,
29+
'statement_indentation' => true,
30+
'no_extra_blank_lines' => true,
2531
'class_definition' => ['single_line' => true],
2632
'concat_space' => ['spacing' => 'one'],
2733
'declare_strict_types' => true,
@@ -30,7 +36,7 @@
3036
'ereg_to_preg' => true,
3137
'explicit_string_variable' => true,
3238
'fully_qualified_strict_types' => true,
33-
'function_typehint_space' => true,
39+
'type_declaration_spaces' => true,
3440
'general_phpdoc_annotation_remove' => [
3541
'annotations' => [
3642
'author',
@@ -48,13 +54,12 @@
4854
'native_function_invocation' => [
4955
'include' => ['@compiler_optimized'],
5056
],
51-
'native_function_type_declaration_casing' => true,
52-
'new_with_braces' => true,
57+
'native_type_declaration_casing' => true,
58+
'new_with_parentheses' => true,
5359
'no_blank_lines_after_class_opening' => true,
5460
'no_empty_comment' => true,
5561
'no_empty_phpdoc' => true,
5662
'no_empty_statement' => true,
57-
'no_extra_blank_lines' => true,
5863
'no_homoglyph_names' => true,
5964
'no_leading_import_slash' => true,
6065
'no_leading_namespace_whitespace' => true,
@@ -113,7 +118,11 @@
113118
'ternary_to_elvis_operator' => true,
114119
'ternary_to_null_coalescing' => true,
115120
'trailing_comma_in_multiline' => [
116-
'elements' => ['arguments', 'arrays', 'match', 'parameters'],
121+
'elements' => [
122+
'arrays',
123+
'arguments',
124+
'parameters',
125+
],
117126
],
118127
'trim_array_spaces' => true,
119128
'unary_operator_spaces' => true,

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
"gacela-project/phpstan-extension": "^0.3",
1414
"phpstan/phpstan": "^1.12",
1515
"phpunit/phpunit": "^9.6",
16-
"psalm/plugin-phpunit": "^0.18",
16+
"psalm/plugin-phpunit": "^0.19",
1717
"rector/rector": "^1.2",
1818
"symfony/var-dumper": "^7.2",
19-
"vimeo/psalm": "^5.26"
19+
"vimeo/psalm": "^6.11"
2020
},
2121
"config": {
2222
"platform": {
23-
"php": "8.2"
23+
"php": "8.2.27"
2424
},
2525
"allow-plugins": {
2626
"composer/package-versions-deprecated": true
@@ -48,11 +48,12 @@
4848
"@csfix",
4949
"@test-all"
5050
],
51-
"fix": "@csfix",
51+
"fix": ["@csfix", "@rector"],
5252
"test": "@test-all",
5353
"test-all": [
5454
"@quality",
55-
"@phpunit"
55+
"@phpunit",
56+
"@rector:dry"
5657
],
5758
"quality": [
5859
"@csrun",
@@ -72,6 +73,8 @@
7273
"phpstan": "XDEBUG_MODE=off ./vendor/bin/phpstan analyze",
7374
"csfix": "XDEBUG_MODE=off ./vendor/bin/php-cs-fixer fix",
7475
"csrun": "XDEBUG_MODE=off ./vendor/bin/php-cs-fixer fix --dry-run",
76+
"rector": "./vendor/bin/rector",
77+
"rector:dry": "./vendor/bin/rector --dry-run",
7578
"serve": "php -S localhost:8080 public/index.php"
7679
}
7780
}

gacela.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Gacela\Router\Config\RouterGacelaConfig;
77
use PhpLightning\Invoice\Infrastructure\Plugin\InvoiceRoutesPlugin;
88

9-
return static function (GacelaConfig $config) : void {
9+
return static function (GacelaConfig $config): void {
1010
$config
1111
->enableFileCache()
1212
->addAppConfig('lightning-config.dist.php', 'lightning-config.php')

psalm.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<psalm
33
errorLevel="1"
4-
phpVersion="8.0"
4+
phpVersion="8.2"
55
findUnusedBaselineEntry="true"
66
findUnusedCode="false"
77
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -24,9 +24,11 @@
2424
<InvalidReturnStatement errorLevel="suppress" />
2525
<LessSpecificReturnStatement errorLevel="suppress" />
2626
<MoreSpecificReturnType errorLevel="suppress" />
27-
<MixedInferredReturnType errorLevel="suppress" />
2827
<MixedReturnStatement errorLevel="suppress" />
2928
<ArgumentTypeCoercion errorLevel="suppress" />
3029
<UnresolvableInclude errorLevel="suppress" />
30+
<MissingOverrideAttribute errorLevel="suppress" />
31+
<MixedMethodCall errorLevel="suppress" />
32+
<UndefinedMethod errorLevel="suppress" />
3133
</issueHandlers>
3234
</psalm>

src/Config/LightningConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function addBackendsFile(string $path): self
9191
public function jsonSerialize(): array
9292
{
9393
$result = [];
94-
if ($this->backends !== null) {
94+
if ($this->backends instanceof BackendsConfig) {
9595
$result['backends'] = $this->backends->jsonSerialize();
9696
}
9797
if ($this->domain !== null) {
@@ -100,7 +100,7 @@ public function jsonSerialize(): array
100100
if ($this->receiver !== null) {
101101
$result['receiver'] = $this->receiver;
102102
}
103-
if ($this->sendableRange !== null) {
103+
if ($this->sendableRange instanceof SendableRange) {
104104
$result['sendable-range'] = $this->sendableRange;
105105
}
106106
if ($this->callbackUrl !== null) {

src/Invoice/Application/CallbackUrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use function sprintf;
1212

13-
final class CallbackUrl implements CallbackUrlInterface
13+
final readonly class CallbackUrl implements CallbackUrlInterface
1414
{
1515
private const TAG_PAY_REQUEST = 'payRequest';
1616

src/Invoice/Application/InvoiceGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use function sprintf;
1212

13-
final class InvoiceGenerator
13+
final readonly class InvoiceGenerator
1414
{
1515
public function __construct(
1616
private BackendInvoiceInterface $backendInvoice,

src/Invoice/Domain/BackendInvoice/EmptyBackendInvoice.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66

77
use PhpLightning\Shared\Transfer\BackendInvoiceResponse;
88

9-
final class EmptyBackendInvoice implements BackendInvoiceInterface
9+
final readonly class EmptyBackendInvoice implements BackendInvoiceInterface
1010
{
11-
private string $name;
12-
13-
public function __construct(string $name)
11+
public function __construct(private string $name)
1412
{
15-
$this->name = $name;
1613
}
1714

1815
public function requestInvoice(int $satsAmount, string $metadata): BackendInvoiceResponse

src/Invoice/Domain/BackendInvoice/LnbitsBackendInvoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class LnbitsBackendInvoice implements BackendInvoiceInterface
1313
* @param array{api_key:string, api_endpoint:string} $options
1414
*/
1515
public function __construct(
16-
private HttpApiInterface $httpApi,
16+
private readonly HttpApiInterface $httpApi,
1717
private array $options,
1818
) {
1919
}

src/Invoice/Domain/CallbackUrl/LnAddressGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use function sprintf;
88

9-
final class LnAddressGenerator implements LnAddressGeneratorInterface
9+
final readonly class LnAddressGenerator implements LnAddressGeneratorInterface
1010
{
1111
public function __construct(
1212
private string $defaultLnAddress,

0 commit comments

Comments
 (0)