Page MenuHomePhabricator

Add a linter rule for `parent` references
ClosedPublic

Authored by joshuaspence on Nov 9 2015, 12:59 AM.
Tags
None
Referenced Files
F18268892: D14443.id.diff
Fri, Aug 22, 2:18 PM
F18085301: D14443.diff
Tue, Aug 5, 7:07 PM
Unknown Object (File)
Jun 9 2025, 7:04 AM
Unknown Object (File)
May 31 2025, 1:11 PM
Unknown Object (File)
May 30 2025, 2:51 PM
Unknown Object (File)
May 30 2025, 10:21 AM
Unknown Object (File)
May 30 2025, 4:35 AM
Unknown Object (File)
May 29 2025, 7:09 PM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.