Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2889679
ArcanistInvalidOctalNumericScalarXHPASTLinterRule.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
ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistInvalidOctalNumericScalarXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
125
;
public
function
getLintName
(
)
{
return
pht
(
'Invalid Octal Numeric Scalar'
)
;
}
public
function
process
(
XHPASTNode
$root
)
{
$octals
=
$this
->
getOctalNumericScalars
(
$root
)
;
foreach
(
$octals
as
$octal
)
{
if
(
!
preg_match
(
'/^0[0-7]*$/'
,
$octal
->
getConcreteString
(
)
)
)
{
$this
->
raiseLintAtNode
(
$octal
,
pht
(
'Invalid octal numeric scalar. `%s` is not a '
.
'valid octal and will be interpreted as `%d`.'
,
$octal
->
getConcreteString
(
)
,
intval
(
$octal
->
getConcreteString
(
)
,
8
)
)
)
;
}
}
}
private
function
getOctalNumericScalars
(
XHPASTNode
$root
)
{
$numeric_scalars
=
$root
->
selectDescendantsOfType
(
'n_NUMERIC_SCALAR'
)
;
$octal_numeric_scalars
=
array
(
)
;
foreach
(
$numeric_scalars
as
$numeric_scalar
)
{
$number
=
$numeric_scalar
->
getConcreteString
(
)
;
if
(
preg_match
(
'/^0\d+$/'
,
$number
)
)
{
$octal_numeric_scalars
[
]
=
$numeric_scalar
;
}
}
return
$octal_numeric_scalars
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 12:29 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1121059
Default Alt Text
ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment