Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F953620
ArcanistParentMemberReferenceXHPASTLinterRule.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
joshuaspence
Nov 9 2015, 12:36 AM
2015-11-09 00:36:13 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
ArcanistParentMemberReferenceXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistParentMemberReferenceXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
100
;
public
function
getLintName
()
{
return
pht
(
'Parent Member Reference'
);
}
public
function
getLintSeverity
()
{
return
ArcanistLintSeverity
::
SEVERITY_ADVICE
;
}
public
function
process
(
XHPASTNode
$root
)
{
$class_declarations
=
$root
->
selectDescendantsOfType
(
'n_CLASS_DECLARATION'
);
foreach
(
$class_declarations
as
$class_declaration
)
{
$parent_class
=
$class_declaration
->
getChildOfType
(
2
,
'n_EXTENDS_LIST'
)
->
getChildOfType
(
0
,
'n_CLASS_NAME'
)
->
getConcreteString
();
$class_static_accesses
=
$class_declaration
->
selectDescendantsOfType
(
'n_CLASS_STATIC_ACCESS'
);
$closures
=
$this
->
getAnonymousClosures
(
$class_declaration
);
foreach
(
$class_static_accesses
as
$class_static_access
)
{
$double_colons
=
$class_static_access
->
selectTokensOfType
(
'T_PAAMAYIM_NEKUDOTAYIM'
);
$class_ref
=
$class_static_access
->
getChildByIndex
(
0
);
if
(
$class_ref
->
getTypeName
()
!=
'n_CLASS_NAME'
)
{
continue
;
}
$class_ref_name
=
$class_ref
->
getConcreteString
();
if
(
strtolower
(
$parent_class
)
==
strtolower
(
$class_ref_name
))
{
$in_closure
=
false
;
foreach
(
$closures
as
$closure
)
{
if
(
$class_ref
->
isDescendantOf
(
$closure
))
{
$in_closure
=
true
;
break
;
}
}
if
(
version_compare
(
$this
->
version
,
'5.4.0'
,
'>='
)
||
!
$in_closure
)
{
$this
->
raiseLintAtNode
(
$class_ref
,
pht
(
'Use `%s` to call.'
,
'parent::'
),
'parent'
);
}
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/yp/fh/dxhsuucz2uxx6hzh
Default Alt Text
ArcanistParentMemberReferenceXHPASTLinterRule.php (1 KB)
Attached To
Mode
P1885 ArcanistParentMemberReferenceXHPASTLinterRule.php
Attached
Detach File
Event Timeline
Log In to Comment