[String] Renamed a method argument

This commit is contained in:
Javier Eguiluz 2019-10-08 09:30:11 +02:00 committed by Nicolas Grekas
parent 7df0b6caf6
commit 1648c0e12d
4 changed files with 17 additions and 17 deletions

View File

@ -404,11 +404,11 @@ abstract class AbstractString implements \JsonSerializable
/** /**
* Matches the string using a regular expression. * Matches the string using a regular expression.
* *
* Pass PREG_PATTERN_ORDER or PREG_SET_ORDER as $flags to get all occurrences matching the pattern. * Pass PREG_PATTERN_ORDER or PREG_SET_ORDER as $flags to get all occurrences matching the regular expression.
* *
* @return array All matches in a multi-dimensional array ordered according to flags * @return array All matches in a multi-dimensional array ordered according to flags
*/ */
abstract public function match(string $pattern, int $flags = 0, int $offset = 0): array; abstract public function match(string $regexp, int $flags = 0, int $offset = 0): array;
/** /**
* @return static * @return static
@ -455,7 +455,7 @@ abstract class AbstractString implements \JsonSerializable
* *
* @return static * @return static
*/ */
abstract public function replaceMatches(string $fromPattern, $to): self; abstract public function replaceMatches(string $fromRegexp, $to): self;
/** /**
* @return static * @return static

View File

@ -200,18 +200,18 @@ abstract class AbstractUnicodeString extends AbstractString
return $str; return $str;
} }
public function match(string $pattern, int $flags = 0, int $offset = 0): array public function match(string $regexp, int $flags = 0, int $offset = 0): array
{ {
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
if ($this->ignoreCase) { if ($this->ignoreCase) {
$pattern .= 'i'; $regexp .= 'i';
} }
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
try { try {
if (false === $match($pattern.'u', $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) { if (false === $match($regexp.'u', $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) {
$lastError = preg_last_error(); $lastError = preg_last_error();
foreach (get_defined_constants(true)['pcre'] as $k => $v) { foreach (get_defined_constants(true)['pcre'] as $k => $v) {
@ -280,10 +280,10 @@ abstract class AbstractUnicodeString extends AbstractString
return $this->pad($length, $pad, STR_PAD_LEFT); return $this->pad($length, $pad, STR_PAD_LEFT);
} }
public function replaceMatches(string $fromPattern, $to): parent public function replaceMatches(string $fromRegexp, $to): parent
{ {
if ($this->ignoreCase) { if ($this->ignoreCase) {
$fromPattern .= 'i'; $fromRegexp .= 'i';
} }
if (\is_array($to) || $to instanceof \Closure) { if (\is_array($to) || $to instanceof \Closure) {
@ -310,7 +310,7 @@ abstract class AbstractUnicodeString extends AbstractString
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
try { try {
if (null === $string = $replace($fromPattern.'u', $to, $this->string)) { if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) {
$lastError = preg_last_error(); $lastError = preg_last_error();
foreach (get_defined_constants(true)['pcre'] as $k => $v) { foreach (get_defined_constants(true)['pcre'] as $k => $v) {

View File

@ -189,18 +189,18 @@ class ByteString extends AbstractString
return $str; return $str;
} }
public function match(string $pattern, int $flags = 0, int $offset = 0): array public function match(string $regexp, int $flags = 0, int $offset = 0): array
{ {
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
if ($this->ignoreCase) { if ($this->ignoreCase) {
$pattern .= 'i'; $regexp .= 'i';
} }
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
try { try {
if (false === $match($pattern, $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) { if (false === $match($regexp, $this->string, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset)) {
$lastError = preg_last_error(); $lastError = preg_last_error();
foreach (get_defined_constants(true)['pcre'] as $k => $v) { foreach (get_defined_constants(true)['pcre'] as $k => $v) {
@ -261,10 +261,10 @@ class ByteString extends AbstractString
return $str; return $str;
} }
public function replaceMatches(string $fromPattern, $to): parent public function replaceMatches(string $fromRegexp, $to): parent
{ {
if ($this->ignoreCase) { if ($this->ignoreCase) {
$fromPattern .= 'i'; $fromRegexp .= 'i';
} }
if (\is_array($to)) { if (\is_array($to)) {
@ -280,7 +280,7 @@ class ByteString extends AbstractString
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
try { try {
if (null === $string = $replace($fromPattern, $to, $this->string)) { if (null === $string = $replace($fromRegexp, $to, $this->string)) {
$lastError = preg_last_error(); $lastError = preg_last_error();
foreach (get_defined_constants(true)['pcre'] as $k => $v) { foreach (get_defined_constants(true)['pcre'] as $k => $v) {

View File

@ -250,9 +250,9 @@ class UnicodeString extends AbstractUnicodeString
return $str; return $str;
} }
public function replaceMatches(string $fromPattern, $to): AbstractString public function replaceMatches(string $fromRegexp, $to): AbstractString
{ {
$str = parent::replaceMatches($fromPattern, $to); $str = parent::replaceMatches($fromRegexp, $to);
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
return $str; return $str;