From 8651a9cc056f2e20e6a4f646d98c7d700b91f7d3 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 11 Apr 2021 09:52:07 +0200 Subject: [PATCH 1/4] Move CI to Github actions --- .github/workflows/continuous-integration.yml | 121 +++++++++++++++++-- .github/workflows/static-analysis.yml | 38 ++++++ .travis.yml | 58 --------- 3 files changed, 150 insertions(+), 67 deletions(-) create mode 100644 .github/workflows/static-analysis.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 03ea186a..3de6b4f1 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -5,12 +5,115 @@ on: pull_request: jobs: - roave_bc_check: - name: "Roave BC Check" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: fetch tags - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - name: Roave BC Check - uses: docker://nyholm/roave-bc-check-ga + roave_bc_check: + name: "Roave BC Check" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: fetch tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + - name: Roave BC Check + uses: docker://nyholm/roave-bc-check-ga + + phpunit: + name: "PHPUnit" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + - "8.0" + dependencies: + - "highest" + include: + - dependencies: "lowest" + php-version: "7.2" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "pcov" + ini-values: "zend.assertions=1" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "--prefer-dist" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit --coverage-clover=coverage.xml" + + - name: "Upload coverage file" + uses: "actions/upload-artifact@v2" + with: + name: "phpunit-${{ matrix.dependencies }}-${{ matrix.php-version }}.coverage" + path: "coverage.xml" + + phpunit-lower-php-versions: + name: "PHPUnit" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "7.1" + dependencies: + - "highest" + include: + - dependencies: "lowest" + php-version: "7.1" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + ini-values: "zend.assertions=1" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "--prefer-dist" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit" + + upload_coverage: + name: "Upload coverage to Codecov" + runs-on: "ubuntu-20.04" + needs: + - "phpunit" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Download coverage files" + uses: "actions/download-artifact@v2" + with: + path: "reports" + + - name: "Upload to Codecov" + uses: "codecov/codecov-action@v1" + with: + directory: reports + diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 00000000..dbb6282f --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,38 @@ +name: "Static Analysis" + +on: + pull_request: + branches: + - "*.x" + push: + branches: + - "*.x" + +jobs: + static-analysis-phpstan: + name: "Static Analysis with PHPStan" + runs-on: "ubuntu-20.04" + + strategy: + matrix: + php-version: + - "7.4" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ matrix.php-version }}" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v1" + with: + dependency-versions: "highest" + + - name: "Run a static analysis with phpstan/phpstan" + run: "vendor/bin/phpstan analyse" + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 52d2141e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ -dist: xenial - -language: php - -php: - - 7.2 - - 7.3 - - 7.4 - -cache: - directories: - - $HOME/.composer/cache - -before_install: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" - -install: - - travis_retry composer update --prefer-dist - -script: - - ./vendor/bin/phpunit - -jobs: - allow_failures: - - php: nightly - - include: - - stage: Test - env: DEPENDENCIES=low - install: - - travis_retry composer update --prefer-dist --prefer-lowest - - - stage: Test - env: COVERAGE - before_script: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} - - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi - script: - - ./vendor/bin/phpunit --coverage-clover clover.xml - after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover clover.xml - - - stage: Test - php: nightly - before_install: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" - - composer config platform.php 7.4.99 - - - stage: Code Quality - env: CODING_STANDARDS - install: travis_retry composer install --prefer-dist - script: ./vendor/bin/phpcs - - - stage: Code Quality - env: STATIC_ANALYSIS - install: travis_retry composer install --prefer-dist - script: vendor/bin/phpstan analyse From 2038d69b2b2b23734b3f90f60da947d6b46d8f24 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 11 Apr 2021 09:52:27 +0200 Subject: [PATCH 2/4] Allow PHP 7.1 and update tools to allow it. --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index ab51ba0f..6f258ea9 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,13 @@ {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} ], "require": { - "php": "^7.2 || ^8.0" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^7.0", - "phpstan/phpstan": "^0.11", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-strict-rules": "^0.11", + "doctrine/coding-standard": "^8.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "autoload": { From 886885ef94ff64905adbba4ab4e04bf6810110c9 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 11 Apr 2021 09:53:09 +0200 Subject: [PATCH 3/4] Apply doctrine/coding-standard to version 8.0 --- .../Inflector/CachedWordInflector.php | 2 +- .../GenericLanguageInflectorFactory.php | 11 +++++----- lib/Doctrine/Inflector/Inflector.php | 19 ++++++++-------- lib/Doctrine/Inflector/InflectorFactory.php | 11 ++++++++-- .../Inflector/LanguageInflectorFactory.php | 6 ++--- lib/Doctrine/Inflector/NoopWordInflector.php | 2 +- .../Inflector/Rules/English/Inflectible.php | 6 ++--- .../Rules/English/InflectorFactory.php | 4 ++-- .../Inflector/Rules/English/Rules.php | 4 ++-- .../Inflector/Rules/English/Uninflected.php | 6 ++--- .../Inflector/Rules/French/Inflectible.php | 6 ++--- .../Rules/French/InflectorFactory.php | 4 ++-- lib/Doctrine/Inflector/Rules/French/Rules.php | 4 ++-- .../Inflector/Rules/French/Uninflected.php | 6 ++--- .../Rules/NorwegianBokmal/Inflectible.php | 6 ++--- .../NorwegianBokmal/InflectorFactory.php | 4 ++-- .../Inflector/Rules/NorwegianBokmal/Rules.php | 4 ++-- .../Rules/NorwegianBokmal/Uninflected.php | 6 ++--- lib/Doctrine/Inflector/Rules/Pattern.php | 6 ++--- lib/Doctrine/Inflector/Rules/Patterns.php | 4 ++-- .../Rules/Portuguese/Inflectible.php | 6 ++--- .../Rules/Portuguese/InflectorFactory.php | 4 ++-- .../Inflector/Rules/Portuguese/Rules.php | 4 ++-- .../Rules/Portuguese/Uninflected.php | 6 ++--- lib/Doctrine/Inflector/Rules/Ruleset.php | 6 ++--- .../Inflector/Rules/Spanish/Inflectible.php | 6 ++--- .../Rules/Spanish/InflectorFactory.php | 4 ++-- .../Inflector/Rules/Spanish/Rules.php | 4 ++-- .../Inflector/Rules/Spanish/Uninflected.php | 6 ++--- lib/Doctrine/Inflector/Rules/Substitution.php | 4 ++-- .../Inflector/Rules/Substitutions.php | 5 +++-- .../Inflector/Rules/Transformation.php | 7 +++--- .../Inflector/Rules/Transformations.php | 2 +- .../Inflector/Rules/Turkish/Inflectible.php | 6 ++--- .../Rules/Turkish/InflectorFactory.php | 4 ++-- .../Inflector/Rules/Turkish/Rules.php | 4 ++-- .../Inflector/Rules/Turkish/Uninflected.php | 6 ++--- lib/Doctrine/Inflector/Rules/Word.php | 2 +- lib/Doctrine/Inflector/RulesetInflector.php | 3 ++- lib/Doctrine/Inflector/WordInflector.php | 2 +- .../Inflector/CachedWordInflectorTest.php | 4 ++-- .../Tests/Inflector/InflectorFactoryTest.php | 8 +++---- .../Inflector/InflectorFunctionalTest.php | 18 +++++++-------- .../Tests/Inflector/InflectorTest.php | 22 +++++++++---------- .../Tests/Inflector/NoopWordInflectorTest.php | 4 ++-- .../Rules/English/EnglishFunctionalTest.php | 13 ++++++----- .../Rules/French/FrenchFunctionalTest.php | 4 ++-- .../Rules/LanguageFunctionalTest.php | 9 ++++---- .../NorwegianBokmalFunctionalTest.php | 4 ++-- .../Tests/Inflector/Rules/PatternTest.php | 10 ++++----- .../Tests/Inflector/Rules/PatternsTest.php | 4 ++-- .../Portuguese/PortugueseFunctionalTest.php | 4 ++-- .../Tests/Inflector/Rules/RulesetTest.php | 8 +++---- .../Rules/Spanish/SpanishFunctionalTest.php | 4 ++-- .../Inflector/Rules/SubstitutionTest.php | 6 ++--- .../Inflector/Rules/SubstitutionsTest.php | 6 ++--- .../Inflector/Rules/TransformationTest.php | 8 +++---- .../Inflector/Rules/TransformationsTest.php | 4 ++-- .../Rules/Turkish/TurkishFunctionalTest.php | 4 ++-- .../Tests/Inflector/Rules/WordTest.php | 4 ++-- .../Tests/Inflector/RulesetInflectorTest.php | 16 +++++++------- 61 files changed, 195 insertions(+), 181 deletions(-) diff --git a/lib/Doctrine/Inflector/CachedWordInflector.php b/lib/Doctrine/Inflector/CachedWordInflector.php index b59ac46c..2d529087 100644 --- a/lib/Doctrine/Inflector/CachedWordInflector.php +++ b/lib/Doctrine/Inflector/CachedWordInflector.php @@ -17,7 +17,7 @@ public function __construct(WordInflector $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); } diff --git a/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php b/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php index 1b15061a..166061d2 100644 --- a/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php +++ b/lib/Doctrine/Inflector/GenericLanguageInflectorFactory.php @@ -5,6 +5,7 @@ namespace Doctrine\Inflector; use Doctrine\Inflector\Rules\Ruleset; + use function array_unshift; abstract class GenericLanguageInflectorFactory implements LanguageInflectorFactory @@ -21,7 +22,7 @@ final public function __construct() $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 @@ final public function build() : Inflector ); } - 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 @@ final public function withSingularRules(?Ruleset $singularRules, bool $reset = f 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 @@ final public function withPluralRules(?Ruleset $pluralRules, bool $reset = false return $this; } - abstract protected function getSingularRuleset() : Ruleset; + abstract protected function getSingularRuleset(): Ruleset; - abstract protected function getPluralRuleset() : Ruleset; + abstract protected function getPluralRuleset(): Ruleset; } diff --git a/lib/Doctrine/Inflector/Inflector.php b/lib/Doctrine/Inflector/Inflector.php index 24119185..610a4cf4 100644 --- a/lib/Doctrine/Inflector/Inflector.php +++ b/lib/Doctrine/Inflector/Inflector.php @@ -5,6 +5,7 @@ namespace Doctrine\Inflector; use RuntimeException; + use function chr; use function function_exists; use function lcfirst; @@ -228,7 +229,7 @@ public function __construct(WordInflector $singularizer, WordInflector $pluraliz /** * 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 @@ public function tableize(string $word) : string /** * 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 @@ public function classify(string $word) : string /** * 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 @@ public function camelize(string $word) : string * * @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 @@ public function capitalize(string $string, string $delimiters = " \n\t\r\0\x0B-" * * @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 @@ public function seemsUtf8(string $string) : bool * * @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 @@ public function unaccent(string $string) : string * * @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 @@ public function urlize(string $string) : string * * @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 @@ public function singularize(string $word) : string * * @return string The word in plural form. */ - public function pluralize(string $word) : string + public function pluralize(string $word): string { return $this->pluralizer->inflect($word); } diff --git a/lib/Doctrine/Inflector/InflectorFactory.php b/lib/Doctrine/Inflector/InflectorFactory.php index 44bba5d7..a0740a74 100644 --- a/lib/Doctrine/Inflector/InflectorFactory.php +++ b/lib/Doctrine/Inflector/InflectorFactory.php @@ -11,30 +11,37 @@ 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.', diff --git a/lib/Doctrine/Inflector/LanguageInflectorFactory.php b/lib/Doctrine/Inflector/LanguageInflectorFactory.php index a80dd6c4..a58f43c0 100644 --- a/lib/Doctrine/Inflector/LanguageInflectorFactory.php +++ b/lib/Doctrine/Inflector/LanguageInflectorFactory.php @@ -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 @@ public function withSingularRules(?Ruleset $singularRules, bool $reset = false) * * @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; } diff --git a/lib/Doctrine/Inflector/NoopWordInflector.php b/lib/Doctrine/Inflector/NoopWordInflector.php index 63806ecc..2fdf5353 100644 --- a/lib/Doctrine/Inflector/NoopWordInflector.php +++ b/lib/Doctrine/Inflector/NoopWordInflector.php @@ -6,7 +6,7 @@ class NoopWordInflector implements WordInflector { - public function inflect(string $word) : string + public function inflect(string $word): string { return $word; } diff --git a/lib/Doctrine/Inflector/Rules/English/Inflectible.php b/lib/Doctrine/Inflector/Rules/English/Inflectible.php index 0de97a27..8f0919fc 100644 --- a/lib/Doctrine/Inflector/Rules/English/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/English/Inflectible.php @@ -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 @@ public static function getSingular() : iterable /** * @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 @@ public static function getPlural() : iterable /** * @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')); diff --git a/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php b/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php index cd40021f..85f92aa8 100644 --- a/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php +++ b/lib/Doctrine/Inflector/Rules/English/InflectorFactory.php @@ -9,12 +9,12 @@ 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(); } diff --git a/lib/Doctrine/Inflector/Rules/English/Rules.php b/lib/Doctrine/Inflector/Rules/English/Rules.php index fcc1d19c..7ccc1038 100644 --- a/lib/Doctrine/Inflector/Rules/English/Rules.php +++ b/lib/Doctrine/Inflector/Rules/English/Rules.php @@ -11,7 +11,7 @@ final class Rules { - public static function getSingularRuleset() : Ruleset + public static function getSingularRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getSingular()), @@ -20,7 +20,7 @@ public static function getSingularRuleset() : Ruleset ); } - public static function getPluralRuleset() : Ruleset + public static function getPluralRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getPlural()), diff --git a/lib/Doctrine/Inflector/Rules/English/Uninflected.php b/lib/Doctrine/Inflector/Rules/English/Uninflected.php index be37a97b..e2656cc4 100644 --- a/lib/Doctrine/Inflector/Rules/English/Uninflected.php +++ b/lib/Doctrine/Inflector/Rules/English/Uninflected.php @@ -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 @@ public static function getSingular() : iterable /** * @return Pattern[] */ - public static function getPlural() : iterable + public static function getPlural(): iterable { yield from self::getDefault(); @@ -46,7 +46,7 @@ public static function getPlural() : iterable /** * @return Pattern[] */ - private static function getDefault() : iterable + private static function getDefault(): iterable { yield new Pattern('\w+media'); yield new Pattern('advice'); diff --git a/lib/Doctrine/Inflector/Rules/French/Inflectible.php b/lib/Doctrine/Inflector/Rules/French/Inflectible.php index b3f22ed2..c73d3dee 100644 --- a/lib/Doctrine/Inflector/Rules/French/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/French/Inflectible.php @@ -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,7 +26,7 @@ public static function getSingular() : iterable /** * @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'); @@ -40,7 +40,7 @@ public static function getPlural() : iterable /** * @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')); diff --git a/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php b/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php index 7042d498..62e31f08 100644 --- a/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php +++ b/lib/Doctrine/Inflector/Rules/French/InflectorFactory.php @@ -9,12 +9,12 @@ 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(); } diff --git a/lib/Doctrine/Inflector/Rules/French/Rules.php b/lib/Doctrine/Inflector/Rules/French/Rules.php index d25f8a8c..6cd45bc5 100644 --- a/lib/Doctrine/Inflector/Rules/French/Rules.php +++ b/lib/Doctrine/Inflector/Rules/French/Rules.php @@ -11,7 +11,7 @@ final class Rules { - public static function getSingularRuleset() : Ruleset + public static function getSingularRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getSingular()), @@ -20,7 +20,7 @@ public static function getSingularRuleset() : Ruleset ); } - public static function getPluralRuleset() : Ruleset + public static function getPluralRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getPlural()), diff --git a/lib/Doctrine/Inflector/Rules/French/Uninflected.php b/lib/Doctrine/Inflector/Rules/French/Uninflected.php index 2fdc020a..3cf2444a 100644 --- a/lib/Doctrine/Inflector/Rules/French/Uninflected.php +++ b/lib/Doctrine/Inflector/Rules/French/Uninflected.php @@ -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 @@ public static function getSingular() : iterable /** * @return Pattern[] */ - public static function getPlural() : iterable + public static function getPlural(): iterable { yield from self::getDefault(); } @@ -27,7 +27,7 @@ public static function getPlural() : iterable /** * @return Pattern[] */ - private static function getDefault() : iterable + private static function getDefault(): iterable { yield new Pattern(''); } diff --git a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php index 9fae0f36..c00317dc 100644 --- a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Inflectible.php @@ -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 @@ public static function getSingular() : iterable /** * @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 @@ public static function getPlural() : iterable /** * @return Substitution[] */ - public static function getIrregular() : iterable + public static function getIrregular(): iterable { yield new Substitution(new Word('konto'), new Word('konti')); } diff --git a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php index 41b9b384..912ae41b 100644 --- a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php +++ b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/InflectorFactory.php @@ -9,12 +9,12 @@ 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(); } diff --git a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php index 5a92132a..9902d353 100644 --- a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php +++ b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Rules.php @@ -11,7 +11,7 @@ final class Rules { - public static function getSingularRuleset() : Ruleset + public static function getSingularRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getSingular()), @@ -20,7 +20,7 @@ public static function getSingularRuleset() : Ruleset ); } - public static function getPluralRuleset() : Ruleset + public static function getPluralRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getPlural()), diff --git a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php index c6b9fc79..5d878c6d 100644 --- a/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php +++ b/lib/Doctrine/Inflector/Rules/NorwegianBokmal/Uninflected.php @@ -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 @@ public static function getSingular() : iterable /** * @return Pattern[] */ - public static function getPlural() : iterable + public static function getPlural(): iterable { yield from self::getDefault(); } @@ -27,7 +27,7 @@ public static function getPlural() : iterable /** * @return Pattern[] */ - private static function getDefault() : iterable + private static function getDefault(): iterable { yield new Pattern('barn'); yield new Pattern('fjell'); diff --git a/lib/Doctrine/Inflector/Rules/Pattern.php b/lib/Doctrine/Inflector/Rules/Pattern.php index 3486eba5..a5f0ef77 100644 --- a/lib/Doctrine/Inflector/Rules/Pattern.php +++ b/lib/Doctrine/Inflector/Rules/Pattern.php @@ -25,17 +25,17 @@ public function __construct(string $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; } diff --git a/lib/Doctrine/Inflector/Rules/Patterns.php b/lib/Doctrine/Inflector/Rules/Patterns.php index a71f1ed2..e8d45cb7 100644 --- a/lib/Doctrine/Inflector/Rules/Patterns.php +++ b/lib/Doctrine/Inflector/Rules/Patterns.php @@ -20,14 +20,14 @@ public function __construct(Pattern ...$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; } diff --git a/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php b/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php index 155055f7..95564d49 100644 --- a/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/Portuguese/Inflectible.php @@ -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 @@ public static function getSingular() : iterable /** * @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 @@ public static function getPlural() : iterable /** * @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')); diff --git a/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php b/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php index 536587e0..bf12d54f 100644 --- a/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php +++ b/lib/Doctrine/Inflector/Rules/Portuguese/InflectorFactory.php @@ -9,12 +9,12 @@ 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(); } diff --git a/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php b/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php index de69b7ec..897f1776 100644 --- a/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php +++ b/lib/Doctrine/Inflector/Rules/Portuguese/Rules.php @@ -11,7 +11,7 @@ final class Rules { - public static function getSingularRuleset() : Ruleset + public static function getSingularRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getSingular()), @@ -20,7 +20,7 @@ public static function getSingularRuleset() : Ruleset ); } - public static function getPluralRuleset() : Ruleset + public static function getPluralRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getPlural()), diff --git a/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php b/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php index 52360c45..58c34f9b 100644 --- a/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php +++ b/lib/Doctrine/Inflector/Rules/Portuguese/Uninflected.php @@ -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 @@ public static function getSingular() : iterable /** * @return Pattern[] */ - public static function getPlural() : iterable + public static function getPlural(): iterable { yield from self::getDefault(); } @@ -27,7 +27,7 @@ public static function getPlural() : iterable /** * @return Pattern[] */ - private static function getDefault() : iterable + private static function getDefault(): iterable { yield new Pattern('tórax'); yield new Pattern('tênis'); diff --git a/lib/Doctrine/Inflector/Rules/Ruleset.php b/lib/Doctrine/Inflector/Rules/Ruleset.php index a2d32c1d..39889b79 100644 --- a/lib/Doctrine/Inflector/Rules/Ruleset.php +++ b/lib/Doctrine/Inflector/Rules/Ruleset.php @@ -22,17 +22,17 @@ public function __construct(Transformations $regular, Patterns $uninflected, Sub $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; } diff --git a/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php b/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php index 6cace86a..c6862fa4 100644 --- a/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/Spanish/Inflectible.php @@ -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 @@ public static function getSingular() : iterable /** * @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 @@ public static function getPlural() : iterable /** * @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')); diff --git a/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php b/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php index da643bda..85084ca3 100644 --- a/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php +++ b/lib/Doctrine/Inflector/Rules/Spanish/InflectorFactory.php @@ -9,12 +9,12 @@ 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(); } diff --git a/lib/Doctrine/Inflector/Rules/Spanish/Rules.php b/lib/Doctrine/Inflector/Rules/Spanish/Rules.php index f77a739b..d7399725 100644 --- a/lib/Doctrine/Inflector/Rules/Spanish/Rules.php +++ b/lib/Doctrine/Inflector/Rules/Spanish/Rules.php @@ -11,7 +11,7 @@ final class Rules { - public static function getSingularRuleset() : Ruleset + public static function getSingularRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getSingular()), @@ -20,7 +20,7 @@ public static function getSingularRuleset() : Ruleset ); } - public static function getPluralRuleset() : Ruleset + public static function getPluralRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getPlural()), diff --git a/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php b/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php index b13281e8..c743b393 100644 --- a/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php +++ b/lib/Doctrine/Inflector/Rules/Spanish/Uninflected.php @@ -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 @@ public static function getSingular() : iterable /** * @return Pattern[] */ - public static function getPlural() : iterable + public static function getPlural(): iterable { yield from self::getDefault(); } @@ -27,7 +27,7 @@ public static function getPlural() : iterable /** * @return Pattern[] */ - private static function getDefault() : iterable + private static function getDefault(): iterable { yield new Pattern('lunes'); yield new Pattern('rompecabezas'); diff --git a/lib/Doctrine/Inflector/Rules/Substitution.php b/lib/Doctrine/Inflector/Rules/Substitution.php index 681ab631..471aff9e 100644 --- a/lib/Doctrine/Inflector/Rules/Substitution.php +++ b/lib/Doctrine/Inflector/Rules/Substitution.php @@ -18,12 +18,12 @@ public function __construct(Word $from, Word $to) $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; } diff --git a/lib/Doctrine/Inflector/Rules/Substitutions.php b/lib/Doctrine/Inflector/Rules/Substitutions.php index 24cc34a8..17ee2961 100644 --- a/lib/Doctrine/Inflector/Rules/Substitutions.php +++ b/lib/Doctrine/Inflector/Rules/Substitutions.php @@ -5,6 +5,7 @@ namespace Doctrine\Inflector\Rules; use Doctrine\Inflector\WordInflector; + use function strtolower; use function strtoupper; use function substr; @@ -21,7 +22,7 @@ public function __construct(Substitution ...$substitutions) } } - public function getFlippedSubstitutions() : Substitutions + public function getFlippedSubstitutions(): Substitutions { $substitutions = []; @@ -35,7 +36,7 @@ public function getFlippedSubstitutions() : Substitutions return new Substitutions(...$substitutions); } - public function inflect(string $word) : string + public function inflect(string $word): string { $lowerWord = strtolower($word); diff --git a/lib/Doctrine/Inflector/Rules/Transformation.php b/lib/Doctrine/Inflector/Rules/Transformation.php index 84ef08b8..30dcd594 100644 --- a/lib/Doctrine/Inflector/Rules/Transformation.php +++ b/lib/Doctrine/Inflector/Rules/Transformation.php @@ -5,6 +5,7 @@ namespace Doctrine\Inflector\Rules; use Doctrine\Inflector\WordInflector; + use function preg_replace; final class Transformation implements WordInflector @@ -21,17 +22,17 @@ public function __construct(Pattern $pattern, string $replacement) $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); } diff --git a/lib/Doctrine/Inflector/Rules/Transformations.php b/lib/Doctrine/Inflector/Rules/Transformations.php index 9f4724e5..b6a48fa8 100644 --- a/lib/Doctrine/Inflector/Rules/Transformations.php +++ b/lib/Doctrine/Inflector/Rules/Transformations.php @@ -16,7 +16,7 @@ public function __construct(Transformation ...$transformations) $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)) { diff --git a/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php b/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php index 74900cb9..d7b7064c 100644 --- a/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/Turkish/Inflectible.php @@ -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 @@ public static function getSingular() : iterable /** * @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 @@ public static function getPlural() : iterable /** * @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')); diff --git a/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php b/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php index 83b80467..c6cdebe9 100644 --- a/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php +++ b/lib/Doctrine/Inflector/Rules/Turkish/InflectorFactory.php @@ -9,12 +9,12 @@ 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(); } diff --git a/lib/Doctrine/Inflector/Rules/Turkish/Rules.php b/lib/Doctrine/Inflector/Rules/Turkish/Rules.php index dd0840c5..ea564ac7 100644 --- a/lib/Doctrine/Inflector/Rules/Turkish/Rules.php +++ b/lib/Doctrine/Inflector/Rules/Turkish/Rules.php @@ -11,7 +11,7 @@ final class Rules { - public static function getSingularRuleset() : Ruleset + public static function getSingularRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getSingular()), @@ -20,7 +20,7 @@ public static function getSingularRuleset() : Ruleset ); } - public static function getPluralRuleset() : Ruleset + public static function getPluralRuleset(): Ruleset { return new Ruleset( new Transformations(...Inflectible::getPlural()), diff --git a/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php b/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php index c95ccbf9..a75d2486 100644 --- a/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php +++ b/lib/Doctrine/Inflector/Rules/Turkish/Uninflected.php @@ -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 @@ public static function getSingular() : iterable /** * @return Pattern[] */ - public static function getPlural() : iterable + public static function getPlural(): iterable { yield from self::getDefault(); } @@ -27,7 +27,7 @@ public static function getPlural() : iterable /** * @return Pattern[] */ - private static function getDefault() : iterable + private static function getDefault(): iterable { yield new Pattern('lunes'); yield new Pattern('rompecabezas'); diff --git a/lib/Doctrine/Inflector/Rules/Word.php b/lib/Doctrine/Inflector/Rules/Word.php index 5156e934..98e93ba2 100644 --- a/lib/Doctrine/Inflector/Rules/Word.php +++ b/lib/Doctrine/Inflector/Rules/Word.php @@ -14,7 +14,7 @@ public function __construct(string $word) $this->word = $word; } - public function getWord() : string + public function getWord(): string { return $this->word; } diff --git a/lib/Doctrine/Inflector/RulesetInflector.php b/lib/Doctrine/Inflector/RulesetInflector.php index 0e3a5ebd..12b2ed5b 100644 --- a/lib/Doctrine/Inflector/RulesetInflector.php +++ b/lib/Doctrine/Inflector/RulesetInflector.php @@ -5,6 +5,7 @@ namespace Doctrine\Inflector; use Doctrine\Inflector\Rules\Ruleset; + use function array_merge; /** @@ -26,7 +27,7 @@ public function __construct(Ruleset $ruleset, Ruleset ...$rulesets) $this->rulesets = array_merge([$ruleset], $rulesets); } - public function inflect(string $word) : string + public function inflect(string $word): string { if ($word === '') { return ''; diff --git a/lib/Doctrine/Inflector/WordInflector.php b/lib/Doctrine/Inflector/WordInflector.php index f2570558..b88b1d69 100644 --- a/lib/Doctrine/Inflector/WordInflector.php +++ b/lib/Doctrine/Inflector/WordInflector.php @@ -6,5 +6,5 @@ interface WordInflector { - public function inflect(string $word) : string; + public function inflect(string $word): string; } diff --git a/tests/Doctrine/Tests/Inflector/CachedWordInflectorTest.php b/tests/Doctrine/Tests/Inflector/CachedWordInflectorTest.php index cab3b6eb..fedfb922 100644 --- a/tests/Doctrine/Tests/Inflector/CachedWordInflectorTest.php +++ b/tests/Doctrine/Tests/Inflector/CachedWordInflectorTest.php @@ -17,7 +17,7 @@ class CachedWordInflectorTest extends TestCase /** @var CachedWordInflector */ private $cachedWordInflector; - public function testInflect() : void + public function testInflect(): void { $this->wordInflector->expects(self::once()) ->method('inflect') @@ -28,7 +28,7 @@ public function testInflect() : void self::assertSame('out', $this->cachedWordInflector->inflect('in')); } - protected function setUp() : void + protected function setUp(): void { $this->wordInflector = $this->createMock(WordInflector::class); diff --git a/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php b/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php index 2720c06c..e52156d0 100644 --- a/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php +++ b/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php @@ -18,7 +18,7 @@ class InflectorFactoryTest extends TestCase { - public function testCreateUsesEnglishByDefault() : void + public function testCreateUsesEnglishByDefault(): void { self::assertInstanceOf(EnglishInflectorFactory::class, InflectorFactory::create()); } @@ -26,12 +26,12 @@ public function testCreateUsesEnglishByDefault() : void /** * @dataProvider provideLanguages */ - public function testCreateForLanguageWithCustomLanguage(string $expectedClass, string $language) : void + public function testCreateForLanguageWithCustomLanguage(string $expectedClass, string $language): void { self::assertInstanceOf($expectedClass, InflectorFactory::createForLanguage($language)); } - public static function provideLanguages() : Generator + public static function provideLanguages(): Generator { yield 'English' => [EnglishInflectorFactory::class, Language::ENGLISH]; yield 'French' => [FrenchInflectorFactory::class, Language::FRENCH]; @@ -41,7 +41,7 @@ public static function provideLanguages() : Generator yield 'Turkish' => [TurkishInflectorFactory::class, Language::TURKISH]; } - public function testCreateForLanguageThrowsInvalidArgumentExceptionForUnsupportedLanguage() : void + public function testCreateForLanguageThrowsInvalidArgumentExceptionForUnsupportedLanguage(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Language "invalid" is not supported.'); diff --git a/tests/Doctrine/Tests/Inflector/InflectorFunctionalTest.php b/tests/Doctrine/Tests/Inflector/InflectorFunctionalTest.php index 84b3f400..569b52e5 100644 --- a/tests/Doctrine/Tests/Inflector/InflectorFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/InflectorFunctionalTest.php @@ -10,7 +10,7 @@ class InflectorFunctionalTest extends TestCase { - public function testCapitalize() : void + public function testCapitalize(): void { self::assertSame( 'Top-O-The-Morning To All_of_you!', @@ -18,7 +18,7 @@ public function testCapitalize() : void ); } - public function testCapitalizeWithCustomDelimiters() : void + public function testCapitalizeWithCustomDelimiters(): void { self::assertSame( 'Top-O-The-Morning To All_Of_You!', @@ -29,7 +29,7 @@ public function testCapitalizeWithCustomDelimiters() : void /** * @dataProvider dataStringsTableize */ - public function testTableize(string $expected, string $word) : void + public function testTableize(string $expected, string $word): void { self::assertSame($expected, $this->createInflector()->tableize($word)); } @@ -39,7 +39,7 @@ public function testTableize(string $expected, string $word) : void * * @return string[][] */ - public function dataStringsTableize() : array + public function dataStringsTableize(): array { // In the format array('expected', 'word') return [ @@ -52,7 +52,7 @@ public function dataStringsTableize() : array /** * @dataProvider dataStringsClassify */ - public function testClassify(string $expected, string $word) : void + public function testClassify(string $expected, string $word): void { self::assertSame($expected, $this->createInflector()->classify($word)); } @@ -62,7 +62,7 @@ public function testClassify(string $expected, string $word) : void * * @return string[][] */ - public function dataStringsClassify() : array + public function dataStringsClassify(): array { // In the format array('expected', 'word') return [ @@ -78,7 +78,7 @@ public function dataStringsClassify() : array /** * @dataProvider dataStringsCamelize */ - public function testCamelize(string $expected, string $word) : void + public function testCamelize(string $expected, string $word): void { self::assertSame($expected, $this->createInflector()->camelize($word)); } @@ -88,7 +88,7 @@ public function testCamelize(string $expected, string $word) : void * * @return string[][] */ - public function dataStringsCamelize() : array + public function dataStringsCamelize(): array { // In the format array('expected', 'word') return [ @@ -100,7 +100,7 @@ public function dataStringsCamelize() : array ]; } - private function createInflector() : Inflector + private function createInflector(): Inflector { return InflectorFactory::create()->build(); } diff --git a/tests/Doctrine/Tests/Inflector/InflectorTest.php b/tests/Doctrine/Tests/Inflector/InflectorTest.php index 77f245d6..c917d2cc 100644 --- a/tests/Doctrine/Tests/Inflector/InflectorTest.php +++ b/tests/Doctrine/Tests/Inflector/InflectorTest.php @@ -20,28 +20,28 @@ class InflectorTest extends TestCase /** @var Inflector */ private $inflector; - public function testTableize() : void + public function testTableize(): void { self::assertSame('model_name', $this->inflector->tableize('ModelName')); self::assertSame('model_name', $this->inflector->tableize('modelName')); self::assertSame('model_name', $this->inflector->tableize('model_name')); } - public function testClassify() : void + public function testClassify(): void { self::assertSame('ModelName', $this->inflector->classify('model_name')); self::assertSame('ModelName', $this->inflector->classify('modelName')); self::assertSame('ModelName', $this->inflector->classify('ModelName')); } - public function testCamelize() : void + public function testCamelize(): void { self::assertSame('modelName', $this->inflector->camelize('ModelName')); self::assertSame('modelName', $this->inflector->camelize('model_name')); self::assertSame('modelName', $this->inflector->camelize('modelName')); } - public function testCapitalize() : void + public function testCapitalize(): void { self::assertSame( 'Top-O-The-Morning To All_of_you!', @@ -49,14 +49,14 @@ public function testCapitalize() : void ); } - public function testSeemsUtf8() : void + public function testSeemsUtf8(): void { self::assertTrue($this->inflector->seemsUtf8('teléfono')); self::assertTrue($this->inflector->seemsUtf8('král')); self::assertTrue($this->inflector->seemsUtf8('telephone')); } - public function testUnaccent() : void + public function testUnaccent(): void { self::assertSame('telefono', $this->inflector->unaccent('teléfono')); self::assertSame('telephone', $this->inflector->unaccent('telephone')); @@ -65,7 +65,7 @@ public function testUnaccent() : void /** * @dataProvider dataStringsUrlize */ - public function testUrlize(string $expected, string $string) : void + public function testUrlize(string $expected, string $string): void { self::assertSame( $expected, @@ -78,7 +78,7 @@ public function testUrlize(string $expected, string $string) : void * * @return string[][] */ - public function dataStringsUrlize() : array + public function dataStringsUrlize(): array { return [ [ @@ -116,7 +116,7 @@ public function dataStringsUrlize() : array ]; } - public function testPluralize() : void + public function testPluralize(): void { $this->pluralInflector->expects(self::once()) ->method('inflect') @@ -126,7 +126,7 @@ public function testPluralize() : void self::assertSame('out', $this->inflector->pluralize('in')); } - public function testSingularize() : void + public function testSingularize(): void { $this->singularInflector->expects(self::once()) ->method('inflect') @@ -136,7 +136,7 @@ public function testSingularize() : void self::assertSame('out', $this->inflector->singularize('in')); } - protected function setUp() : void + protected function setUp(): void { $this->singularInflector = $this->createMock(WordInflector::class); $this->pluralInflector = $this->createMock(WordInflector::class); diff --git a/tests/Doctrine/Tests/Inflector/NoopWordInflectorTest.php b/tests/Doctrine/Tests/Inflector/NoopWordInflectorTest.php index 6e414913..378edd34 100644 --- a/tests/Doctrine/Tests/Inflector/NoopWordInflectorTest.php +++ b/tests/Doctrine/Tests/Inflector/NoopWordInflectorTest.php @@ -12,13 +12,13 @@ class NoopWordInflectorTest extends TestCase /** @var NoopWordInflector */ private $inflector; - public function testInflect() : void + public function testInflect(): void { self::assertSame('foo', $this->inflector->inflect('foo')); self::assertSame('bar', $this->inflector->inflect('bar')); } - protected function setUp() : void + protected function setUp(): void { $this->inflector = new NoopWordInflector(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php index f5c6adb7..e84c8559 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php @@ -8,6 +8,7 @@ use Doctrine\Inflector\InflectorFactory; use Doctrine\Inflector\Language; use Doctrine\Tests\Inflector\Rules\LanguageFunctionalTest; + use function sprintf; class EnglishFunctionalTest extends LanguageFunctionalTest @@ -15,7 +16,7 @@ class EnglishFunctionalTest extends LanguageFunctionalTest /** * @return string[][] */ - public function dataSampleWords() : array + public function dataSampleWords(): array { return [ ['', ''], @@ -445,7 +446,7 @@ public function dataSampleWords() : array * * @return string[][] */ - public function dataSingularsUninflectedWhenSingularized() : array + public function dataSingularsUninflectedWhenSingularized(): array { // In the format array('singular', 'notEquals') return [ @@ -466,7 +467,7 @@ public function dataSingularsUninflectedWhenSingularized() : array /** * @dataProvider dataSingularsUninflectedWhenSingularized */ - public function testSingularsWhenSingularizedShouldBeUninflected(string $singular, string $notEquals) : void + public function testSingularsWhenSingularizedShouldBeUninflected(string $singular, string $notEquals): void { self::assertNotSame( $notEquals, @@ -482,7 +483,7 @@ public function testSingularsWhenSingularizedShouldBeUninflected(string $singula * * @return string[][] */ - public function dataPluralUninflectedWhenPluralized() : array + public function dataPluralUninflectedWhenPluralized(): array { return [ ['media'], @@ -492,7 +493,7 @@ public function dataPluralUninflectedWhenPluralized() : array /** * @dataProvider dataPluralUninflectedWhenPluralized */ - public function testPluralsWhenPluralizedShouldBeUninflected(string $plural) : void + public function testPluralsWhenPluralizedShouldBeUninflected(string $plural): void { $pluralized = $this->createInflector()->pluralize($plural); @@ -503,7 +504,7 @@ public function testPluralsWhenPluralizedShouldBeUninflected(string $plural) : v ); } - protected function createInflector() : Inflector + protected function createInflector(): Inflector { return InflectorFactory::createForLanguage(Language::ENGLISH)->build(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/French/FrenchFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/French/FrenchFunctionalTest.php index 8d7975c4..4ead07e6 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/French/FrenchFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/French/FrenchFunctionalTest.php @@ -14,7 +14,7 @@ class FrenchFunctionalTest extends LanguageFunctionalTest /** * @return string[][] */ - public function dataSampleWords() : array + public function dataSampleWords(): array { return [ ['ami', 'amis'], @@ -56,7 +56,7 @@ public function dataSampleWords() : array ]; } - protected function createInflector() : Inflector + protected function createInflector(): Inflector { return InflectorFactory::createForLanguage(Language::FRENCH)->build(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/LanguageFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/LanguageFunctionalTest.php index fca58f26..ecefcf01 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/LanguageFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/LanguageFunctionalTest.php @@ -6,6 +6,7 @@ use Doctrine\Inflector\Inflector; use PHPUnit\Framework\TestCase; + use function sprintf; abstract class LanguageFunctionalTest extends TestCase @@ -13,12 +14,12 @@ abstract class LanguageFunctionalTest extends TestCase /** * @return string[][] */ - abstract public function dataSampleWords() : array; + abstract public function dataSampleWords(): array; /** * @dataProvider dataSampleWords */ - public function testInflectingSingulars(string $singular, string $plural) : void + public function testInflectingSingulars(string $singular, string $plural): void { self::assertSame( $singular, @@ -30,7 +31,7 @@ public function testInflectingSingulars(string $singular, string $plural) : void /** * @dataProvider dataSampleWords */ - public function testInflectingPlurals(string $singular, string $plural) : void + public function testInflectingPlurals(string $singular, string $plural): void { self::assertSame( $plural, @@ -39,5 +40,5 @@ public function testInflectingPlurals(string $singular, string $plural) : void ); } - abstract protected function createInflector() : Inflector; + abstract protected function createInflector(): Inflector; } diff --git a/tests/Doctrine/Tests/Inflector/Rules/NorwegianBokmal/NorwegianBokmalFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/NorwegianBokmal/NorwegianBokmalFunctionalTest.php index 077e6e0e..de9059e2 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/NorwegianBokmal/NorwegianBokmalFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/NorwegianBokmal/NorwegianBokmalFunctionalTest.php @@ -14,7 +14,7 @@ class NorwegianBokmalFunctionalTest extends LanguageFunctionalTest /** * @return string[][] */ - public function dataSampleWords() : array + public function dataSampleWords(): array { return [ ['dag', 'dager'], @@ -31,7 +31,7 @@ public function dataSampleWords() : array ]; } - protected function createInflector() : Inflector + protected function createInflector(): Inflector { return InflectorFactory::createForLanguage(Language::NORWEGIAN_BOKMAL)->build(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/PatternTest.php b/tests/Doctrine/Tests/Inflector/Rules/PatternTest.php index 673e6355..7d59d158 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/PatternTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/PatternTest.php @@ -12,29 +12,29 @@ class PatternTest extends TestCase /** @var Pattern */ private $pattern; - public function testGetPattern() : void + public function testGetPattern(): void { self::assertSame('test', $this->pattern->getPattern()); } - public function testGetRegex() : void + public function testGetRegex(): void { self::assertSame('/test/i', $this->pattern->getRegex()); } - public function testPatternWithExplicitRegex() : void + public function testPatternWithExplicitRegex(): void { $pattern = new Pattern('/test/'); self::assertSame('/test/', $pattern->getRegex()); } - public function testMatches() : void + public function testMatches(): void { self::assertTrue($this->pattern->matches('test')); } - protected function setUp() : void + protected function setUp(): void { $this->pattern = new Pattern('test'); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/PatternsTest.php b/tests/Doctrine/Tests/Inflector/Rules/PatternsTest.php index 8b901065..704f4bc0 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/PatternsTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/PatternsTest.php @@ -13,13 +13,13 @@ class PatternsTest extends TestCase /** @var Patterns */ private $patterns; - public function testMatches() : void + public function testMatches(): void { self::assertTrue($this->patterns->matches('test1')); self::assertFalse($this->patterns->matches('test2')); } - protected function setUp() : void + protected function setUp(): void { $this->patterns = new Patterns(new Pattern('test1')); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/Portuguese/PortugueseFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/Portuguese/PortugueseFunctionalTest.php index 9d5ad860..72bf9198 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/Portuguese/PortugueseFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/Portuguese/PortugueseFunctionalTest.php @@ -14,7 +14,7 @@ class PortugueseFunctionalTest extends LanguageFunctionalTest /** * @return string[][] */ - public function dataSampleWords() : array + public function dataSampleWords(): array { return [ ['livro', 'livros'], @@ -47,7 +47,7 @@ public function dataSampleWords() : array ]; } - protected function createInflector() : Inflector + protected function createInflector(): Inflector { return InflectorFactory::createForLanguage(Language::PORTUGUESE)->build(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/RulesetTest.php b/tests/Doctrine/Tests/Inflector/Rules/RulesetTest.php index bf03f41e..f44c5822 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/RulesetTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/RulesetTest.php @@ -25,22 +25,22 @@ class RulesetTest extends TestCase /** @var Ruleset */ private $ruleset; - public function testGetRegular() : void + public function testGetRegular(): void { self::assertSame($this->regular, $this->ruleset->getRegular()); } - public function testGetUninflected() : void + public function testGetUninflected(): void { self::assertSame($this->uninflected, $this->ruleset->getUninflected()); } - public function testGetIrregular() : void + public function testGetIrregular(): void { self::assertSame($this->irregular, $this->ruleset->getIrregular()); } - protected function setUp() : void + protected function setUp(): void { $this->regular = $this->createMock(Transformations::class); $this->uninflected = $this->createMock(Patterns::class); diff --git a/tests/Doctrine/Tests/Inflector/Rules/Spanish/SpanishFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/Spanish/SpanishFunctionalTest.php index 16a4186a..c881e91e 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/Spanish/SpanishFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/Spanish/SpanishFunctionalTest.php @@ -14,7 +14,7 @@ class SpanishFunctionalTest extends LanguageFunctionalTest /** * @return string[][] */ - public function dataSampleWords() : array + public function dataSampleWords(): array { return [ ['libro', 'libros'], @@ -56,7 +56,7 @@ public function dataSampleWords() : array ]; } - protected function createInflector() : Inflector + protected function createInflector(): Inflector { return InflectorFactory::createForLanguage(Language::SPANISH)->build(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/SubstitutionTest.php b/tests/Doctrine/Tests/Inflector/Rules/SubstitutionTest.php index 25b0a2f5..0f366ca1 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/SubstitutionTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/SubstitutionTest.php @@ -13,17 +13,17 @@ class SubstitutionTest extends TestCase /** @var Substitution */ private $substitution; - public function testGetFrom() : void + public function testGetFrom(): void { self::assertSame('from', $this->substitution->getFrom()->getWord()); } - public function testGetTo() : void + public function testGetTo(): void { self::assertSame('to', $this->substitution->getTo()->getWord()); } - protected function setUp() : void + protected function setUp(): void { $this->substitution = new Substitution(new Word('from'), new Word('to')); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/SubstitutionsTest.php b/tests/Doctrine/Tests/Inflector/Rules/SubstitutionsTest.php index 44139dee..2c779bb2 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/SubstitutionsTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/SubstitutionsTest.php @@ -17,19 +17,19 @@ class SubstitutionsTest extends TestCase /** @var Substitutions */ private $irregular; - public function testGetFlippedSubstitutions() : void + public function testGetFlippedSubstitutions(): void { $substitutions = $this->irregular->getFlippedSubstitutions(); self::assertSame('spins', $substitutions->inflect('spinor')); } - public function testInflect() : void + public function testInflect(): void { self::assertSame('spinor', $this->irregular->inflect('spins')); } - protected function setUp() : void + protected function setUp(): void { $this->substitutions = [ new Substitution(new Word('spins'), new Word('spinor')), diff --git a/tests/Doctrine/Tests/Inflector/Rules/TransformationTest.php b/tests/Doctrine/Tests/Inflector/Rules/TransformationTest.php index 2234c337..48002801 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/TransformationTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/TransformationTest.php @@ -13,22 +13,22 @@ class TransformationTest extends TestCase /** @var Transformation */ private $transformation; - public function testGetPattern() : void + public function testGetPattern(): void { self::assertSame('s$', $this->transformation->getPattern()->getPattern()); } - public function testGetReplacement() : void + public function testGetReplacement(): void { self::assertSame('', $this->transformation->getReplacement()); } - public function testInflect() : void + public function testInflect(): void { self::assertSame('test', $this->transformation->inflect('tests')); } - protected function setUp() : void + protected function setUp(): void { $this->transformation = new Transformation(new Pattern('s$'), ''); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/TransformationsTest.php b/tests/Doctrine/Tests/Inflector/Rules/TransformationsTest.php index 57c25e30..9f842490 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/TransformationsTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/TransformationsTest.php @@ -14,12 +14,12 @@ class TransformationsTest extends TestCase /** @var Transformations */ private $transformations; - public function testInflect() : void + public function testInflect(): void { self::assertSame('customizables', $this->transformations->inflect('custom')); } - protected function setUp() : void + protected function setUp(): void { $this->transformations = new Transformations(new Transformation(new Pattern('/^(custom)$/i'), '\1izables')); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/Turkish/TurkishFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/Turkish/TurkishFunctionalTest.php index c9577f85..ac29e2c8 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/Turkish/TurkishFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/Turkish/TurkishFunctionalTest.php @@ -14,7 +14,7 @@ class TurkishFunctionalTest extends LanguageFunctionalTest /** * @return string[][] */ - public function dataSampleWords() : array + public function dataSampleWords(): array { return [ ['gün', 'günler'], @@ -29,7 +29,7 @@ public function dataSampleWords() : array ]; } - protected function createInflector() : Inflector + protected function createInflector(): Inflector { return InflectorFactory::createForLanguage(Language::TURKISH)->build(); } diff --git a/tests/Doctrine/Tests/Inflector/Rules/WordTest.php b/tests/Doctrine/Tests/Inflector/Rules/WordTest.php index d3351524..994031de 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/WordTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/WordTest.php @@ -12,12 +12,12 @@ class WordTest extends TestCase /** @var Word */ private $word; - public function testGetWord() : void + public function testGetWord(): void { self::assertSame('test', $this->word->getWord()); } - protected function setUp() : void + protected function setUp(): void { $this->word = new Word('test'); } diff --git a/tests/Doctrine/Tests/Inflector/RulesetInflectorTest.php b/tests/Doctrine/Tests/Inflector/RulesetInflectorTest.php index dd495b49..a3e0fcd5 100644 --- a/tests/Doctrine/Tests/Inflector/RulesetInflectorTest.php +++ b/tests/Doctrine/Tests/Inflector/RulesetInflectorTest.php @@ -26,7 +26,7 @@ class RulesetInflectorTest extends TestCase /** @var RulesetInflector */ private $rulesetInflector; - public function testInflectIrregularUsesFirstMatch() : void + public function testInflectIrregularUsesFirstMatch(): void { $firstIrregular = $this->createMock(Substitutions::class); $secondIrregular = $this->createMock(Substitutions::class); @@ -50,7 +50,7 @@ public function testInflectIrregularUsesFirstMatch() : void self::assertSame('first', $this->rulesetInflector->inflect('in')); } - public function testInflectIrregularContinuesIfFirstRulesetReturnsOriginalValue() : void + public function testInflectIrregularContinuesIfFirstRulesetReturnsOriginalValue(): void { $firstRuleset = new Ruleset( new Transformations(), @@ -69,7 +69,7 @@ public function testInflectIrregularContinuesIfFirstRulesetReturnsOriginalValue( self::assertSame('second', $inflector->inflect('in')); } - public function testInflectUninflectedSkipsOnFirstMatch() : void + public function testInflectUninflectedSkipsOnFirstMatch(): void { $firstUninflected = $this->createMock(Patterns::class); $secondUninflected = $this->createMock(Patterns::class); @@ -93,7 +93,7 @@ public function testInflectUninflectedSkipsOnFirstMatch() : void self::assertSame('in', $this->rulesetInflector->inflect('in')); } - public function testIrregularIsInflectedEvenIfLaterRulesetIgnores() : void + public function testIrregularIsInflectedEvenIfLaterRulesetIgnores(): void { $firstIrregular = new Substitutions(new Substitution(new Word('travel'), new Word('travels'))); $secondUninflected = new Patterns(new Pattern('travel')); @@ -109,7 +109,7 @@ public function testIrregularIsInflectedEvenIfLaterRulesetIgnores() : void self::assertSame('travels', $this->rulesetInflector->inflect('travel')); } - public function testInflectRegularUsesFirstMatch() : void + public function testInflectRegularUsesFirstMatch(): void { $irregular = $this->createMock(Substitutions::class); @@ -163,7 +163,7 @@ public function testInflectRegularUsesFirstMatch() : void self::assertSame('first', $this->rulesetInflector->inflect('in')); } - public function testInflectRegularContinuesIfFirstRulesetReturnsOriginalValue() : void + public function testInflectRegularContinuesIfFirstRulesetReturnsOriginalValue(): void { $irregular = $this->createMock(Substitutions::class); @@ -219,7 +219,7 @@ public function testInflectRegularContinuesIfFirstRulesetReturnsOriginalValue() self::assertSame('second', $this->rulesetInflector->inflect('in')); } - public function testInflectReturnsOriginalValueOnNoMatches() : void + public function testInflectReturnsOriginalValueOnNoMatches(): void { $irregular = $this->createMock(Substitutions::class); @@ -269,7 +269,7 @@ public function testInflectReturnsOriginalValueOnNoMatches() : void self::assertSame('in', $this->rulesetInflector->inflect('in')); } - protected function setUp() : void + protected function setUp(): void { $this->firstRuleset = $this->createMock(Ruleset::class); $this->secondRuleset = $this->createMock(Ruleset::class); From fa8fc358d99536b0897f948cbd03d211ae8e163a Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 11 Apr 2021 09:56:43 +0200 Subject: [PATCH 4/4] Apply changes to comply with phpstan 0.12 --- lib/Doctrine/Common/Inflector/Inflector.php | 5 ++++- tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Common/Inflector/Inflector.php b/lib/Doctrine/Common/Inflector/Inflector.php index d00e5651..763b1167 100644 --- a/lib/Doctrine/Common/Inflector/Inflector.php +++ b/lib/Doctrine/Common/Inflector/Inflector.php @@ -167,7 +167,7 @@ public static function reset() : void * }}} * * @param string $type The type of inflection, either 'plural' or 'singular' - * @param array|iterable $rules An array of rules to be added. + * @param array|iterable $rules An array of rules to be added. * @param boolean $reset If true, will unset default inflections for all * new rules that are being defined in $rules. * @@ -197,6 +197,9 @@ public static function rules(string $type, iterable $rules, bool $reset = false) } } + /** + * @param array|iterable $rules An array of rules to be added. + */ private static function buildRuleset(iterable $rules) : Ruleset { $regular = []; diff --git a/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php b/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php index e52156d0..c27992f4 100644 --- a/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php +++ b/tests/Doctrine/Tests/Inflector/InflectorFactoryTest.php @@ -24,6 +24,7 @@ public function testCreateUsesEnglishByDefault(): void } /** + * @psalm-param class-string $expectedClass * @dataProvider provideLanguages */ public function testCreateForLanguageWithCustomLanguage(string $expectedClass, string $language): void @@ -31,6 +32,7 @@ public function testCreateForLanguageWithCustomLanguage(string $expectedClass, s self::assertInstanceOf($expectedClass, InflectorFactory::createForLanguage($language)); } + /** @return Generator */ public static function provideLanguages(): Generator { yield 'English' => [EnglishInflectorFactory::class, Language::ENGLISH];