Page MenuHomePhabricator

Add a linter rule for incorrect use of parent scope
ClosedPublic

Authored by joshuaspence on Apr 15 2015, 10:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 2, 5:02 PM
Unknown Object (File)
May 6 2025, 11:40 AM
Unknown Object (File)
Apr 26 2025, 6:51 AM
Unknown Object (File)
Apr 21 2025, 7:42 PM
Unknown Object (File)
Apr 19 2025, 7:28 PM
Unknown Object (File)
Apr 19 2025, 2:05 PM
Unknown Object (File)
Apr 18 2025, 8:02 PM
Unknown Object (File)
Apr 17 2025, 3:35 PM
Subscribers

Details

Summary

The following code is invalid:

final class MyClass {
  public function __construct() {
    parent::__construct(null);
  }
}

$x = new MyClass();

Running the above code will produce a fatal error:

PHP Fatal error:  Cannot access parent:: when current class scope has no parent
Test Plan

Added unit tests.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable