Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2889081
ArcanistSelfClassReferenceXHPASTLinterRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
ArcanistSelfClassReferenceXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistSelfClassReferenceXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
95
;
public
function
getLintName
(
)
{
return
pht
(
'Self Class Reference'
)
;
}
public
function
getLintSeverity
(
)
{
return
ArcanistLintSeverity
::
SEVERITY_WARNING
;
}
public
function
process
(
XHPASTNode
$root
)
{
$class_declarations
=
$root
->
selectDescendantsOfType
(
'n_CLASS_DECLARATION'
)
;
foreach
(
$class_declarations
as
$class_declaration
)
{
if
(
$class_declaration
->
getChildByIndex
(
1
)
->
getTypeName
(
)
==
'n_EMPTY'
)
{
continue
;
}
$class_name
=
$class_declaration
->
getChildOfType
(
1
,
'n_CLASS_NAME'
)
->
getConcreteString
(
)
;
$instantiations
=
$class_declaration
->
selectDescendantsOfType
(
'n_NEW'
)
;
foreach
(
$instantiations
as
$instantiation
)
{
$type
=
$instantiation
->
getChildByIndex
(
0
)
;
if
(
$type
->
getTypeName
(
)
!=
'n_CLASS_NAME'
)
{
continue
;
}
if
(
strtolower
(
$type
->
getConcreteString
(
)
)
==
strtolower
(
$class_name
)
)
{
$this
->
raiseLintAtNode
(
$type
,
pht
(
'Use `%s` to instantiate the current class.'
,
'self'
)
,
'self'
)
;
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 11:20 (5 w, 17 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1121086
Default Alt Text
ArcanistSelfClassReferenceXHPASTLinterRule.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment