Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22401394
ArcanistPregQuoteMisuseXHPASTLinterRule.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
ArcanistPregQuoteMisuseXHPASTLinterRule.php
View Options
<?php
/**
* @{function:preg_quote} takes two arguments, but the second one is optional
* because it is possible to use `()`, `[]` or `{}` as regular expression
* delimiters. If you don't pass a second argument, you're probably going to
* get something wrong.
*/
final
class
ArcanistPregQuoteMisuseXHPASTLinterRule
extends
ArcanistXHPASTLinterRule
{
const
ID
=
14
;
public
function
getLintName
()
{
return
pht
(
'Misuse of %s'
,
'preg_quote()'
);
}
public
function
getLintSeverity
()
{
return
ArcanistLintSeverity
::
SEVERITY_ADVICE
;
}
public
function
process
(
XHPASTNode
$root
)
{
$function_calls
=
$this
->
getFunctionCalls
(
$root
,
array
(
'preg_quote'
));
foreach
(
$function_calls
as
$call
)
{
$parameter_list
=
$call
->
getChildOfType
(
1
,
'n_CALL_PARAMETER_LIST'
);
if
(
count
(
$parameter_list
->
getChildren
())
!==
2
)
{
$this
->
raiseLintAtNode
(
$call
,
pht
(
'If you use pattern delimiters that require escaping '
.
'(such as `%s`, but not `%s`) then you should pass two '
.
'arguments to %s, so that %s knows which delimiter to escape.'
,
'//'
,
'()'
,
'preg_quote()'
,
'preg_quote()'
));
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 27, 18:20 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1222398
Default Alt Text
ArcanistPregQuoteMisuseXHPASTLinterRule.php (1 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline