minor #39965 Changed private static array-properties to const (5.2) (simonberger)

This PR was merged into the 5.2 branch.

Discussion
----------

Changed private static array-properties to const (5.2)

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

This continues #39959 for 5.2
Just two array-properties and a string property in one class newly added.

/cc @nicolas-grekas

Commits
-------

a5fd0c48eb Changed private static array-properties to const static properties newly introduced in 5.2
This commit is contained in:
Nicolas Grekas 2021-01-25 16:00:15 +01:00
commit 17560729d1

View File

@ -23,7 +23,7 @@ final class FrenchInflector implements InflectorInterface
*
* @see https://la-conjugaison.nouvelobs.com/regles/grammaire/le-pluriel-des-noms-121.php
*/
private static $pluralizeRegexp = [
private const PLURALIZE_REGEXP = [
// First entry: regexp
// Second entry: replacement
@ -67,7 +67,7 @@ final class FrenchInflector implements InflectorInterface
/**
* A list of all rules for singularize.
*/
private static $singularizeRegexp = [
private const SINGULARIZE_REGEXP = [
// First entry: regexp
// Second entry: replacement
@ -108,7 +108,7 @@ final class FrenchInflector implements InflectorInterface
* A list of words which should not be inflected.
* This list is only used by singularize.
*/
private static $uninflected = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
/**
* {@inheritdoc}
@ -139,7 +139,7 @@ final class FrenchInflector implements InflectorInterface
return [$singular];
}
foreach (self::$pluralizeRegexp as $rule) {
foreach (self::PLURALIZE_REGEXP as $rule) {
[$regexp, $replace] = $rule;
if (1 === preg_match($regexp, $singular)) {
@ -152,6 +152,6 @@ final class FrenchInflector implements InflectorInterface
private function isInflectedWord(string $word): bool
{
return 1 === preg_match(self::$uninflected, $word);
return 1 === preg_match(self::UNINFLECTED, $word);
}
}