8000 Changed private static array-properties to const (5.1) by simonberger · Pull Request #39962 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
class RegisterGlobalSecurityEventListenersPass implements CompilerPassInterface
{
private static $eventBubblingEvents = [
private const EVENT_BUBBLING_EVENTS = [
CheckPassportEvent::class,
LoginFailureEvent::class,
LoginSuccessEvent::class,
Expand Down Expand Up @@ -73,7 +73,7 @@ public function process(ContainerBuilder $container)
}

$methodCallArguments = $methodCall[1];
if (!\in_array($methodCallArguments[0], self::$eventBubblingEvents, true)) {
if (!\in_array($methodCallArguments[0], self::EVENT_BUBBLING_EVENTS, true)) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MemcachedAdapter extends AbstractAdapter

protected $maxIdLength = 250;

private static $defaultClientOptions = [
private const DEFAULT_CLIENT_OPTIONS = [
'persistent_id' => null,
'username' => null,
'password' => null,
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function createConnection($servers, array $options = [])
}
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'];
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/String/Inflector/EnglishInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand All @@ -327,7 +327,7 @@ public function singularize(string $plural): array
$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];
}

Expand Down Expand Up @@ -406,15 +406,15 @@ public function pluralize(string $singular): array
$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];
}

// The outer loop iterates over the entries of the singular table
// 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;
Expand Down
0