1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-03-28 20:18:12 +01:00
phorge-arcanist/src/lint/linter/__tests__/xhpast/class-name-literal.lint-test
Joshua Spence 9090efcb40 Add a linter rule to prevent hardcoded class names
Summary: Add a linter rule to advise against the use of hardcoded class names. Hardcoded class names make the code harder to refactor and it is generally preferable to use the `__CLASS__` magic constant instead.

Test Plan: This works, but needs some polish.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12605
2015-05-13 06:51:15 +10:00

29 lines
472 B
Text

<?php
class MyClass {
public function someMethod() {
return 'MyClass';
}
public function someOtherMethod() {
$x = 'MyClass is awesome';
$y = 'MyClassIsAwesome';
return __CLASS__;
}
}
~~~~~~~~~~
error:2:7
advice:4:12
advice:8:10
~~~~~~~~~~
<?php
class MyClass {
public function someMethod() {
return __CLASS__;
}
public function someOtherMethod() {
$x = 'MyClass is awesome';
$y = 'MyClassIsAwesome';
return __CLASS__;
}
}