Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2901382
ArcanistArrayValueXHPASTLinterRule.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
ArcanistArrayValueXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistArrayValueXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
76
;
public
function
getLintName
(
)
{
return
pht
(
'Array Element'
)
;
}
public
function
getLintSeverity
(
)
{
return
ArcanistLintSeverity
::
SEVERITY_WARNING
;
}
public
function
process
(
XHPASTNode
$root
)
{
$arrays
=
$root
->
selectDescendantsOfType
(
'n_ARRAY_LITERAL'
)
;
foreach
(
$arrays
as
$array
)
{
$array_values
=
$array
->
getChildOfType
(
0
,
'n_ARRAY_VALUE_LIST'
)
->
getChildrenOfType
(
'n_ARRAY_VALUE'
)
;
if
(
!
$array_values
)
{
// There is no need to check an empty array.
continue
;
}
$multiline
=
$array
->
getLineNumber
(
)
!=
$array
->
getEndLineNumber
(
)
;
if
(
!
$multiline
)
{
continue
;
}
foreach
(
$array_values
as
$value
)
{
list
(
$before
,
$after
)
=
$value
->
getSurroundingNonsemanticTokens
(
)
;
if
(
strpos
(
implode
(
''
,
mpull
(
$before
,
'getValue'
)
)
,
"\n"
)
===
false
)
{
if
(
last
(
$before
)
&&
last
(
$before
)
->
isAnyWhitespace
(
)
)
{
$token
=
last
(
$before
)
;
$replacement
=
"\n"
.
$value
->
getIndentation
(
)
;
}
else
{
$token
=
head
(
$value
->
getTokens
(
)
)
;
$replacement
=
"\n"
.
$value
->
getIndentation
(
)
.
$token
->
getValue
(
)
;
}
$this
->
raiseLintAtToken
(
$token
,
pht
(
'Array elements should each occupy a single line.'
)
,
$replacement
)
;
}
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Jan 20, 08:57 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1120687
Default Alt Text
ArcanistArrayValueXHPASTLinterRule.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment