Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22421103
ArcanistInvalidModifiersXHPASTLinterRule.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
ArcanistInvalidModifiersXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistInvalidModifiersXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
72
;
public
function
getLintName
()
{
return
pht
(
'Invalid Modifiers'
);
}
public
function
process
(
XHPASTNode
$root
)
{
$methods
=
$root
->
selectDescendantsOfTypes
(
array
(
'n_CLASS_MEMBER_MODIFIER_LIST'
,
'n_METHOD_MODIFIER_LIST'
,
));
foreach
(
$methods
as
$method
)
{
$modifiers
=
$method
->
getChildren
();
$is_abstract
=
false
;
$is_final
=
false
;
$is_static
=
false
;
$visibility
=
null
;
foreach
(
$modifiers
as
$modifier
)
{
switch
(
$modifier
->
getConcreteString
())
{
case
'abstract'
:
if
(
$method
->
getTypeName
()
==
'n_CLASS_MEMBER_MODIFIER_LIST'
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Properties cannot be declared %s.'
,
'abstract'
));
}
if
(
$is_abstract
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Multiple %s modifiers are not allowed.'
,
'abstract'
));
}
if
(
$is_final
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Cannot use the %s modifier on an %s class member'
,
'final'
,
'abstract'
));
}
$is_abstract
=
true
;
break
;
case
'final'
:
if
(
$is_abstract
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Cannot use the %s modifier on an %s class member'
,
'final'
,
'abstract'
));
}
if
(
$is_final
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Multiple %s modifiers are not allowed.'
,
'final'
));
}
$is_final
=
true
;
break
;
case
'public'
:
case
'protected'
:
case
'private'
:
if
(
$visibility
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Multiple access type modifiers are not allowed.'
));
}
$visibility
=
$modifier
->
getConcreteString
();
break
;
case
'static'
:
if
(
$is_static
)
{
$this
->
raiseLintAtNode
(
$modifier
,
pht
(
'Multiple %s modifiers are not allowed.'
,
'static'
));
}
break
;
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 28, 03:05 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1219157
Default Alt Text
ArcanistInvalidModifiersXHPASTLinterRule.php (2 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline