[Form] Remove unneeded FormUtil constants
They are part of the public API (as const are always public) but cannot be used at all from outside the class as the$pluralMap is private. The meaning of the indices is already documented in the array.
This commit is contained in:
parent
7fe18d13a0
commit
4efb9fec50
@ -16,16 +16,6 @@ namespace Symfony\Component\Form\Util;
|
|||||||
*/
|
*/
|
||||||
abstract class FormUtil
|
abstract class FormUtil
|
||||||
{
|
{
|
||||||
const PLURAL_SUFFIX = 0;
|
|
||||||
|
|
||||||
const PLURAL_SUFFIX_LENGTH = 1;
|
|
||||||
|
|
||||||
const PLURAL_SUFFIX_AFTER_VOCAL = 2;
|
|
||||||
|
|
||||||
const PLURAL_SUFFIX_AFTER_CONS = 3;
|
|
||||||
|
|
||||||
const SINGULAR_SUFFIX = 4;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map english plural to singular suffixes
|
* Map english plural to singular suffixes
|
||||||
*
|
*
|
||||||
@ -128,8 +118,8 @@ abstract class FormUtil
|
|||||||
// in the plural table to compare them with the characters of the actual
|
// in the plural table to compare them with the characters of the actual
|
||||||
// given plural suffix
|
// given plural suffix
|
||||||
for ($i = 0, $numPlurals = count(self::$pluralMap); $i < $numPlurals; ++$i) {
|
for ($i = 0, $numPlurals = count(self::$pluralMap); $i < $numPlurals; ++$i) {
|
||||||
$suffix = self::$pluralMap[$i][self::PLURAL_SUFFIX];
|
$suffix = self::$pluralMap[$i][0];
|
||||||
$suffixLength = self::$pluralMap[$i][self::PLURAL_SUFFIX_LENGTH];
|
$suffixLength = self::$pluralMap[$i][1];
|
||||||
$j = 0;
|
$j = 0;
|
||||||
|
|
||||||
// Compare characters in the plural table and of the suffix of the
|
// Compare characters in the plural table and of the suffix of the
|
||||||
@ -145,17 +135,19 @@ abstract class FormUtil
|
|||||||
if ($j < $pluralLength) {
|
if ($j < $pluralLength) {
|
||||||
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
|
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
|
||||||
|
|
||||||
if (!self::$pluralMap[$i][self::PLURAL_SUFFIX_AFTER_VOCAL] && $nextIsVocal) {
|
if (!self::$pluralMap[$i][2] && $nextIsVocal) {
|
||||||
|
// suffix may not succeed a vocal but next char is one
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::$pluralMap[$i][self::PLURAL_SUFFIX_AFTER_CONS] && !$nextIsVocal) {
|
if (!self::$pluralMap[$i][3] && !$nextIsVocal) {
|
||||||
|
// suffix may not succeed a consonant but next char is one
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
|
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
|
||||||
$newSuffix = self::$pluralMap[$i][self::SINGULAR_SUFFIX];
|
$newSuffix = self::$pluralMap[$i][4];
|
||||||
|
|
||||||
// Check whether the first character in the plural suffix
|
// Check whether the first character in the plural suffix
|
||||||
// is uppercased. If yes, uppercase the first character in
|
// is uppercased. If yes, uppercase the first character in
|
||||||
|
Reference in New Issue
Block a user