Page MenuHomePhabricator

Add a linter rule for `parent` references
ClosedPublic

Authored by joshuaspence on Nov 9 2015, 12:59 AM.
Tags
None
Referenced Files
F15548845: D14443.id34959.diff
Sun, Apr 27, 2:29 AM
F15542000: D14443.id.diff
Fri, Apr 25, 2:56 PM
F15541157: D14443.id34959.diff
Fri, Apr 25, 11:04 AM
F15540569: D14443.id34909.diff
Fri, Apr 25, 8:16 AM
F15540568: D14443.id.diff
Fri, Apr 25, 8:16 AM
F15539761: D14443.id35109.diff
Fri, Apr 25, 4:11 AM
F15536732: D14443.id34911.diff
Thu, Apr 24, 10:52 AM
F15536731: D14443.diff
Thu, Apr 24, 10:51 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 8720
Build 10125: Run Core Tests
Build 10124: 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.