diff --git a/fixtures/diagnostics/errors/this_in_function.php b/fixtures/diagnostics/errors/this_in_function.php deleted file mode 100644 index db6139d..0000000 --- a/fixtures/diagnostics/errors/this_in_function.php +++ /dev/null @@ -1,6 +0,0 @@ -getFirstAncestor(Node\MethodDeclaration::class); - if ($method === null || $method->isStatic()) { + if ($method->isStatic()) { $this->diagnostics[] = new Diagnostic( - $method === null - ? "\$this can only be used in an object context." - : "\$this can not be used in static methods.", + "\$this can not be used in static methods.", Range::fromNode($node), null, DiagnosticSeverity::ERROR, diff --git a/tests/Diagnostics/InvalidThisUsageTest.php b/tests/Diagnostics/InvalidThisUsageTest.php index 7542918..b7e8196 100644 --- a/tests/Diagnostics/InvalidThisUsageTest.php +++ b/tests/Diagnostics/InvalidThisUsageTest.php @@ -71,42 +71,6 @@ class InvalidThisUsageTest extends TestCase ); } - public function testThisInFunctionProducesError() - { - $diagnostics = $this->collectDiagnostics( - __DIR__ . '/../../fixtures/diagnostics/errors/this_in_function.php' - ); - - $this->assertCount(1, $diagnostics); - $this->assertDiagnostic( - $diagnostics[0], - '$this can only be used in an object context.', - DiagnosticSeverity::ERROR, - new Range( - new Position(4, 11), - new Position(4, 16) - ) - ); - } - - public function testThisInRoot() - { - $diagnostics = $this->collectDiagnostics( - __DIR__ . '/../../fixtures/diagnostics/errors/this_in_root.php' - ); - - $this->assertCount(1, $diagnostics); - $this->assertDiagnostic( - $diagnostics[0], - '$this can only be used in an object context.', - DiagnosticSeverity::ERROR, - new Range( - new Position(2, 5), - new Position(2, 10) - ) - ); - } - public function testThisInMethodProducesNoError() { $diagnostics = $this->collectDiagnostics(