Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22401028
ArcanistInvalidOctalNumericScalarXHPASTLinterRule.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
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
Fri, Nov 27, 18:15 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1206134
Default Alt Text
ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php (1 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline