Skip to content

Commit 7e62077

Browse files
authored
Refactoring + update vendors (#12)
1 parent 801b49d commit 7e62077

15 files changed

+95
-49
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
/.scrutinizer.yml export-ignore
77
/.styleci.yml export-ignore
88
/.travis.yml export-ignore
9+
/phpcs.xml export-ignore
10+
/phpstan.neon export-ignore
911
/phpunit.xml.dist export-ignore
1012
/tests export-ignore

.scrutinizer.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
checks:
2-
php: true
2+
php: true
33

44
filter:
5-
paths:
6-
- src/*
7-
excluded_paths:
8-
- vendor/*
9-
- tests/*
5+
paths:
6+
- src/*
7+
excluded_paths:
8+
- vendor/*
9+
- tests/*
1010

1111
before_commands:
12-
- "composer install --prefer-dist"
12+
- "composer install --prefer-dist"

.styleci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
preset: recommended
22

33
enabled:
4-
- combine_consecutive_unsets
5-
- linebreak_after_opening_tag
6-
- ordered_class_elements
7-
- unalign_double_arrow
4+
- combine_consecutive_unsets
5+
- linebreak_after_opening_tag
6+
- ordered_class_elements
7+
- unalign_double_arrow
88

99
disabled:
10-
- align_double_arrow
10+
- align_double_arrow
1111

1212
finder:
1313
exclude:

.travis.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ language: php
33
sudo: false
44

55
php:
6-
- 7.1
7-
- 7.2
8-
- 7.3
6+
- 7.1
7+
- 7.2
8+
- 7.3
99

1010
before_script:
11-
- composer self-update
11+
- composer self-update
1212

1313
install:
14-
- composer install --dev --no-interaction --prefer-dist
14+
- composer install --dev --no-interaction --prefer-dist
1515

1616
script:
17-
- ./vendor/bin/phpcs ./ -p --encoding=utf-8 --extensions=php --ignore=vendor --ignore=tests --standard=PSR2
18-
- ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml
17+
- ./vendor/bin/phpcs ./ -p --encoding=utf-8 --extensions=php --ignore=vendor --ignore=tests --standard=phpcs.xml
18+
- ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml
19+
- ./vendor/bin/phpstan analyse -l 7 --no-progress -c phpstan.neon ./
1920

2021
after_success:
21-
- bash <(curl -s https://codecov.io/bash)
22+
- bash <(curl -s https://codecov.io/bash)
2223

2324
cache:
24-
directories:
25-
- $COMPOSER_CACHE_DIR
25+
directories:
26+
- $COMPOSER_CACHE_DIR
2627

2728
notifications:
28-
email:
29-
- genvaldartem@gmail.com
29+
email:
30+
- genvaldartem@gmail.com

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PHP library for transliteration. 🇺🇦 :uk: :ru: :abcd:
1515

1616
## Requirements
1717

18-
* PHP 7.1 *and later*
18+
* PHP 7.1.3 *and later*
1919

2020
## Install via Composer
2121

composer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
"issues": "https://github.com/fre5h/transliteration/issues"
1818
},
1919
"require": {
20-
"php": ">=7.1.0"
20+
"php": ">=7.1.3"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "~6.4",
24-
"squizlabs/php_codesniffer": "~3.1"
23+
"friendsofphp/php-cs-fixer": "^2.15",
24+
"johnkary/phpunit-speedtrap": "^3.1",
25+
"phpstan/phpstan": "^0.11",
26+
"phpstan/phpstan-phpunit": "^0.11",
27+
"phpunit/phpunit": "~7.5",
28+
"slam/phpstan-extensions": "^3.4",
29+
"squizlabs/php_codesniffer": "~3.1",
30+
"thecodingmachine/phpstan-strict-rules": "^0.11"
2531
},
2632
"autoload": {
2733
"psr-4": {

phpcs.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Stfalcon Codding Standard"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
5+
>
6+
<arg name="basepath" value="."/>
7+
<arg name="cache" value=".phpcs-cache"/>
8+
<arg name="extensions" value="php"/>
9+
<arg name="encoding" value="utf-8"/>
10+
<arg name="colors"/>
11+
<arg name="parallel" value="4"/>
12+
<arg value="p"/>
13+
<arg value="s"/>
14+
15+
<file>./src/</file>
16+
<file>./tests/</file>
17+
18+
<rule ref="PSR2">
19+
<exclude name="Generic.Files.LineLength"/>
20+
</rule>
21+
22+
<!-- Don't hide tokenizer exceptions -->
23+
<rule ref="Internal.Tokenizer.Exception">
24+
<type>error</type>
25+
</rule>
26+
</ruleset>

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
includes:
2+
- 'vendor/phpstan/phpstan-phpunit/extension.neon'
3+
- 'vendor/phpstan/phpstan-phpunit/rules.neon'
4+
- 'vendor/slam/phpstan-extensions/conf/slam-rules.neon'
5+
parameters:
6+
level: 7
7+
excludes_analyse:
8+
- '%rootDir%/../../../tests/*'
9+
- '%rootDir%/../../../vendor/*'
10+
fileExtensions:
11+
- 'php'

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.4/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.5/phpunit.xsd"
55
colors="true"
66
bootstrap="vendor/autoload.php"
77
>
88
<testsuites>
9-
<testsuite name="Transliteration Test Suite">
9+
<testsuite name="Transliteration Library Test Suite">
1010
<directory>./tests/</directory>
1111
</testsuite>
1212
</testsuites>

src/RussianToEnglish.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
3-
declare(strict_types=1);
42
/*
53
* This file is part of the Transliteration library
64
*
@@ -10,6 +8,8 @@
108
* file that was distributed with this source code.
119
*/
1210

11+
declare(strict_types=1);
12+
1313
namespace Fresh\Transliteration;
1414

1515
/**
@@ -23,7 +23,7 @@
2323
*/
2424
class RussianToEnglish implements TransliteratorInterface
2525
{
26-
/** @const array */
26+
/** @const string[] */
2727
private const RUSSIAN_TO_ENGLISH_RULES = [
2828
'а' => 'a',
2929
'б' => 'b',
@@ -102,7 +102,7 @@ public static function transliterate(string $russianText): string
102102
{
103103
$transliteratedText = '';
104104

105-
if (\mb_strlen($russianText) > 0) {
105+
if ('' !== $russianText) {
106106
$transliteratedText = \str_replace(
107107
\array_keys(self::RUSSIAN_TO_ENGLISH_RULES),
108108
\array_values(self::RUSSIAN_TO_ENGLISH_RULES),

0 commit comments

Comments
 (0)