Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 867cfa6

Browse files
authored
Merge pull request #315 from PrisisForks/feature/cs-fixes
2 parents 478e46e + 9a356ec commit 867cfa6

File tree

6 files changed

+345
-308
lines changed

6 files changed

+345
-308
lines changed

.php_cs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ $config->getFinder()
2828
'.dependabot',
2929
'.github',
3030
])
31+
// php_unit_namespaced rule thinks than the const are some namespaces
32+
->notPath('rector.php')
3133
->name('*.php')
3234
->ignoreDotFiles(true)
3335
->ignoreVCS(true);

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"phpstan/phpstan-strict-rules": "^0.12.9",
3737
"phpunit/phpunit": "^9.5.2",
3838
"psalm/plugin-phpunit": "^0.15.1",
39-
"rector/rector": "^0.9.31",
39+
"rector/rector": "^0.10.6",
40+
"rector/rector-phpunit": "^0.10.6",
4041
"slam/phpstan-extensions": "^5.1.0",
4142
"symplify/phpstan-rules": "^9.2",
4243
"thecodingmachine/phpstan-strict-rules": "^0.12.1",

rector.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Nette\Utils\Strings;
1616
use Rector\Core\Configuration\Option;
1717
use Rector\Core\ValueObject\PhpVersion;
18+
use Rector\PHPUnit\Set\PHPUnitSetList;
19+
use Rector\Set\ValueObject\SetList;
1820
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1921

2022
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -56,6 +58,27 @@
5658
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, $phpstanPath);
5759

5860
$parameters->set(Option::SETS, [
59-
'action-injection-to-constructor-injection', 'array-str-functions-to-static-call', 'early-return', 'doctrine-code-quality', 'dead-code', 'code-quality', 'type-declaration', 'order', 'psr4', 'type-declaration', 'type-declaration-strict', 'php71', 'php72', 'php73', 'php74', 'php80', 'phpunit91', 'phpunit-code-quality', 'phpunit-exception', 'phpunit-yield-data-provider',
61+
SetList::CODING_STYLE,
62+
SetList::CODE_QUALITY,
63+
SetList::CODE_QUALITY_STRICT,
64+
SetList::DEAD_CODE,
65+
SetList::PRIVATIZATION,
66+
SetList::NAMING,
67+
SetList::TYPE_DECLARATION,
68+
SetList::ORDER,
69+
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
70+
PHPUnitSetList::PHPUNIT_91,
71+
PHPUnitSetList::PHPUNIT_EXCEPTION,
72+
PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER,
73+
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
74+
SetList::PHP_71,
75+
SetList::PHP_72,
76+
SetList::PHP_73,
77+
SetList::PHP_74,
78+
SetList::PHP_80,
79+
SetList::EARLY_RETURN,
80+
SetList::TYPE_DECLARATION_STRICT,
81+
SetList::PSR_4,
82+
SetList::SAFE_07,
6083
]);
6184
};

src/Config.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
use function is_string;
6767
use function trim;
6868

69+
/** @noRector ArgumentAdderRector */
6970
final class Config extends CsConfig
7071
{
7172
/** @var array<string, array<string, string>> */
@@ -171,7 +172,7 @@ public function getRules(): array
171172
}
172173

173174
/**
174-
* @return bool[][]|string[][]
175+
* @return array<string, array<string, bool>>|array<string, array<string, string>>|array<string, bool>
175176
*
176177
* @psalm-return array{final_static_access: true, final_public_method_for_abstract_class: true, lowercase_constants: false, global_namespace_import: array{import_classes: true, import_constants: true, import_functions: true}, nullable_type_declaration_for_default_null_value: true, phpdoc_line_span: array{const: string, method: string, property: string}, phpdoc_to_param_type: false, self_static_accessor: true}
177178
*/

tests/Constraint/ArraySubset.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use SebastianBergmann\RecursionContext\InvalidArgumentException;
2323
use Traversable;
2424
use function is_array;
25+
use function Safe\array_replace_recursive;
2526

2627
/**
2728
* Constraint that asserts that the array it is evaluated for has a specified subset.
@@ -32,7 +33,7 @@
3233
final class ArraySubset extends Constraint
3334
{
3435
/** @var mixed[] */
35-
private array $subset;
36+
private array $subset = [];
3637

3738
/**
3839
* @param ArrayObject|iterable|mixed[]|Traversable $subset
@@ -80,14 +81,14 @@ public function evaluate($other, string $description = '', bool $returnResult =
8081
return null;
8182
}
8283

83-
$f = new ComparisonFailure(
84+
$comparisonFailure = new ComparisonFailure(
8485
$patched,
8586
$arr,
8687
var_export($patched, true),
8788
var_export($arr, true)
8889
);
8990

90-
$this->fail($arr, $description, $f);
91+
$this->fail($arr, $description, $comparisonFailure);
9192
}
9293

9394
/**
@@ -124,7 +125,7 @@ protected function failureDescription($other): string
124125
*
125126
* @return mixed[]
126127
*/
127-
protected function toArray(iterable $other): array
128+
private function toArray(iterable $other): array
128129
{
129130
if (is_array($other)) {
130131
return $other;

0 commit comments

Comments
 (0)