Skip to content

Commit 2365f06

Browse files
authored
Static fixes (#349)
* cs * static fixes * remove node visitor stop from DowngradeHashAlgorithmXxHashRector
1 parent d051cbe commit 2365f06

File tree

16 files changed

+75
-206
lines changed

16 files changed

+75
-206
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"phpunit/phpunit": "^11.5",
1414
"rector/rector-src": "dev-main",
1515
"symplify/easy-coding-standard": "^12.3",
16+
"symplify/phpstan-extensions": "^12.0",
17+
"symplify/phpstan-rules": "^14.9",
1618
"symplify/rule-doc-generator": "^12.2",
1719
"symplify/vendor-patches": "^11.5",
1820
"tomasvotruba/class-leak": "^1.0",

phpstan.neon

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# to be enabled later once rector upgraded to use phpstan v2
2-
# includes:
3-
# - vendor/symplify/phpstan-rules/config/symplify-rules.neon
4-
# - vendor/symplify/phpstan-rules/config/rector-rules.neon
1+
includes:
2+
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
3+
- vendor/symplify/phpstan-rules/config/rector-rules.neon
54

65
parameters:
76
level: 8
7+
errorFormat: symplify
88

99
reportUnmatchedIgnoredErrors: false
1010

@@ -57,16 +57,16 @@ parameters:
5757
- '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'
5858

5959
# phpstan instanceof
60-
-
61-
identifier: phpstanApi.instanceofAssumption
62-
63-
-
64-
identifier: phpstanApi.varTagAssumption
60+
- identifier: phpstanApi.instanceofAssumption
61+
- identifier: phpstanApi.varTagAssumption
62+
- '#Asking about instanceof PHPStan\\.* is not covered by backward compatibility promise#'
6563

6664
-
6765
identifier: argument.type
68-
69-
- '#Asking about instanceof PHPStan\\.* is not covered by backward compatibility promise#'
66+
paths:
67+
- rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php
68+
- rules/DowngradePhp85/Rector/Class_/DowngradeFinalPropertyPromotionRector.php
69+
- rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php
7070

7171
# false positive intanceof in OR usage
7272
-
@@ -76,3 +76,30 @@ parameters:
7676
-
7777
identifier: deadCode.unreachable
7878
path: rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php
79+
80+
# cached printed nodes
81+
-
82+
identifier: rector.noPropertyNodeAssign
83+
paths:
84+
- rules/DowngradePhp83/Rector/FuncCall/DowngradeJsonValidateRector.php
85+
- rules/DowngradePhp81/Rector/FuncCall/DowngradeArrayIsListRector.php
86+
- rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php
87+
88+
# already registered in PHP 8.1 set
89+
-
90+
identifier: rector.upgradeDowngradeRegisteredInSet
91+
path: rules/DowngradePhp74/Rector/Array_/DowngradeArraySpreadRector.php
92+
93+
# valid stmts property check
94+
-
95+
identifier: symplify.forbiddenFuncCall
96+
path: rules/DowngradePhp73/Rector/FuncCall/DowngradeArrayKeyFirstLastRector.php
97+
98+
# false positive
99+
-
100+
identifier: symplify.seeAnnotationToTest
101+
path: rules/DowngradePhp85/Rector/StmtsAwareInterface/DowngradePipeOperatorRector.php
102+
103+
-
104+
identifier: rector.noIntegerRefactorReturn
105+
path: rules/DowngradePhp82/Rector/FuncCall/DowngradeIteratorCountToArrayRector.php

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_constant.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture;
44

5-
class Fixture
5+
final class FixtureConstant
66
{
77
public function run()
88
{
@@ -16,7 +16,7 @@ class Fixture
1616

1717
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture;
1818

19-
class Fixture
19+
final class FixtureConstant
2020
{
2121
public function run()
2222
{

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_named_arguments.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture;
44

5-
class Fixture
5+
final class FixtureNamedArguments
66
{
77
public function run()
88
{
@@ -16,7 +16,7 @@ class Fixture
1616

1717
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture;
1818

19-
class Fixture
19+
final class FixtureNamedArguments
2020
{
2121
public function run()
2222
{

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_named_arguments_false_order.php.inc

Lines changed: 0 additions & 27 deletions
This file was deleted.

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_xxh128.php.inc

Lines changed: 0 additions & 27 deletions
This file was deleted.

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_xxh32.php.inc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture;
44

5-
class Fixture
5+
final class FixtureXxh32
66
{
77
public function run()
88
{
9-
return hash('xxh32', 'some-data-to-hash');
9+
$value = hash('xxh32', 'some-data-to-hash');
10+
11+
$value = hash('xxh64', 'some-data-to-hash');
12+
13+
$value = hash('xxh128', 'some-data-to-hash');
1014
}
1115
}
1216

@@ -16,11 +20,15 @@ class Fixture
1620

1721
namespace Rector\Tests\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHash\Fixture;
1822

19-
class Fixture
23+
final class FixtureXxh32
2024
{
2125
public function run()
2226
{
23-
return hash('md5', 'some-data-to-hash');
27+
$value = hash('md5', 'some-data-to-hash');
28+
29+
$value = hash('md5', 'some-data-to-hash');
30+
31+
$value = hash('md5', 'some-data-to-hash');
2432
}
2533
}
2634

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_xxh64.php.inc

Lines changed: 0 additions & 27 deletions
This file was deleted.

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/skip_check_version_compare_ternary.php.inc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ final class SkipCheckVersionCompareTernary
66
{
77
public function run_v()
88
{
9-
return version_compare(PHP_VERSION, '8.1','>=')
9+
$value = version_compare(PHP_VERSION, '8.1','>=')
1010
? hash( 'xxh128', $value )
1111
: hash( 'md4', $value );
12+
13+
$value = version_compare(PHP_VERSION, '8.1','<')
14+
? hash( 'md4', $value )
15+
: hash( 'xxh128', $value );
1216
}
1317
}

rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/skip_check_version_compare_ternary2.php.inc

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)