Page MenuHomePhabricator

Add a linter rule for `parent` references
ClosedPublic

Authored by joshuaspence on Nov 9 2015, 12:59 AM.
Tags
None
Referenced Files
F18857108: D14443.id.diff
Sat, Nov 1, 1:16 PM
F18831708: D14443.id.diff
Sat, Oct 25, 2:43 PM
F18828977: D14443.diff
Fri, Oct 24, 7:03 PM
F18820892: D14443.id35007.diff
Wed, Oct 22, 5:40 PM
F18818166: D14443.id34911.diff
Tue, Oct 21, 9:44 PM
F18811945: D14443.id35109.diff
Mon, Oct 20, 5:59 AM
F18784906: D14443.id35053.diff
Mon, Oct 13, 3:43 PM
F18712836: D14443.id.diff
Sep 29 2025, 5:33 AM
Subscribers

Details

Summary

Add a linter rule to detect static method calls which should reference the parent class instead of a hardcoded class reference. For example, consider the following:

class SomeClass extends AnotherClass {
  public function someMethod() {
    AnotherClass::someOtherMethod();
  }
}

This should instead be written as:

class SomeClass extends AnotherClass {
  public function someMethod() {
    parent::someOtherMethod();
  }
}
Test Plan

Added unit tests.

Diff Detail

Repository
rARC Arcanist
Branch
master
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 8722
Build 10129: Run Core Tests
Build 10128: arc lint + arc unit

Event Timeline

joshuaspence retitled this revision from to Add a linter rule for `parent` references.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence edited the test plan for this revision. (Show Details)
epriestley added a reviewer: epriestley.
epriestley added inline comments.
src/lint/linter/xhpast/rules/ArcanistParentMemberReferenceXHPASTLinterRule.php
63

Extra period in human-readable message.

This revision is now accepted and ready to land.Nov 15 2015, 4:52 PM
joshuaspence edited edge metadata.

Fix lint message

This revision was automatically updated to reflect the committed changes.