• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mpyw / laravel-local-class-scope / 27456829111

13 Jun 2026 04:41AM UTC coverage: 92.405% (-7.6%) from 100.0%
27456829111

push

github

web-flow
Implement PHPStan extension to get better static analysis support for the `scoped` method (#11)

* Add application for testing PHPStan extension

* Add tests for PHPStan extension

* Implement PHPStan extension

To get better static analysis support for the `scoped` method.

* Add extension.neon

* Add phpstan.neon.dist

* Update composer.json

* Update README.md

62 of 68 new or added lines in 3 files covered. (91.18%)

73 of 79 relevant lines covered (92.41%)

13.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.8
/src/PHPStan/Reflection/ScopedMethodReflection.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Mpyw\LaravelLocalClassScope\PHPStan\Reflection;
6

7
use Illuminate\Database\Eloquent\Scope;
8
use Override;
9
use PHPStan\Reflection\ClassReflection;
10
use PHPStan\Reflection\FunctionVariant;
11
use PHPStan\Reflection\MethodReflection;
12
use PHPStan\TrinaryLogic;
13
use PHPStan\Type\Generic\GenericClassStringType;
14
use PHPStan\Type\Generic\TemplateTypeMap;
15
use PHPStan\Type\MixedType;
16
use PHPStan\Type\ObjectType;
17
use PHPStan\Type\Type;
18
use PHPStan\Type\UnionType;
19

20
final class ScopedMethodReflection implements MethodReflection
21
{
22
    public function __construct(
23
        private readonly ClassReflection $declaringClass,
24
        private readonly Type $returnType,
25
        private readonly bool $isStatic,
26
    ) {}
11✔
27

28
    #[Override]
29
    public function getName(): string
30
    {
31
        return 'scoped';
11✔
32
    }
33

34
    #[Override]
35
    public function getPrototype(): MethodReflection
36
    {
NEW
37
        return $this;
×
38
    }
39

40
    #[Override]
41
    public function getVariants(): array
42
    {
43
        return [
11✔
44
            new FunctionVariant(
11✔
45
                TemplateTypeMap::createEmpty(),
11✔
46
                null,
11✔
47
                [
11✔
48
                    new ScopedParameterReflection(
11✔
49
                        'scope',
11✔
50
                        new UnionType([
11✔
51
                            new ObjectType(Scope::class),
11✔
52
                            new GenericClassStringType(
11✔
53
                                new ObjectType(Scope::class),
11✔
54
                            ),
11✔
55
                        ]),
11✔
56
                        false,
11✔
57
                        false,
11✔
58
                    ),
11✔
59
                    new ScopedParameterReflection(
11✔
60
                        'parameters',
11✔
61
                        new MixedType,
11✔
62
                        true,
11✔
63
                        true,
11✔
64
                    ),
11✔
65
                ],
11✔
66
                true,
11✔
67
                $this->returnType,
11✔
68
            ),
11✔
69
        ];
11✔
70
    }
71

72
    #[Override]
73
    public function isDeprecated(): TrinaryLogic
74
    {
NEW
75
        return TrinaryLogic::createNo();
×
76
    }
77

78
    #[Override]
79
    public function getDeprecatedDescription(): ?string
80
    {
NEW
81
        return null;
×
82
    }
83

84
    #[Override]
85
    public function isFinal(): TrinaryLogic
86
    {
87
        return TrinaryLogic::createNo();
11✔
88
    }
89

90
    #[Override]
91
    public function isInternal(): TrinaryLogic
92
    {
NEW
93
        return TrinaryLogic::createNo();
×
94
    }
95

96
    #[Override]
97
    public function getThrowType(): ?Type
98
    {
99
        return null;
11✔
100
    }
101

102
    #[Override]
103
    public function hasSideEffects(): TrinaryLogic
104
    {
105
        return TrinaryLogic::createYes();
11✔
106
    }
107

108
    #[Override]
109
    public function getDeclaringClass(): ClassReflection
110
    {
111
        return $this->declaringClass;
11✔
112
    }
113

114
    #[Override]
115
    public function isStatic(): bool
116
    {
117
        return $this->isStatic;
11✔
118
    }
119

120
    #[Override]
121
    public function isPrivate(): bool
122
    {
123
        return false;
11✔
124
    }
125

126
    #[Override]
127
    public function isPublic(): bool
128
    {
129
        return true;
11✔
130
    }
131

132
    #[Override]
133
    public function getDocComment(): ?string
134
    {
NEW
135
        return null;
×
136
    }
137
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc