-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrules.neon
62 lines (62 loc) · 3.27 KB
/
rules.neon
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
parameters:
# https://github.com/spaze/phpstan-disallowed-calls/blob/main/docs/custom-rules.md
disallowedMethodCalls:
- method: 'Illuminate\Database\Eloquent\Model::update()'
message: 'it assigns attributes through an array and is not type safe, without parameters it is like save().'
errorTip: 'Assign attributes through property assignment, then call save(). If your intention was to not save new models, check $exists explicitly.'
- method: 'Illuminate\Database\Eloquent\Factories\Factory::createOne()'
message: 'creating or filling models through arrays prevents static validation from working.'
errorTip: 'Call createOne() without any parameters, use property assignment to fill the model.'
allowExceptParamsAnyValue:
- position: 1
name: 'attributes'
- method: 'Illuminate\Database\Eloquent\Factories\Factory::makeOne()'
message: 'creating or filling models through arrays prevents static validation from working.'
errorTip: 'Call makeOne() without any parameters, use property assignment to fill the model.'
allowExceptParamsAnyValue:
- position: 1
name: 'attributes'
- method: 'Illuminate\Database\Eloquent\Factories\Factory::create()'
message: 'creating or filling models through arrays prevents static validation from working.'
errorTip: 'Call create() without any parameters, use property assignment to fill the model.'
allowExceptParamsAnyValue:
- position: 1
name: 'attributes'
- method: 'Illuminate\Database\Eloquent\Factories\Factory::make()'
message: 'creating or filling models through arrays prevents static validation from working.'
errorTip: 'Call make() without any parameters, use property assignment to fill the model.'
allowExceptParamsAnyValue:
- position: 1
name: 'attributes'
- method: 'Illuminate\Support\Collection::toArray()'
message: 'because it is inefficient and provides no type inference'
errorTip: 'Use all() instead.'
- method: 'Illuminate\Support\Collection::flatten()'
message: 'because it provides no type inference.'
errorTip: 'Use Illuminate\Support\Collection::flatMap() or MLL\LaravelUtils\Collection\CollectionUtils::flattenOnce() instead.'
- method: 'Illuminate\Support\Collection::where()'
message: 'because it might be not type safe.'
errorTip: 'Use filter()/reject() instead.'
- method: 'Illuminate\Support\Collection::pluck()'
message: 'because it is not type safe.'
errorTip: 'Use map() instead.'
disallowedFunctionCalls:
- function: 'getenv()'
message: 'it does not consider the .env file.'
errorTip: 'Use env() instead.'
- function: 'optional()'
message: 'it undermines type safety.'
errorTip: 'Use the null safe operator ?-> instead.'
disallowedStaticCalls:
- method: 'Illuminate\Database\Eloquent\Builder::create()'
message: 'creating or filling models through arrays prevents static validation from working.'
errorTip: 'Assign attributes through property assignment.'
allowExceptParamsAnyValue:
- position: 1
name: 'attributes'
- method: 'Illuminate\Support\Facades\Event::fake()'
message: 'you MUST limit which events to fake so model events still work.'
errorTip: 'Use Event::fake(MyEvent::class) instead.'
allowParamsAnywhereAnyValue:
- position: 1
name: 'eventsToFake'