dep: package update
This commit is contained in:
Vendored
+2
-3
@@ -3,6 +3,5 @@
|
||||
Doctrine Inflector is a small library that can perform string manipulations
|
||||
with regard to uppercase/lowercase and singular/plural forms of words.
|
||||
|
||||
[](https://travis-ci.org/doctrine/inflector)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/inflector/?branch=master)
|
||||
[](https://scrutinizer-ci.com/g/doctrine/inflector/?branch=master)
|
||||
[](https://github.com/doctrine/inflector/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A4.0.x)
|
||||
[](https://codecov.io/gh/doctrine/inflector/branch/2.0.x)
|
||||
|
||||
+6
-10
@@ -16,11 +16,12 @@
|
||||
"php": "^7.2 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^7.0",
|
||||
"phpstan/phpstan": "^0.11",
|
||||
"phpstan/phpstan-phpunit": "^0.11",
|
||||
"phpstan/phpstan-strict-rules": "^0.11",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
|
||||
"doctrine/coding-standard": "^8.2",
|
||||
"phpstan/phpstan": "^0.12",
|
||||
"phpstan/phpstan-phpunit": "^0.12",
|
||||
"phpstan/phpstan-strict-rules": "^0.12",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||
"vimeo/psalm": "^4.10"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -31,10 +32,5 @@
|
||||
"psr-4": {
|
||||
"Doctrine\\Tests\\Inflector\\": "tests/Doctrine/Tests/Inflector"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class CachedWordInflector implements WordInflector
|
||||
$this->wordInflector = $wordInflector;
|
||||
}
|
||||
|
||||
public function inflect(string $word) : string
|
||||
public function inflect(string $word): string
|
||||
{
|
||||
return $this->cache[$word] ?? $this->cache[$word] = $this->wordInflector->inflect($word);
|
||||
}
|
||||
|
||||
+6
-5
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Doctrine\Inflector;
|
||||
|
||||
use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
use function array_unshift;
|
||||
|
||||
abstract class GenericLanguageInflectorFactory implements LanguageInflectorFactory
|
||||
@@ -21,7 +22,7 @@ abstract class GenericLanguageInflectorFactory implements LanguageInflectorFacto
|
||||
$this->pluralRulesets[] = $this->getPluralRuleset();
|
||||
}
|
||||
|
||||
final public function build() : Inflector
|
||||
final public function build(): Inflector
|
||||
{
|
||||
return new Inflector(
|
||||
new CachedWordInflector(new RulesetInflector(
|
||||
@@ -33,7 +34,7 @@ abstract class GenericLanguageInflectorFactory implements LanguageInflectorFacto
|
||||
);
|
||||
}
|
||||
|
||||
final public function withSingularRules(?Ruleset $singularRules, bool $reset = false) : LanguageInflectorFactory
|
||||
final public function withSingularRules(?Ruleset $singularRules, bool $reset = false): LanguageInflectorFactory
|
||||
{
|
||||
if ($reset) {
|
||||
$this->singularRulesets = [];
|
||||
@@ -46,7 +47,7 @@ abstract class GenericLanguageInflectorFactory implements LanguageInflectorFacto
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function withPluralRules(?Ruleset $pluralRules, bool $reset = false) : LanguageInflectorFactory
|
||||
final public function withPluralRules(?Ruleset $pluralRules, bool $reset = false): LanguageInflectorFactory
|
||||
{
|
||||
if ($reset) {
|
||||
$this->pluralRulesets = [];
|
||||
@@ -59,7 +60,7 @@ abstract class GenericLanguageInflectorFactory implements LanguageInflectorFacto
|
||||
return $this;
|
||||
}
|
||||
|
||||
abstract protected function getSingularRuleset() : Ruleset;
|
||||
abstract protected function getSingularRuleset(): Ruleset;
|
||||
|
||||
abstract protected function getPluralRuleset() : Ruleset;
|
||||
abstract protected function getPluralRuleset(): Ruleset;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Doctrine\Inflector;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
use function chr;
|
||||
use function function_exists;
|
||||
use function lcfirst;
|
||||
@@ -228,7 +229,7 @@ class Inflector
|
||||
/**
|
||||
* Converts a word into the format for a Doctrine table name. Converts 'ModelName' to 'model_name'.
|
||||
*/
|
||||
public function tableize(string $word) : string
|
||||
public function tableize(string $word): string
|
||||
{
|
||||
$tableized = preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $word);
|
||||
|
||||
@@ -245,7 +246,7 @@ class Inflector
|
||||
/**
|
||||
* Converts a word into the format for a Doctrine class name. Converts 'table_name' to 'TableName'.
|
||||
*/
|
||||
public function classify(string $word) : string
|
||||
public function classify(string $word): string
|
||||
{
|
||||
return str_replace([' ', '_', '-'], '', ucwords($word, ' _-'));
|
||||
}
|
||||
@@ -253,7 +254,7 @@ class Inflector
|
||||
/**
|
||||
* Camelizes a word. This uses the classify() method and turns the first character to lowercase.
|
||||
*/
|
||||
public function camelize(string $word) : string
|
||||
public function camelize(string $word): string
|
||||
{
|
||||
return lcfirst($this->classify($word));
|
||||
}
|
||||
@@ -283,7 +284,7 @@ class Inflector
|
||||
*
|
||||
* @return string The string with all delimiter-separated words capitalized.
|
||||
*/
|
||||
public function capitalize(string $string, string $delimiters = " \n\t\r\0\x0B-") : string
|
||||
public function capitalize(string $string, string $delimiters = " \n\t\r\0\x0B-"): string
|
||||
{
|
||||
return ucwords($string, $delimiters);
|
||||
}
|
||||
@@ -293,7 +294,7 @@ class Inflector
|
||||
*
|
||||
* @param string $string The string to check for utf8 characters in.
|
||||
*/
|
||||
public function seemsUtf8(string $string) : bool
|
||||
public function seemsUtf8(string $string): bool
|
||||
{
|
||||
for ($i = 0; $i < strlen($string); $i++) {
|
||||
if (ord($string[$i]) < 0x80) {
|
||||
@@ -331,7 +332,7 @@ class Inflector
|
||||
*
|
||||
* @return string Unaccented string
|
||||
*/
|
||||
public function unaccent(string $string) : string
|
||||
public function unaccent(string $string): string
|
||||
{
|
||||
if (preg_match('/[\x80-\xff]/', $string) === false) {
|
||||
return $string;
|
||||
@@ -444,7 +445,7 @@ class Inflector
|
||||
*
|
||||
* @return string Urlized string.
|
||||
*/
|
||||
public function urlize(string $string) : string
|
||||
public function urlize(string $string): string
|
||||
{
|
||||
// Remove all non url friendly characters with the unaccent function
|
||||
$unaccented = $this->unaccent($string);
|
||||
@@ -487,7 +488,7 @@ class Inflector
|
||||
*
|
||||
* @return string The word in singular form.
|
||||
*/
|
||||
public function singularize(string $word) : string
|
||||
public function singularize(string $word): string
|
||||
{
|
||||
return $this->singularizer->inflect($word);
|
||||
}
|
||||
@@ -499,7 +500,7 @@ class Inflector
|
||||
*
|
||||
* @return string The word in plural form.
|
||||
*/
|
||||
public function pluralize(string $word) : string
|
||||
public function pluralize(string $word): string
|
||||
{
|
||||
return $this->pluralizer->inflect($word);
|
||||
}
|
||||
|
||||
@@ -11,30 +11,37 @@ use Doctrine\Inflector\Rules\Portuguese;
|
||||
use Doctrine\Inflector\Rules\Spanish;
|
||||
use Doctrine\Inflector\Rules\Turkish;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
final class InflectorFactory
|
||||
{
|
||||
public static function create() : LanguageInflectorFactory
|
||||
public static function create(): LanguageInflectorFactory
|
||||
{
|
||||
return self::createForLanguage(Language::ENGLISH);
|
||||
}
|
||||
|
||||
public static function createForLanguage(string $language) : LanguageInflectorFactory
|
||||
public static function createForLanguage(string $language): LanguageInflectorFactory
|
||||
{
|
||||
switch ($language) {
|
||||
case Language::ENGLISH:
|
||||
return new English\InflectorFactory();
|
||||
|
||||
case Language::FRENCH:
|
||||
return new French\InflectorFactory();
|
||||
|
||||
case Language::NORWEGIAN_BOKMAL:
|
||||
return new NorwegianBokmal\InflectorFactory();
|
||||
|
||||
case Language::PORTUGUESE:
|
||||
return new Portuguese\InflectorFactory();
|
||||
|
||||
case Language::SPANISH:
|
||||
return new Spanish\InflectorFactory();
|
||||
|
||||
case Language::TURKISH:
|
||||
return new Turkish\InflectorFactory();
|
||||
|
||||
default:
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Language "%s" is not supported.',
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ interface LanguageInflectorFactory
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withSingularRules(?Ruleset $singularRules, bool $reset = false) : self;
|
||||
public function withSingularRules(?Ruleset $singularRules, bool $reset = false): self;
|
||||
|
||||
/**
|
||||
* Applies custom rules for pluralisation
|
||||
@@ -24,10 +24,10 @@ interface LanguageInflectorFactory
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withPluralRules(?Ruleset $pluralRules, bool $reset = false) : self;
|
||||
public function withPluralRules(?Ruleset $pluralRules, bool $reset = false): self;
|
||||
|
||||
/**
|
||||
* Builds the inflector instance with all applicable rules
|
||||
*/
|
||||
public function build() : Inflector;
|
||||
public function build(): Inflector;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Doctrine\Inflector;
|
||||
|
||||
class NoopWordInflector implements WordInflector
|
||||
{
|
||||
public function inflect(string $word) : string
|
||||
public function inflect(string $word): string
|
||||
{
|
||||
return $word;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('(s)tatuses$'), '\1\2tatus');
|
||||
yield new Transformation(new Pattern('(s)tatus$'), '\1\2tatus');
|
||||
@@ -62,7 +62,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('(s)tatus$'), '\1\2tatuses');
|
||||
yield new Transformation(new Pattern('(quiz)$'), '\1zes');
|
||||
@@ -94,7 +94,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Substitution[]
|
||||
*/
|
||||
public static function getIrregular() : iterable
|
||||
public static function getIrregular(): iterable
|
||||
{
|
||||
yield new Substitution(new Word('atlas'), new Word('atlases'));
|
||||
yield new Substitution(new Word('axe'), new Word('axes'));
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@ use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
final class InflectorFactory extends GenericLanguageInflectorFactory
|
||||
{
|
||||
protected function getSingularRuleset() : Ruleset
|
||||
protected function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getSingularRuleset();
|
||||
}
|
||||
|
||||
protected function getPluralRuleset() : Ruleset
|
||||
protected function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getPluralRuleset();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use Doctrine\Inflector\Rules\Transformations;
|
||||
|
||||
final class Rules
|
||||
{
|
||||
public static function getSingularRuleset() : Ruleset
|
||||
public static function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getSingular()),
|
||||
@@ -20,7 +20,7 @@ final class Rules
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPluralRuleset() : Ruleset
|
||||
public static function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getPlural()),
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
|
||||
@@ -33,7 +33,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
|
||||
@@ -46,7 +46,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
private static function getDefault() : iterable
|
||||
private static function getDefault(): iterable
|
||||
{
|
||||
yield new Pattern('\w+media');
|
||||
yield new Pattern('advice');
|
||||
|
||||
+6
-5
@@ -14,7 +14,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/'), '\1ail');
|
||||
yield new Transformation(new Pattern('/ails$/'), 'ail');
|
||||
@@ -26,21 +26,22 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/(s|x|z)$/'), '\1');
|
||||
yield new Transformation(new Pattern('/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/'), '\1aux');
|
||||
yield new Transformation(new Pattern('/ail$/'), 'ails');
|
||||
yield new Transformation(new Pattern('/(chacal|carnaval|festival|récital)$/'), '\1s');
|
||||
yield new Transformation(new Pattern('/al$/'), 'aux');
|
||||
yield new Transformation(new Pattern('/(bleu|émeu|landau|lieu|pneu|sarrau)$/'), '\1s');
|
||||
yield new Transformation(new Pattern('/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)$/'), '\1x');
|
||||
yield new Transformation(new Pattern('/(bleu|émeu|landau|pneu|sarrau)$/'), '\1s');
|
||||
yield new Transformation(new Pattern('/(bijou|caillou|chou|genou|hibou|joujou|lieu|pou|au|eu|eau)$/'), '\1x');
|
||||
yield new Transformation(new Pattern('/$/'), 's');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Substitution[]
|
||||
*/
|
||||
public static function getIrregular() : iterable
|
||||
public static function getIrregular(): iterable
|
||||
{
|
||||
yield new Substitution(new Word('monsieur'), new Word('messieurs'));
|
||||
yield new Substitution(new Word('madame'), new Word('mesdames'));
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@ use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
final class InflectorFactory extends GenericLanguageInflectorFactory
|
||||
{
|
||||
protected function getSingularRuleset() : Ruleset
|
||||
protected function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getSingularRuleset();
|
||||
}
|
||||
|
||||
protected function getPluralRuleset() : Ruleset
|
||||
protected function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getPluralRuleset();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use Doctrine\Inflector\Rules\Transformations;
|
||||
|
||||
final class Rules
|
||||
{
|
||||
public static function getSingularRuleset() : Ruleset
|
||||
public static function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getSingular()),
|
||||
@@ -20,7 +20,7 @@ final class Rules
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPluralRuleset() : Ruleset
|
||||
public static function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getPlural()),
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
private static function getDefault() : iterable
|
||||
private static function getDefault(): iterable
|
||||
{
|
||||
yield new Pattern('');
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/re$/i'), 'r');
|
||||
yield new Transformation(new Pattern('/er$/i'), '');
|
||||
@@ -23,7 +23,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/e$/i'), 'er');
|
||||
yield new Transformation(new Pattern('/r$/i'), 're');
|
||||
@@ -33,7 +33,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Substitution[]
|
||||
*/
|
||||
public static function getIrregular() : iterable
|
||||
public static function getIrregular(): iterable
|
||||
{
|
||||
yield new Substitution(new Word('konto'), new Word('konti'));
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -9,12 +9,12 @@ use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
final class InflectorFactory extends GenericLanguageInflectorFactory
|
||||
{
|
||||
protected function getSingularRuleset() : Ruleset
|
||||
protected function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getSingularRuleset();
|
||||
}
|
||||
|
||||
protected function getPluralRuleset() : Ruleset
|
||||
protected function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getPluralRuleset();
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ use Doctrine\Inflector\Rules\Transformations;
|
||||
|
||||
final class Rules
|
||||
{
|
||||
public static function getSingularRuleset() : Ruleset
|
||||
public static function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getSingular()),
|
||||
@@ -20,7 +20,7 @@ final class Rules
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPluralRuleset() : Ruleset
|
||||
public static function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getPlural()),
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
private static function getDefault() : iterable
|
||||
private static function getDefault(): iterable
|
||||
{
|
||||
yield new Pattern('barn');
|
||||
yield new Pattern('fjell');
|
||||
|
||||
@@ -25,17 +25,17 @@ final class Pattern
|
||||
}
|
||||
}
|
||||
|
||||
public function getPattern() : string
|
||||
public function getPattern(): string
|
||||
{
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
public function getRegex() : string
|
||||
public function getRegex(): string
|
||||
{
|
||||
return $this->regex;
|
||||
}
|
||||
|
||||
public function matches(string $word) : bool
|
||||
public function matches(string $word): bool
|
||||
{
|
||||
return preg_match($this->getRegex(), $word) === 1;
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ class Patterns
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
|
||||
$patterns = array_map(static function (Pattern $pattern) : string {
|
||||
$patterns = array_map(static function (Pattern $pattern): string {
|
||||
return $pattern->getPattern();
|
||||
}, $this->patterns);
|
||||
|
||||
$this->regex = '/^(?:' . implode('|', $patterns) . ')$/i';
|
||||
}
|
||||
|
||||
public function matches(string $word) : bool
|
||||
public function matches(string $word): bool
|
||||
{
|
||||
return preg_match($this->regex, $word, $regs) === 1;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/^(g|)ases$/i'), '\1ás');
|
||||
yield new Transformation(new Pattern('/(japon|escoc|ingl|dinamarqu|fregu|portugu)eses$/i'), '\1ês');
|
||||
@@ -37,7 +37,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/^(alem|c|p)ao$/i'), '\1aes');
|
||||
yield new Transformation(new Pattern('/^(irm|m)ao$/i'), '\1aos');
|
||||
@@ -61,7 +61,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Substitution[]
|
||||
*/
|
||||
public static function getIrregular() : iterable
|
||||
public static function getIrregular(): iterable
|
||||
{
|
||||
yield new Substitution(new Word('abdomen'), new Word('abdomens'));
|
||||
yield new Substitution(new Word('alemão'), new Word('alemães'));
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@ use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
final class InflectorFactory extends GenericLanguageInflectorFactory
|
||||
{
|
||||
protected function getSingularRuleset() : Ruleset
|
||||
protected function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getSingularRuleset();
|
||||
}
|
||||
|
||||
protected function getPluralRuleset() : Ruleset
|
||||
protected function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getPluralRuleset();
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ use Doctrine\Inflector\Rules\Transformations;
|
||||
|
||||
final class Rules
|
||||
{
|
||||
public static function getSingularRuleset() : Ruleset
|
||||
public static function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getSingular()),
|
||||
@@ -20,7 +20,7 @@ final class Rules
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPluralRuleset() : Ruleset
|
||||
public static function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getPlural()),
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
private static function getDefault() : iterable
|
||||
private static function getDefault(): iterable
|
||||
{
|
||||
yield new Pattern('tórax');
|
||||
yield new Pattern('tênis');
|
||||
|
||||
@@ -22,17 +22,17 @@ class Ruleset
|
||||
$this->irregular = $irregular;
|
||||
}
|
||||
|
||||
public function getRegular() : Transformations
|
||||
public function getRegular(): Transformations
|
||||
{
|
||||
return $this->regular;
|
||||
}
|
||||
|
||||
public function getUninflected() : Patterns
|
||||
public function getUninflected(): Patterns
|
||||
{
|
||||
return $this->uninflected;
|
||||
}
|
||||
|
||||
public function getIrregular() : Substitutions
|
||||
public function getIrregular(): Substitutions
|
||||
{
|
||||
return $this->irregular;
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/ereses$/'), 'erés');
|
||||
yield new Transformation(new Pattern('/iones$/'), 'ión');
|
||||
@@ -26,7 +26,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/ú([sn])$/i'), 'u\1es');
|
||||
yield new Transformation(new Pattern('/ó([sn])$/i'), 'o\1es');
|
||||
@@ -42,7 +42,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Substitution[]
|
||||
*/
|
||||
public static function getIrregular() : iterable
|
||||
public static function getIrregular(): iterable
|
||||
{
|
||||
yield new Substitution(new Word('el'), new Word('los'));
|
||||
yield new Substitution(new Word('papá'), new Word('papás'));
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@ use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
final class InflectorFactory extends GenericLanguageInflectorFactory
|
||||
{
|
||||
protected function getSingularRuleset() : Ruleset
|
||||
protected function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getSingularRuleset();
|
||||
}
|
||||
|
||||
protected function getPluralRuleset() : Ruleset
|
||||
protected function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getPluralRuleset();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use Doctrine\Inflector\Rules\Transformations;
|
||||
|
||||
final class Rules
|
||||
{
|
||||
public static function getSingularRuleset() : Ruleset
|
||||
public static function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getSingular()),
|
||||
@@ -20,7 +20,7 @@ final class Rules
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPluralRuleset() : Ruleset
|
||||
public static function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getPlural()),
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
private static function getDefault() : iterable
|
||||
private static function getDefault(): iterable
|
||||
{
|
||||
yield new Pattern('lunes');
|
||||
yield new Pattern('rompecabezas');
|
||||
|
||||
@@ -18,12 +18,12 @@ final class Substitution
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
public function getFrom() : Word
|
||||
public function getFrom(): Word
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
public function getTo() : Word
|
||||
public function getTo(): Word
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Doctrine\Inflector\Rules;
|
||||
|
||||
use Doctrine\Inflector\WordInflector;
|
||||
|
||||
use function strtolower;
|
||||
use function strtoupper;
|
||||
use function substr;
|
||||
@@ -21,7 +22,7 @@ class Substitutions implements WordInflector
|
||||
}
|
||||
}
|
||||
|
||||
public function getFlippedSubstitutions() : Substitutions
|
||||
public function getFlippedSubstitutions(): Substitutions
|
||||
{
|
||||
$substitutions = [];
|
||||
|
||||
@@ -35,7 +36,7 @@ class Substitutions implements WordInflector
|
||||
return new Substitutions(...$substitutions);
|
||||
}
|
||||
|
||||
public function inflect(string $word) : string
|
||||
public function inflect(string $word): string
|
||||
{
|
||||
$lowerWord = strtolower($word);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Doctrine\Inflector\Rules;
|
||||
|
||||
use Doctrine\Inflector\WordInflector;
|
||||
|
||||
use function preg_replace;
|
||||
|
||||
final class Transformation implements WordInflector
|
||||
@@ -21,17 +22,17 @@ final class Transformation implements WordInflector
|
||||
$this->replacement = $replacement;
|
||||
}
|
||||
|
||||
public function getPattern() : Pattern
|
||||
public function getPattern(): Pattern
|
||||
{
|
||||
return $this->pattern;
|
||||
}
|
||||
|
||||
public function getReplacement() : string
|
||||
public function getReplacement(): string
|
||||
{
|
||||
return $this->replacement;
|
||||
}
|
||||
|
||||
public function inflect(string $word) : string
|
||||
public function inflect(string $word): string
|
||||
{
|
||||
return (string) preg_replace($this->pattern->getRegex(), $this->replacement, $word);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class Transformations implements WordInflector
|
||||
$this->transformations = $transformations;
|
||||
}
|
||||
|
||||
public function inflect(string $word) : string
|
||||
public function inflect(string $word): string
|
||||
{
|
||||
foreach ($this->transformations as $transformation) {
|
||||
if ($transformation->getPattern()->matches($word)) {
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/l[ae]r$/i'), '');
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Transformation[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield new Transformation(new Pattern('/([eöiü][^aoıueöiü]{0,6})$/u'), '\1ler');
|
||||
yield new Transformation(new Pattern('/([aoıu][^aoıueöiü]{0,6})$/u'), '\1lar');
|
||||
@@ -31,7 +31,7 @@ class Inflectible
|
||||
/**
|
||||
* @return Substitution[]
|
||||
*/
|
||||
public static function getIrregular() : iterable
|
||||
public static function getIrregular(): iterable
|
||||
{
|
||||
yield new Substitution(new Word('ben'), new Word('biz'));
|
||||
yield new Substitution(new Word('sen'), new Word('siz'));
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@ use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
final class InflectorFactory extends GenericLanguageInflectorFactory
|
||||
{
|
||||
protected function getSingularRuleset() : Ruleset
|
||||
protected function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getSingularRuleset();
|
||||
}
|
||||
|
||||
protected function getPluralRuleset() : Ruleset
|
||||
protected function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return Rules::getPluralRuleset();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use Doctrine\Inflector\Rules\Transformations;
|
||||
|
||||
final class Rules
|
||||
{
|
||||
public static function getSingularRuleset() : Ruleset
|
||||
public static function getSingularRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getSingular()),
|
||||
@@ -20,7 +20,7 @@ final class Rules
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPluralRuleset() : Ruleset
|
||||
public static function getPluralRuleset(): Ruleset
|
||||
{
|
||||
return new Ruleset(
|
||||
new Transformations(...Inflectible::getPlural()),
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getSingular() : iterable
|
||||
public static function getSingular(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -19,7 +19,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
public static function getPlural() : iterable
|
||||
public static function getPlural(): iterable
|
||||
{
|
||||
yield from self::getDefault();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ final class Uninflected
|
||||
/**
|
||||
* @return Pattern[]
|
||||
*/
|
||||
private static function getDefault() : iterable
|
||||
private static function getDefault(): iterable
|
||||
{
|
||||
yield new Pattern('lunes');
|
||||
yield new Pattern('rompecabezas');
|
||||
|
||||
@@ -14,7 +14,7 @@ class Word
|
||||
$this->word = $word;
|
||||
}
|
||||
|
||||
public function getWord() : string
|
||||
public function getWord(): string
|
||||
{
|
||||
return $this->word;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Doctrine\Inflector;
|
||||
|
||||
use Doctrine\Inflector\Rules\Ruleset;
|
||||
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ class RulesetInflector implements WordInflector
|
||||
$this->rulesets = array_merge([$ruleset], $rulesets);
|
||||
}
|
||||
|
||||
public function inflect(string $word) : string
|
||||
public function inflect(string $word): string
|
||||
{
|
||||
if ($word === '') {
|
||||
return '';
|
||||
|
||||
@@ -6,5 +6,5 @@ namespace Doctrine\Inflector;
|
||||
|
||||
interface WordInflector
|
||||
{
|
||||
public function inflect(string $word) : string;
|
||||
public function inflect(string $word): string;
|
||||
}
|
||||
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="7"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib/Doctrine/Inflector" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
||||
Reference in New Issue
Block a user