File tree Expand file tree Collapse file tree 4 files changed +2
-49
lines changed
fixtures/diagnostics/errors Expand file tree Collapse file tree 4 files changed +2
-49
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -99,11 +99,9 @@ private function collectDiagnostics($node)
99
99
// Find the first ancestor that's a class method. Return an error
100
100
// if there is none, or if the method is static.
101
101
$ method = $ node ->getFirstAncestor (Node \MethodDeclaration::class);
102
- if ($ method === null || $ method ->isStatic ()) {
102
+ if ($ method ->isStatic ()) {
103
103
$ this ->diagnostics [] = new Diagnostic (
104
- $ method === null
105
- ? "\$this can only be used in an object context. "
106
- : "\$this can not be used in static methods. " ,
104
+ "\$this can not be used in static methods. " ,
107
105
Range::fromNode ($ node ),
108
106
null ,
109
107
DiagnosticSeverity::ERROR ,
Original file line number Diff line number Diff line change @@ -71,42 +71,6 @@ public function testThisInStaticMethodProducesError()
71
71
);
72
72
}
73
73
74
- public function testThisInFunctionProducesError ()
75
- {
76
- $ diagnostics = $ this ->collectDiagnostics (
77
- __DIR__ . '/../../fixtures/diagnostics/errors/this_in_function.php '
78
- );
79
-
80
- $ this ->assertCount (1 , $ diagnostics );
81
- $ this ->assertDiagnostic (
82
- $ diagnostics [0 ],
83
- '$this can only be used in an object context. ' ,
84
- DiagnosticSeverity::ERROR ,
85
- new Range (
86
- new Position (4 , 11 ),
87
- new Position (4 , 16 )
88
- )
89
- );
90
- }
91
-
92
- public function testThisInRoot ()
93
- {
94
- $ diagnostics = $ this ->collectDiagnostics (
95
- __DIR__ . '/../../fixtures/diagnostics/errors/this_in_root.php '
96
- );
97
-
98
- $ this ->assertCount (1 , $ diagnostics );
99
- $ this ->assertDiagnostic (
100
- $ diagnostics [0 ],
101
- '$this can only be used in an object context. ' ,
102
- DiagnosticSeverity::ERROR ,
103
- new Range (
104
- new Position (2 , 5 ),
105
- new Position (2 , 10 )
106
- )
107
- );
108
- }
109
-
110
74
public function testThisInMethodProducesNoError ()
111
75
{
112
76
$ diagnostics = $ this ->collectDiagnostics (
You can’t perform that action at this time.
0 commit comments