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)
9999 // Find the first ancestor that's a class method. Return an error
100100 // if there is none, or if the method is static.
101101 $ method = $ node ->getFirstAncestor (Node \MethodDeclaration::class);
102- if ($ method === null || $ method ->isStatic ()) {
102+ if ($ method ->isStatic ()) {
103103 $ 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. " ,
107105 Range::fromNode ($ node ),
108106 null ,
109107 DiagnosticSeverity::ERROR ,
Original file line number Diff line number Diff line change @@ -71,42 +71,6 @@ public function testThisInStaticMethodProducesError()
7171 );
7272 }
7373
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-
11074 public function testThisInMethodProducesNoError ()
11175 {
11276 $ diagnostics = $ this ->collectDiagnostics (
You can’t perform that action at this time.
0 commit comments