-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathrector.php
More file actions
80 lines (73 loc) · 3.84 KB
/
Copy pathrector.php
File metadata and controls
80 lines (73 loc) · 3.84 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
71
72
73
74
75
76
77
78
79
80
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\ConvertStaticToSelfRector;
use Rector\Config\RectorConfig;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\TypeDeclaration\Rector\FuncCall\AddArrowFunctionParamArrayWhereDimFetchRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector;
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
return RectorConfig::configure()
->withPaths([
__DIR__.'/php-classes',
])
// framework layers Slate is hologit-composed against (skeleton-v3 +
// emergence/php-core via its vendor tree, layer-events, saml2, dwoo);
// run script/fetch-analysis-context to populate. Symbols only -- never
// rewritten or reported on.
->withAutoloadPaths([
__DIR__.'/.analysis-context/skeleton-v3/php-classes',
__DIR__.'/.analysis-context/skeleton-v3/vendor/emergence/php-core/src',
__DIR__.'/.analysis-context/skeleton-v3/vendor/emergence/php-core/src-compat',
__DIR__.'/.analysis-context/layer-events/php-classes',
__DIR__.'/.analysis-context/emergence-saml2/php-classes',
__DIR__.'/.analysis-context/dwoo/lib',
])
->withPhpSets(php83: true)
// typeDeclarations is deliberately OFF, unlike the php-core gate this
// mirrors: method signature types (return types especially) fatal any
// downstream subclass that overrides the method without them, and unlike
// php-core -- whose consumers are enumerable -- Slate is subclassed by
// layers that cannot all be audited (slate-cbl/slate-sbg/slate-spark,
// school skeletons, private school-site layers). The very methods the
// set wants to type (save, destroy, getTitle, __classLoaded...) are
// demonstrably overridden downstream without types. Closure-scoped type
// rules are cherry-picked below instead; closures cannot be overridden.
->withPreparedSets(
deadCode: true,
codeQuality: true,
privatization: true,
earlyReturn: true,
)
->withRules([
ClosureReturnTypeRector::class,
AddClosureParamTypeForArrayMapRector::class,
AddArrowFunctionParamArrayWhereDimFetchRector::class,
])
->withSkip([
// Late static binding (static::) is the primary extension mechanism
// of the Emergence class model - school-site layers and product
// sublayers (slate-cbl, slate-sbg, scienceleadership-skeleton...)
// override Slate's statics constantly; never rewrite to self::.
ConvertStaticToSelfRector::class,
// #[Override] hard-couples Slate's methods to the exact parent
// chain present at analysis time, but hologit composition lets
// deeper layers swap parent-class files per site - a cosmetic
// attribute must not be able to turn into a class-load fatal.
AddOverrideAttributeToOverriddenMethodsRector::class,
// match compares strictly; these legacy switches loose-compare
// request params and DB values by design.
ChangeSwitchToMatchRector::class,
// The "extra" arguments this would delete (e.g. in
// AbstractSpreadsheetConnector) look like missing parameters in the
// callee signatures, i.e. real bugs to fix deliberately - deleting
// the arguments would silently codify the data loss.
RemoveExtraParametersRector::class,
// adds `implements Stringable` plus an explicit `: string` on
// __toString - a method-signature type, held per the note on
// typeDeclarations above (downstream layers override __toString
// without it).
StringableForToStringRector::class,
]);