|
21 | 21 | use Guanguans\MonorepoBuilderWorker\Support\Rectors\RemoveNamespaceRector; |
22 | 22 | use Guanguans\SoarPHP\Contracts\Throwable; |
23 | 23 | use Guanguans\SoarPHP\Support\Rectors\AddDocCommentForHasOptionsRector; |
| 24 | +use Illuminate\Support\Str; |
24 | 25 | use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; |
25 | 26 | use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector; |
26 | 27 | use Rector\CodingStyle\Rector\ArrowFunction\StaticArrowFunctionRector; |
|
39 | 40 | use Rector\Php80\ValueObject\AnnotationToAttribute; |
40 | 41 | use Rector\PHPUnit\Set\PHPUnitSetList; |
41 | 42 | use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; |
| 43 | +use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; |
| 44 | +use Rector\Transform\ValueObject\StaticCallToFuncCall; |
42 | 45 | use Rector\ValueObject\PhpVersion; |
| 46 | +use Rector\ValueObject\Visibility; |
| 47 | +use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; |
| 48 | +use Rector\Visibility\ValueObject\ChangeMethodVisibility; |
43 | 49 | use function Guanguans\SoarPHP\Support\classes; |
44 | 50 |
|
45 | 51 | return RectorConfig::configure() |
|
123 | 129 | 'phpstan-ignore-next-line', |
124 | 130 | 'psalm-suppress', |
125 | 131 | ]) |
| 132 | + ->withConfiguredRule(StaticCallToFuncCallRector::class, [ |
| 133 | + new StaticCallToFuncCall(Str::class, 'of', 'str'), |
| 134 | + ]) |
| 135 | + ->withConfiguredRule( |
| 136 | + ChangeMethodVisibilityRector::class, |
| 137 | + classes(static fn (string $class, string $file): bool => str_starts_with($class, 'Guanguans\SoarPHP')) |
| 138 | + ->filter(static fn (ReflectionClass $reflectionClass): bool => $reflectionClass->isTrait()) |
| 139 | + ->map( |
| 140 | + static fn (ReflectionClass $reflectionClass): array => collect($reflectionClass->getMethods(ReflectionMethod::IS_PRIVATE)) |
| 141 | + ->reject(static fn (ReflectionMethod $reflectionMethod): bool => $reflectionMethod->isFinal() || $reflectionMethod->isInternal()) |
| 142 | + ->map(static fn (ReflectionMethod $reflectionMethod): ChangeMethodVisibility => new ChangeMethodVisibility( |
| 143 | + $reflectionClass->getName(), |
| 144 | + $reflectionMethod->getName(), |
| 145 | + Visibility::PROTECTED |
| 146 | + )) |
| 147 | + ->all() |
| 148 | + ) |
| 149 | + ->flatten() |
| 150 | + // ->dd() |
| 151 | + ->all(), |
| 152 | + ) |
126 | 153 | ->withConfiguredRule( |
127 | 154 | RenameFunctionRector::class, |
128 | 155 | [ |
129 | 156 | 'Pest\Faker\fake' => 'fake', |
130 | | - 'Pest\Faker\faker' => 'faker', |
| 157 | + 'Pest\Faker\faker' => 'fake', |
131 | 158 | 'faker' => 'fake', |
132 | 159 | 'test' => 'it', |
133 | 160 | ] + array_reduce( |
|
0 commit comments