File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \Rules ;
4+
5+ use PhpParser \Node ;
6+ use PhpParser \Node \Name ;
7+ use PHPStan \Analyser \Scope ;
8+ use PHPStan \Testing \RuleTestCase ;
9+
10+ /**
11+ * @extends RuleTestCase<Rule>
12+ */
13+ class NameHookedRuleTest extends RuleTestCase
14+ {
15+
16+ /**
17+ * @return Rule<Node>
18+ */
19+ protected function getRule (): Rule
20+ {
21+ return new class implements Rule {
22+
23+ public function getNodeType (): string
24+ {
25+ return Name::class;
26+ }
27+
28+ /**
29+ * @param Name $node
30+ */
31+ public function processNode (Node $ node , Scope $ scope ): array
32+ {
33+ return RuleErrorBuilder::message ('Found a name: ' . $ node ->toString ())
34+ ->identifier ('test.name.hooked ' )
35+ ->build ();
36+ }
37+
38+ };
39+ }
40+
41+ public function testRule (): void
42+ {
43+ $ this ->analyse ([__DIR__ . '/data/name-hooked.php ' ], [
44+ [
45+ 'Found a name: NameHooked ' ,
46+ 3 ,
47+ ],
48+ ]);
49+ }
50+
51+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace NameHooked ;
You can’t perform that action at this time.
0 commit comments