Skip to content

Commit

Permalink
Refactoring + update vendors (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
fre5h committed Jun 14, 2019
1 parent 801b49d commit 7e62077
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 5 additions & 5 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
25 changes: 13 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- [email protected]
email:
- [email protected]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
26 changes: 26 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<ruleset name="Stfalcon Codding Standard"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="utf-8"/>
<arg name="colors"/>
<arg name="parallel" value="4"/>
<arg value="p"/>
<arg value="s"/>

<file>./src/</file>
<file>./tests/</file>

<rule ref="PSR2">
<exclude name="Generic.Files.LineLength"/>
</rule>

<!-- Don't hide tokenizer exceptions -->
<rule ref="Internal.Tokenizer.Exception">
<type>error</type>
</rule>
</ruleset>
11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.5/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Transliteration Test Suite">
<testsuite name="Transliteration Library Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
8 changes: 4 additions & 4 deletions src/RussianToEnglish.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Transliteration library
*
Expand All @@ -10,6 +8,8 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Fresh\Transliteration;

/**
Expand All @@ -23,7 +23,7 @@
*/
class RussianToEnglish implements TransliteratorInterface
{
/** @const array */
/** @const string[] */
private const RUSSIAN_TO_ENGLISH_RULES = [
'а' => 'a',
'б' => 'b',
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/Transliterator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Transliteration library
*
Expand All @@ -10,6 +8,8 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Fresh\Transliteration;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/TransliteratorInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Transliteration library
*
Expand All @@ -10,6 +8,8 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Fresh\Transliteration;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/UkrainianToEnglish.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Transliteration library
*
Expand All @@ -10,6 +8,8 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Fresh\Transliteration;

/**
Expand All @@ -24,7 +24,7 @@
*/
class UkrainianToEnglish implements TransliteratorInterface
{
/** @const array */
/** @const string[] */
private const UKRAINIAN_TO_ENGLISH_RULES = [
'А' => 'A',
'Б' => 'B',
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/RussianToEnglishTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Transliteration library
*
Expand All @@ -10,6 +8,8 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Tests\Fresh\Transliteration;

use Fresh\Transliteration\Transliterator;
Expand All @@ -35,9 +35,9 @@ public function setUp()
/**
* @dataProvider alphabetProvider
*/
public function testTransliterationFromRussianToEnglish(string $russianText, string $transliteratedText)
public function testTransliterationFromRussianToEnglish(string $russianText, string $transliteratedText): void
{
$this->assertEquals($transliteratedText, $this->transliterator->ruToEn($russianText));
self::assertEquals($transliteratedText, $this->transliterator->ruToEn($russianText));
}

public function alphabetProvider(): array
Expand Down
6 changes: 3 additions & 3 deletions tests/UkrainianToEnglishTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

declare(strict_types=1);
/*
* This file is part of the Transliteration library
*
Expand All @@ -10,6 +8,8 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Tests\Fresh\Transliteration;

use Fresh\Transliteration\Transliterator;
Expand All @@ -35,7 +35,7 @@ public function setUp()
* @dataProvider officialExamplesProvider
* @dataProvider sentencesProvider
*/
public function testTransliterationFromUkrainianToEnglish(string $ukrainianText, string $transliteratedText)
public function testTransliterationFromUkrainianToEnglish(string $ukrainianText, string $transliteratedText): void
{
$this->assertEquals($transliteratedText, $this->transliterator->ukToEn($ukrainianText));
}
Expand Down

0 comments on commit 7e62077

Please sign in to comment.