Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2680426
ArcanistArrayCombineXHPASTLinterRule.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
ArcanistArrayCombineXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistArrayCombineXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
84
;
public
function
getLintName
(
)
{
return
pht
(
'`%s` Unreliable'
,
'array_combine()'
)
;
}
public
function
getLintSeverity
(
)
{
return
ArcanistLintSeverity
::
SEVERITY_DISABLED
;
}
public
function
process
(
XHPASTNode
$root
)
{
$function_calls
=
$this
->
getFunctionCalls
(
$root
,
array
(
'array_combine'
)
)
;
foreach
(
$function_calls
as
$call
)
{
$name
=
$call
->
getChildByIndex
(
0
)
->
getConcreteString
(
)
;
$parameter_list
=
$call
->
getChildOfType
(
1
,
'n_CALL_PARAMETER_LIST'
)
;
if
(
count
(
$parameter_list
->
getChildren
(
)
)
!==
2
)
{
// Wrong number of parameters, but raise that elsewhere if we want.
continue
;
}
$first
=
$parameter_list
->
getChildByIndex
(
0
)
;
$second
=
$parameter_list
->
getChildByIndex
(
1
)
;
if
(
$first
->
getConcreteString
(
)
==
$second
->
getConcreteString
(
)
)
{
$this
->
raiseLintAtNode
(
$call
,
pht
(
'Prior to PHP 5.4, `%s` fails when given empty arrays. '
.
'Prefer to write `%s` as `%s`.'
,
'array_combine()'
,
'array_combine($x, $x)'
,
'array_fuse($x)'
)
)
;
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Dec 19, 17:02 (21 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1008625
Default Alt Text
ArcanistArrayCombineXHPASTLinterRule.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment