PregQuoteUsage
error on by defaultGroup: Probable bugs · PhpStorm name: PregQuoteUsageInspection
preg_quote() only escapes the pattern delimiter when it is given as the second argument. Called with a single argument, a / or # inside the quoted text breaks the surrounding pattern.
Example
php
<?php
$re1 = '~' . preg_quote($needle) . '~i';
$re2 = preg_quote ( $host );
$re3 = '@^' . preg_quote($path, '@') . '$@';
$re4 = $quoter->preg_quote($needle);Reported:
- line 2: Pass the pattern delimiter to preg_quote() as its second argument.
- line 3: Pass the pattern delimiter to preg_quote() as its second argument.
Configure
In custos.json:
json
{
"rules": {
"PregQuoteUsage": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore PregQuoteUsage
/**
* @noinspection PregQuoteUsageInspection
*/