Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890548
ArcanistBinaryNumericScalarCasingXHPASTLinterRule.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
ArcanistBinaryNumericScalarCasingXHPASTLinterRule.php
View Options
<?php
final
class
ArcanistBinaryNumericScalarCasingXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
131
;
public
function
getLintName
(
)
{
return
pht
(
'Binary Integer Casing'
)
;
}
public
function
getLintSeverity
(
)
{
return
ArcanistLintSeverity
::
SEVERITY_WARNING
;
}
public
function
process
(
XHPASTNode
$root
)
{
$binaries
=
$this
->
getBinaryNumericScalars
(
$root
)
;
foreach
(
$binaries
as
$binary
)
{
$value
=
substr
(
$binary
->
getConcreteString
(
)
,
2
)
;
if
(
!
preg_match
(
'/^0b[01]+$/'
,
$binary
->
getConcreteString
(
)
)
)
{
$this
->
raiseLintAtNode
(
$binary
,
pht
(
'For consistency, write binary integers with a leading `%s`.'
,
'0b'
)
,
'0b'
.
$value
)
;
}
}
}
private
function
getBinaryNumericScalars
(
XHPASTNode
$root
)
{
$numeric_scalars
=
$root
->
selectDescendantsOfType
(
'n_NUMERIC_SCALAR'
)
;
$binary_numeric_scalars
=
array
(
)
;
foreach
(
$numeric_scalars
as
$numeric_scalar
)
{
$number
=
$numeric_scalar
->
getConcreteString
(
)
;
if
(
preg_match
(
'/^0b[01]+$/i'
,
$number
)
)
{
$binary_numeric_scalars
[
]
=
$numeric_scalar
;
}
}
return
$binary_numeric_scalars
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 13:44 (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1124719
Default Alt Text
ArcanistBinaryNumericScalarCasingXHPASTLinterRule.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment