Skip to content

Commit

Permalink
Merge pull request #13 from dimitriBouteille/12-update-rector-configu…
Browse files Browse the repository at this point in the history
…ration

#12 Update rector config
  • Loading branch information
dimitriBouteille authored Mar 3, 2024
2 parents c4b5649 + c814970 commit e513706
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
37 changes: 19 additions & 18 deletions rector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2024 Dimitri BOUTEILLE (https://github.com/dimitriBouteille)
* Copyright (c) Dimitri BOUTEILLE (https://github.com/dimitriBouteille)
* See LICENSE.txt for license details.
*
* Author: Dimitri BOUTEILLE <[email protected]>
Expand All @@ -13,23 +13,24 @@
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
]);

// register single rule
$rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class);

$rectorConfig
->skip([
SimplifyBoolIdenticalTrueRector::class,
CallableThisArrayToAnonymousFunctionRector::class,
SimplifyIfReturnBoolRector::class,
]);

$rectorConfig->sets([
SetList::CODE_QUALITY,
__DIR__ . '/tests',
])
->withRules([
TypedPropertyFromStrictConstructorRector::class,
])
->withPreparedSets(
codeQuality: true,
typeDeclarations: true,
instanceOf: true,
)
->withSets([
SetList::PHP_81,
])
->withSkip([
SimplifyBoolIdenticalTrueRector::class,
CallableThisArrayToAnonymousFunctionRector::class,
SimplifyIfReturnBoolRector::class,
]);
};
4 changes: 2 additions & 2 deletions src/Loaders/AnnotationDirectoryLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public function load(mixed $resource): array
$files = iterator_to_array(new \RecursiveIteratorIterator(
new \RecursiveCallbackFilterIterator(
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
function (\SplFileInfo $current) {
function (\SplFileInfo $current): bool {
return !str_starts_with($current->getBasename(), '.');
}
),
\RecursiveIteratorIterator::LEAVES_ONLY
));

usort($files, function (\SplFileInfo $a, \SplFileInfo $b) {
usort($files, function (\SplFileInfo $a, \SplFileInfo $b): int {
return (string) $a > (string) $b ? 1 : -1;
});

Expand Down
2 changes: 1 addition & 1 deletion src/RouteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function checkRoutes(array $routes): void
public function register(): void
{
$routes = $this->getRoutes();
add_action('rest_api_init', function () use ($routes) {
add_action('rest_api_init', function () use ($routes): void {
foreach ($routes as $route) {
register_rest_route(
$route->namespace,
Expand Down

0 comments on commit e513706

Please sign in to comment.