EregToPregFixer
extends AbstractFixer
in package
FinalYes
Tags
Table of Contents
Properties
- $delimiters : array<int, string>
- $functions : array<int, array<int, string>>
Methods
- getDefinition() : FixerDefinitionInterface
- getPriority() : int
- {@inheritdoc}
- isCandidate() : bool
- isRisky() : bool
- applyFix() : void
- checkPreg() : bool
- Check the validity of a PCRE.
- getBestDelimiter() : string
- Get the delimiter that would require the least escaping in a regular expression.
Properties
$delimiters
private
static array<int, string>
$delimiters
= ['/', '#', '!']
the list of preg delimiters, in order of preference
$functions
private
static array<int, array<int, string>>
$functions
= [['ereg', 'preg_match', ''], ['eregi', 'preg_match', 'i'], ['ereg_replace', 'preg_replace', ''], ['eregi_replace', 'preg_replace', 'i'], ['split', 'preg_split', ''], ['spliti', 'preg_split', 'i']]
the list of the ext/ereg function names, their preg equivalent and the preg modifier(s), if any all condensed in an array of arrays
Methods
getDefinition()
public
getDefinition() : FixerDefinitionInterface
Return values
FixerDefinitionInterfacegetPriority()
{@inheritdoc}
public
getPriority() : int
Must run after NoUselessConcatOperatorFixer.
Return values
intisCandidate()
public
isCandidate(Tokens $tokens) : bool
Parameters
- $tokens : Tokens
Return values
boolisRisky()
public
isRisky() : bool
Return values
boolapplyFix()
protected
applyFix(SplFileInfo $file, Tokens $tokens) : void
Parameters
- $file : SplFileInfo
- $tokens : Tokens
checkPreg()
Check the validity of a PCRE.
private
checkPreg(string $pattern) : bool
Parameters
- $pattern : string
-
the regular expression
Return values
boolgetBestDelimiter()
Get the delimiter that would require the least escaping in a regular expression.
private
getBestDelimiter(string $pattern) : string
Parameters
- $pattern : string
-
the regular expression
Return values
string —the preg delimiter