minor #39962 Changed private static array-properties to const (5.1) (simonberger)

This PR was merged into the 5.1 branch.

Discussion
----------

Changed private static array-properties to const (5.1)

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

This continues #39959 for 5.1
Just a few newly introduced readonly static array-properties.

/cc @nicolas-grekas

Commits
-------

f891fb2e5e Changed private static array-properties to const static properties newly introduced in 5.1
This commit is contained in:
Nicolas Grekas 2021-01-25 15:44:36 +01:00
commit ac61623ef8
3 changed files with 9 additions and 9 deletions

View File

@ -35,7 +35,7 @@ use Symfony\Component\Security\Http\SecurityEvents;
*/
class RegisterGlobalSecurityEventListenersPass implements CompilerPassInterface
{
private static $eventBubblingEvents = [
private const EVENT_BUBBLING_EVENTS = [
CheckPassportEvent::class,
LoginFailureEvent::class,
LoginSuccessEvent::class,
@ -73,7 +73,7 @@ class RegisterGlobalSecurityEventListenersPass implements CompilerPassInterface
}
$methodCallArguments = $methodCall[1];
if (!\in_array($methodCallArguments[0], self::$eventBubblingEvents, true)) {
if (!\in_array($methodCallArguments[0], self::EVENT_BUBBLING_EVENTS, true)) {
continue;
}

View File

@ -33,7 +33,7 @@ This conversation was marked as resolved by lstrojny
protected $maxIdLength = 250;
private static $defaultClientOptions = [
private const DEFAULT_CLIENT_OPTIONS = [
'persistent_id' => null,
'username' => null,
'password' => null,
@ -108,7 +108,7 @@ This conversation was marked as resolved by lstrojny
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
try {
$options += static::$defaultClientOptions;
$options += static::DEFAULT_CLIENT_OPTIONS;
$client = new \Memcached($options['persistent_id']);
$username = $options['username'];
$password = $options['password'];

View File

@ -138,7 +138,7 @@ final class EnglishInflector implements InflectorInterface
*
* @see http://english-zone.com/spelling/plurals.html
*/
private static $singularMap = [
private const SINGULAR_MAP = [
// First entry: singular suffix, reversed
// Second entry: length of singular suffix
// Third entry: Whether the suffix may succeed a vocal
@ -304,7 +304,7 @@ final class EnglishInflector implements InflectorInterface
/**
* A list of words which should not be inflected, reversed.
*/
private static $uninflected = [
private const UNINFLECTED = [
'',
'atad',
'reed',
@ -327,7 +327,7 @@ final class EnglishInflector implements InflectorInterface
$pluralLength = \strlen($lowerPluralRev);
// Check if the word is one which is not inflected, return early if so
if (\in_array($lowerPluralRev, self::$uninflected, true)) {
if (\in_array($lowerPluralRev, self::UNINFLECTED, true)) {
return [$plural];
}
@ -406,7 +406,7 @@ final class EnglishInflector implements InflectorInterface
$singularLength = \strlen($lowerSingularRev);
// Check if the word is one which is not inflected, return early if so
if (\in_array($lowerSingularRev, self::$uninflected, true)) {
if (\in_array($lowerSingularRev, self::UNINFLECTED, true)) {
return [$singular];
}
@ -414,7 +414,7 @@ final class EnglishInflector implements InflectorInterface
// The inner loop $j iterates over the characters of the singular suffix
// in the singular table to compare them with the characters of the actual
// given singular suffix
foreach (self::$singularMap as $map) {
foreach (self::SINGULAR_MAP as $map) {
$suffix = $map[0];
$suffixLength = $map[1];
$j = 0;