Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15393166
D12385.id29782.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12385.id29782.diff
View Options
diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php
--- a/src/lint/linter/ArcanistXHPASTLinter.php
+++ b/src/lint/linter/ArcanistXHPASTLinter.php
@@ -3407,14 +3407,16 @@
$class_static_accesses = $class_declaration
->selectDescendantsOfType('n_CLASS_STATIC_ACCESS');
- $self_member_references = array();
foreach ($class_static_accesses as $class_static_access) {
- $double_colons = $class_static_access
+ $double_colons = $class_static_access
->selectTokensOfType('T_PAAMAYIM_NEKUDOTAYIM');
- $class_ref = $class_static_access
- ->getChildOfType(0, 'n_CLASS_NAME');
- $class_ref_name = $class_ref->getConcreteString();
+ $class_ref = $class_static_access->getChildByIndex(0);
+
+ if ($class_ref->getTypeName() != 'n_CLASS_NAME') {
+ continue;
+ }
+ $class_ref_name = $class_ref->getConcreteString();
if (strtolower($class_name) == strtolower($class_ref_name)) {
$this->raiseLintAtNode(
@@ -3441,20 +3443,23 @@
pht('PHP keywords should be lowercase.'),
strtolower($class_ref_name));
}
+ }
+ }
- foreach ($double_colons as $double_colon) {
- $tokens = $double_colon->getNonsemanticTokensBefore() +
- $double_colon->getNonsemanticTokensAfter();
+ $double_colons = $root
+ ->selectTokensOfType('T_PAAMAYIM_NEKUDOTAYIM');
- foreach ($tokens as $token) {
- if ($token->isAnyWhitespace()) {
- $this->raiseLintAtToken(
- $token,
- self::LINT_SELF_MEMBER_REFERENCE,
- pht('Unnecessary whitespace around double colon operator.'),
- '');
- }
- }
+ foreach ($double_colons as $double_colon) {
+ $tokens = $double_colon->getNonsemanticTokensBefore() +
+ $double_colon->getNonsemanticTokensAfter();
+
+ foreach ($tokens as $token) {
+ if ($token->isAnyWhitespace()) {
+ $this->raiseLintAtToken(
+ $token,
+ self::LINT_SELF_MEMBER_REFERENCE,
+ pht('Unnecessary whitespace around double colon operator.'),
+ '');
}
}
}
diff --git a/src/lint/linter/__tests__/xhpast/self-member-references.lint-test b/src/lint/linter/__tests__/xhpast/self-member-references.lint-test
--- a/src/lint/linter/__tests__/xhpast/self-member-references.lint-test
+++ b/src/lint/linter/__tests__/xhpast/self-member-references.lint-test
@@ -12,11 +12,15 @@
echo Self :: FOOBAR;
}
- public function baz() {
+ public function baz(Foo $x) {
echo static::FOOBAR;
echo Foo::FOOBAR;
+
+ $x::bar();
}
}
+
+MyClass :: myMethod();
~~~~~~~~~~
error:3:7
advice:7:5
@@ -24,6 +28,8 @@
advice:12:14
advice:12:17
advice:17:10
+advice:23:8
+advice:23:11
~~~~~~~~~~
<?php
@@ -39,8 +45,12 @@
echo self::FOOBAR;
}
- public function baz() {
+ public function baz(Foo $x) {
echo static::FOOBAR;
echo self::FOOBAR;
+
+ $x::bar();
}
}
+
+MyClass::myMethod();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 8:10 PM (6 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7707622
Default Alt Text
D12385.id29782.diff (3 KB)
Attached To
Mode
D12385: Improvements to "self member reference" linter rule
Attached
Detach File
Event Timeline
Log In to Comment