Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Feb 4, 2025
1 parent de632bb commit 8d969bb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"pint",
"npm run prettier"
],
"pint": "pint --config pint-strict-imports.json",
"pint": "pint",
"test:pest": "pest --parallel",
"test:phpstan": "phpstan analyse",
"test": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
use Filament\Pages\Dashboard;
use Filament\Pages\Page;
use Filament\Resources\Pages\CreateRecord;
use Filament\Schemas\Components\Component;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
Expand All @@ -19,7 +23,7 @@
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

class SimpleMethodChangesRector extends AbstractRector
class FixMethodsRector extends AbstractRector
{
protected VariableRenamer $variableRenamer;

Expand Down Expand Up @@ -74,6 +78,19 @@ public function getChanges(): array
},
],
],
[
'class' => [
Component::class,
],
'changes' => [
'getChildComponents' => function (ClassMethod $node): void {
$param = new Param(new Variable('slot'), default: new ConstFetch(new Name('null')));
$param->type = new Name('?string');

$node->params = [$param];
},
],
],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

class SimplePropertyChangesRector extends AbstractRector
class FixPropertiesRector extends AbstractRector
{
/**
* @return array<array{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function refactor(Node $node): ?Node
}

/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $classMethod
* @param ClassMethod|Function_|Closure|ArrowFunction $classMethod
*/
private function shouldSkipParam(Param $param, string $expectedName, $classMethod): bool
{
Expand Down
10 changes: 8 additions & 2 deletions packages/upgrade/src/rector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Filament\Infolists\Components\ImageEntry;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\ImageColumn;
use Filament\Upgrade\Rector;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
Expand Down Expand Up @@ -260,12 +262,16 @@
);

$rectorConfig->rules([
Rector\SimpleMethodChangesRector::class,
Rector\SimplePropertyChangesRector::class,
Rector\FixMethodsRector::class,
Rector\FixPropertiesRector::class,
Rector\RenameSchemaParamToMatchTypeRector::class,
]);

$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename(Schema::class, 'schema', 'components'),
new MethodCallRename(ImageColumn::class, 'height', 'imageHeight'),
new MethodCallRename(ImageColumn::class, 'width', 'imageWidth'),
new MethodCallRename(ImageEntry::class, 'height', 'imageHeight'),
new MethodCallRename(ImageEntry::class, 'width', 'imageWidth'),
]);
};
17 changes: 0 additions & 17 deletions pint-strict-imports.json

This file was deleted.

4 changes: 4 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"concat_space": {
"spacing": "one"
},
"fully_qualified_strict_types": {
"import_symbols": true
},
"global_namespace_import": true,
"method_argument_space": true,
"single_trait_insert_per_statement": true,
"types_spaces": {
Expand Down

0 comments on commit 8d969bb

Please sign in to comment.