Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3282174
ArcanistToStringExceptionXHPASTLinterRule.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
993 B
Referenced Files
None
Subscribers
None
ArcanistToStringExceptionXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistToStringExceptionXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
67
;
public
function
getLintName
(
)
{
return
pht
(
'Throwing Exception in `%s` Method'
,
'__toString'
)
;
}
public
function
process
(
XHPASTNode
$root
)
{
$methods
=
$root
->
selectDescendantsOfType
(
'n_METHOD_DECLARATION'
)
;
foreach
(
$methods
as
$method
)
{
$name
=
$method
->
getChildOfType
(
2
,
'n_STRING'
)
->
getConcreteString
(
)
;
if
(
$name
!=
'__toString'
)
{
continue
;
}
$statements
=
$method
->
getChildByIndex
(
6
)
;
if
(
$statements
->
getTypeName
(
)
!=
'n_STATEMENT_LIST'
)
{
continue
;
}
$throws
=
$statements
->
selectDescendantsOfType
(
'n_THROW'
)
;
foreach
(
$throws
as
$throw
)
{
$this
->
raiseLintAtNode
(
$throw
,
pht
(
'It is not possible to throw an `%s` from within the `%s` method.'
,
'Exception'
,
'__toString'
)
)
;
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Mar 24, 05:45 (4 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1120367
Default Alt Text
ArcanistToStringExceptionXHPASTLinterRule.php (993 B)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment