From 7e62077733cf09faf57b401d6c9ea00f63941e02 Mon Sep 17 00:00:00 2001 From: Artem Henvald Date: Fri, 14 Jun 2019 14:19:09 +0300 Subject: [PATCH] Refactoring + update vendors (#12) --- .gitattributes | 2 ++ .scrutinizer.yml | 14 +++++++------- .styleci.yml | 10 +++++----- .travis.yml | 25 +++++++++++++------------ README.md | 2 +- composer.json | 12 +++++++++--- phpcs.xml | 26 ++++++++++++++++++++++++++ phpstan.neon | 11 +++++++++++ phpunit.xml.dist | 4 ++-- src/RussianToEnglish.php | 8 ++++---- src/Transliterator.php | 4 ++-- src/TransliteratorInterface.php | 4 ++-- src/UkrainianToEnglish.php | 8 ++++---- tests/RussianToEnglishTest.php | 8 ++++---- tests/UkrainianToEnglishTest.php | 6 +++--- 15 files changed, 95 insertions(+), 49 deletions(-) create mode 100644 phpcs.xml create mode 100644 phpstan.neon diff --git a/.gitattributes b/.gitattributes index 1817dab..3592638 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,5 +6,7 @@ /.scrutinizer.yml export-ignore /.styleci.yml export-ignore /.travis.yml export-ignore +/phpcs.xml export-ignore +/phpstan.neon export-ignore /phpunit.xml.dist export-ignore /tests export-ignore diff --git a/.scrutinizer.yml b/.scrutinizer.yml index a5c5b7d..7db6c42 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,12 +1,12 @@ checks: - php: true + php: true filter: - paths: - - src/* - excluded_paths: - - vendor/* - - tests/* + paths: + - src/* + excluded_paths: + - vendor/* + - tests/* before_commands: - - "composer install --prefer-dist" + - "composer install --prefer-dist" diff --git a/.styleci.yml b/.styleci.yml index b8204e9..742c956 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,13 +1,13 @@ preset: recommended enabled: - - combine_consecutive_unsets - - linebreak_after_opening_tag - - ordered_class_elements - - unalign_double_arrow + - combine_consecutive_unsets + - linebreak_after_opening_tag + - ordered_class_elements + - unalign_double_arrow disabled: - - align_double_arrow + - align_double_arrow finder: exclude: diff --git a/.travis.yml b/.travis.yml index df43e16..68a6b92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,27 +3,28 @@ language: php sudo: false php: - - 7.1 - - 7.2 - - 7.3 + - 7.1 + - 7.2 + - 7.3 before_script: - - composer self-update + - composer self-update install: - - composer install --dev --no-interaction --prefer-dist + - composer install --dev --no-interaction --prefer-dist script: - - ./vendor/bin/phpcs ./ -p --encoding=utf-8 --extensions=php --ignore=vendor --ignore=tests --standard=PSR2 - - ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml + - ./vendor/bin/phpcs ./ -p --encoding=utf-8 --extensions=php --ignore=vendor --ignore=tests --standard=phpcs.xml + - ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml + - ./vendor/bin/phpstan analyse -l 7 --no-progress -c phpstan.neon ./ after_success: - - bash <(curl -s https://codecov.io/bash) + - bash <(curl -s https://codecov.io/bash) cache: - directories: - - $COMPOSER_CACHE_DIR + directories: + - $COMPOSER_CACHE_DIR notifications: - email: - - genvaldartem@gmail.com + email: + - genvaldartem@gmail.com diff --git a/README.md b/README.md index 6c24660..f1d3b02 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ PHP library for transliteration. 🇺🇦 :uk: :ru: :abcd: ## Requirements -* PHP 7.1 *and later* +* PHP 7.1.3 *and later* ## Install via Composer diff --git a/composer.json b/composer.json index 1238319..13052f9 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,17 @@ "issues": "https://github.com/fre5h/transliteration/issues" }, "require": { - "php": ">=7.1.0" + "php": ">=7.1.3" }, "require-dev": { - "phpunit/phpunit": "~6.4", - "squizlabs/php_codesniffer": "~3.1" + "friendsofphp/php-cs-fixer": "^2.15", + "johnkary/phpunit-speedtrap": "^3.1", + "phpstan/phpstan": "^0.11", + "phpstan/phpstan-phpunit": "^0.11", + "phpunit/phpunit": "~7.5", + "slam/phpstan-extensions": "^3.4", + "squizlabs/php_codesniffer": "~3.1", + "thecodingmachine/phpstan-strict-rules": "^0.11" }, "autoload": { "psr-4": { diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..924a7c2 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + ./src/ + ./tests/ + + + + + + + + error + + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..7bef421 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,11 @@ +includes: + - 'vendor/phpstan/phpstan-phpunit/extension.neon' + - 'vendor/phpstan/phpstan-phpunit/rules.neon' + - 'vendor/slam/phpstan-extensions/conf/slam-rules.neon' +parameters: + level: 7 + excludes_analyse: + - '%rootDir%/../../../tests/*' + - '%rootDir%/../../../vendor/*' + fileExtensions: + - 'php' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b2f71cf..559ae74 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,12 @@ - + ./tests/ diff --git a/src/RussianToEnglish.php b/src/RussianToEnglish.php index 26be14f..2c7593c 100644 --- a/src/RussianToEnglish.php +++ b/src/RussianToEnglish.php @@ -1,6 +1,4 @@ 'a', 'б' => 'b', @@ -102,7 +102,7 @@ public static function transliterate(string $russianText): string { $transliteratedText = ''; - if (\mb_strlen($russianText) > 0) { + if ('' !== $russianText) { $transliteratedText = \str_replace( \array_keys(self::RUSSIAN_TO_ENGLISH_RULES), \array_values(self::RUSSIAN_TO_ENGLISH_RULES), diff --git a/src/Transliterator.php b/src/Transliterator.php index 556cce8..423e985 100644 --- a/src/Transliterator.php +++ b/src/Transliterator.php @@ -1,6 +1,4 @@ 'A', 'Б' => 'B', @@ -104,7 +104,7 @@ public static function transliterate(string $ukrainianText): string { $transliteratedText = ''; - if (\mb_strlen($ukrainianText) > 0) { + if ('' !== $ukrainianText) { if (self::checkForZghException($ukrainianText)) { $ukrainianText = \str_replace(['Зг', 'зг'], ['Zgh', 'zgh'], $ukrainianText); } diff --git a/tests/RussianToEnglishTest.php b/tests/RussianToEnglishTest.php index 59ddd5e..cd5d218 100644 --- a/tests/RussianToEnglishTest.php +++ b/tests/RussianToEnglishTest.php @@ -1,6 +1,4 @@ assertEquals($transliteratedText, $this->transliterator->ruToEn($russianText)); + self::assertEquals($transliteratedText, $this->transliterator->ruToEn($russianText)); } public function alphabetProvider(): array diff --git a/tests/UkrainianToEnglishTest.php b/tests/UkrainianToEnglishTest.php index d64b4dd..caa9bbc 100644 --- a/tests/UkrainianToEnglishTest.php +++ b/tests/UkrainianToEnglishTest.php @@ -1,6 +1,4 @@ assertEquals($transliteratedText, $this->transliterator->ukToEn($ukrainianText)); }