-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrector.php
More file actions
70 lines (67 loc) · 3.29 KB
/
Copy pathrector.php
File metadata and controls
70 lines (67 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
use RectorLaravel\Rector\ArrayDimFetch\EnvVariableToEnvHelperRector;
use RectorLaravel\Rector\FuncCall\AppToResolveRector;
use RectorLaravel\Rector\StaticCall\CarbonToDateFacadeRector;
use RectorLaravel\Set\LaravelSetList;
return RectorConfig::configure()
// Mirror the paths analyzed by PHPStan (see phpstan.neon), plus tests/.
->withPaths([
__DIR__.'/app',
__DIR__.'/bootstrap/app.php',
__DIR__.'/config',
__DIR__.'/database',
__DIR__.'/routes',
__DIR__.'/tests',
])
// Apply the PHP level set matching the version declared in composer.json.
->withPhpSets()
// Import namespaced class references instead of emitting redundant
// fully-qualified names when a `use` statement already exists. Global
// short classes (e.g. `\Override`) stay qualified as PHP requires.
->withImportNames(importShortClasses: false)
// Conservative, high-signal rule sets. Structural refactors that complement
// Pint (style) and PHPStan (detection) without changing behaviour.
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
earlyReturn: true,
)
// Laravel-aware refactors that modernise framework idioms safely.
->withSets([
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_IF_HELPERS,
])
// Opt out of rules that are noisy or conflict with our conventions. Revisit
// and trim this list as the codebase adopts more of Rector's suggestions.
->withSkip([
// Shadows of pest-plugin-browser classes (#786, #944). They are copies
// of the vendor source with one documented change each, so that a plugin
// bump can be diffed against them; refactoring them structurally would
// make that diff unreadable for no benefit.
__DIR__.'/tests/Browser/Support/Execution.php',
__DIR__.'/tests/Browser/Support/LaravelHttpServer.php',
// Keep explicit constructor bodies readable; do not inline defaults.
InlineConstructorDefaultToPropertyRector::class,
// `app()` and `resolve()` are equivalent; don't churn the codebase over
// a purely stylistic preference.
AppToResolveRector::class,
// The `Date` facade resolves to CarbonImmutable under Larastan, which
// clashes with our explicit `Illuminate\Support\Carbon` type hints.
CarbonToDateFacadeRector::class,
// Unsafe in write contexts: rewrites `unset($_ENV[...])` into
// `unset(Env::get(...))`, which is not valid PHP.
EnvVariableToEnvHelperRector::class,
// The browser plugin's fluent assertion methods declare `: Webpage` but
// return `$this`, which is really an `AwaitableWebpage` at runtime. Rector
// trusts the declared type and keeps trying to narrow the sign-in helper's
// (correct) `AwaitableWebpage` return to `Webpage`, which then breaks the
// suite. Keep the accurate runtime type here.
ReturnTypeFromStrictTypedCallRector::class => [
__DIR__.'/tests/Browser/Helpers.php',
],
]);