Skip to content

Commit

Permalink
Merge pull request #37 from heiglandreas/setPHP72AsDefault
Browse files Browse the repository at this point in the history
Set PHP 7.2 as default version
  • Loading branch information
heiglandreas committed Feb 9, 2018
2 parents acdd957 + ea5ea22 commit 233a361
Show file tree
Hide file tree
Showing 46 changed files with 797 additions and 485 deletions.
18 changes: 0 additions & 18 deletions .php_cs

This file was deleted.

91 changes: 34 additions & 57 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,48 @@
sudo: false
language: php

php:
- 7.0
- 7.1
- 7.2
- nightly

env:
- DEPS=lowest
- DEPS=locked
- DEPS=latest

matrix:
fast_finish : true
allow_failures:
- php: 5.3
- php: 5.4
- php: 5.5
- php: nightly
- php: hhvm
include:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=locked
- php: 5.6
env:
- DEPS=latest
- php: 7.0
env:
- DEPS=lowest
- php: 7.0
env:
- DEPS=locked
- php: 7.0
env:
- DEPS=latest
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
- php: 7.2
env:
- DEPS=locked
- TEST_COVERAGE=true
- CHECK_CS=false
- php: 7.1
env:
- DEPS=latest
- php: hhvm
env:
- DEPS=lowest
- php: hhvm
env:
- DEPS=locked
- php: hhvm
env:
- DEPS=latest
- php: nightly
env:
- DEPS=lowest
- php: nightly
env:
- DEPS=locked
- php: nightly
env:
- DEPS=latest

stages:
- check
- test

jobs:
include:
- stage: check
php: 7.2
script:
- composer cs-check
- stage: test
- stage: coverage
if: branch = master AND type = push
php: 7.2
env: TEST_COVERAGE=true
script:
after_script:
- travis_retry composer require $COMPOSER_ARGS --dev satooshi/php-coveralls ;
- composer test-coverage
- travis_retry composer upload-coverage

before_install:
- travis_retry composer self-update
Expand All @@ -70,14 +53,8 @@ before_install:
install:
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require $COMPOSER_ARGS --dev satooshi/php-coveralls ; fi
- travis_retry composer install $COMPOSER_ARGS
- composer show --installed

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
- if [[ $CHECK_CS == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer upload-coverage ; fi
- composer test
20 changes: 13 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"ext-mbstring" : "*"
},
"require-dev" : {
"mockery/mockery" : "^0.9",
"phpunit/phpunit": "^4.8||^5.3"
"mockery/mockery" : "^1.0",
"phpunit/phpunit": "^6.0"
},
"autoload" : {
"psr-4" : {
Expand All @@ -36,18 +36,24 @@
"@cs-check",
"@test"
],
"upload-coverage": "coveralls -v",
"upload-coverage": [
"curl -o coveralls -L https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar",
"chmod 755 coveralls",
"./coveralls -v"
],
"cs-download" : [
"curl -o php-cs-fixer -L `curl -s https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/releases | grep browser_download_url | head -n 1 | cut -d '\"' -f 4`",
"chmod 755 php-cs-fixer"
"curl -o phpcs -L https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.2.2/phpcs.phar",
"curl -o phpcs.asc -L https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.2.2/phpcs.phar.asc",
"# gpg --verify phpcs.asc phpcs",
"chmod 755 phpcs"
],
"cs-check": [
"@cs-download",
"./php-cs-fixer --version && ./php-cs-fixer fix -v --diff --dry-run"
"./phpcs --version && ./phpcs"
],
"cs-fix": [
"@cs-download",
"./php-cs-fixer fix -v"
"./phpcs"
],
"test": "phpunit",
"test-coverage": "phpunit --coverage-clover clover.xml"
Expand Down
113 changes: 113 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0"?>
<ruleset name="Hyphenator-Standard" namespace="Org\Heigl\Hyphenator\CS\Standard">

<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument.
If you have custom sniffs, and they use a namespace prefix
that is different to the name of the directory containing
your ruleset.xml file, you can set the namespace prefix using
the namespace attribute of the ruleset tag.
For example, if your namespace format for sniffs is
MyProject\CS\Standard\Sniffs\Category, set the namespace to
MyProject\CS\Standard (everything up to \Sniffs\)
-->

<!--
The content of the description tag is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
-->
<description>Coding Standard for the Hyphenator-Project</description>

<!--
You can hard-code config values used by sniffs directly
into your custom standard. Note that this does not work
for config values that override command line arguments,
such as show_warnings and report_format.
The following tag is equivalent to the command line argument:
-runtime-set zend_ca_path /path/to/ZendCodeAnalyzer
-->
<!--config name="zend_ca_path" value="/path/to/ZendCodeAnalyzer"/-->

<!--
If no files or directories are specified on the command line
your custom standard can specify what files should be checked
instead.
Note that file and directory paths specified in a ruleset are
relative to the ruleset's location, and that specifying any file or
directory path on the command line will ignore all file tags.
-->
<file>./src</file>
<file>./tests</file>

<!--
You can hard-code ignore patterns directly into your
custom standard so you don't have to specify the
patterns on the command line.
The following two tags are equivalent to the command line argument:
-ignore=*/tests/*,*/data/*
-->
<exclude-pattern>*/share/*</exclude-pattern>
<exclude-pattern>*/tools/*</exclude-pattern>
<exclude-pattern>*/bootstrap.php</exclude-pattern>

<!--
Patterns can be specified as relative if you would
like the relative path of the file checked instead of the
full path. This can sometimes help with portability.
The relative path is determined based on the paths you
pass into PHP_CodeSniffer on the command line.
-->
<!--exclude-pattern type="relative">^/tests/*</exclude-pattern>
<exclude-pattern type="relative">^/data/*</exclude-pattern-->

<!--
You can hard-code command line values into your custom standard.
Note that this does not work for the command line values:
-v[v][v], -l, -d, -sniffs and -standard
The following tags are equivalent to the command line arguments:
-report=summary -colors -sp
-->
<!--arg name="report" value="summary"/-->
<arg name="report" value="full"/>
<arg name="colors"/>
<arg value="sp"/>

<!--
You can hard-code custom php.ini settings into your custom standard.
The following tag sets the memory limit to 64M.
-->
<ini name="memory_limit" value="64M"/>

<!--
If your helper classes need custom autoloading rules that you are
not able to include in other ways, you can hard-code files to include
before the ruleset is processed and any sniff classes have been loaded.
This is different to bootstrap files, which are loaded after the ruleset
has already been processed.
-->
<!--autoload>/path/to/autoload.php</autoload>
<autoload>/path/to/other/autoload.php</autoload-->

<!--
Include all sniffs in the PEAR standard. Note that the
path to the standard does not have to be specified as the
PEAR standard exists inside the PHP_CodeSniffer install
directory.
-->
<rule ref="PSR2"/>

<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>src/Hyphenator.php</exclude-pattern>
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/Org/Heigl/Hyphenator/parsedFiles</directory>
<directory suffix=".php">src/share</directory>
</exclude>
</whitelist>
</filter>
Expand Down
28 changes: 14 additions & 14 deletions src/Dictionary/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ class Dictionary
/**
* The internal storage for the dictionary.
*
* @var array $_dictionary
* @var array $dictionary
*/
protected $_dictionary = array();
private $dictionary = array();

/**
* Where to look for the basic files.
*
* @var string $_fileLocation
*/
protected static $_fileLocation = '';
private static $fileLocation = '';

/**
* Set the file-location.
Expand All @@ -71,7 +71,7 @@ class Dictionary
*/
public static function setFileLocation($fileLocation)
{
self::$_fileLocation = $fileLocation;
self::$fileLocation = $fileLocation;
}

/**
Expand Down Expand Up @@ -107,14 +107,14 @@ public static function factory($locale)
*/
public function load($locale)
{
$locale = $this->_unifyLocale($locale);
$file = self::$_fileLocation . DIRECTORY_SEPARATOR . $locale . '.ini';
$this->_dictionary = array();
$locale = $this->unifyLocale($locale);
$file = self::$fileLocation . DIRECTORY_SEPARATOR . $locale . '.ini';
$this->dictionary = array();
if (! file_exists(realpath($file))) {
return $this;
}
foreach (parse_ini_file($file) as $key => $val) {
$this->_dictionary[str_replace('@:', '', $key)] = $val;
$this->dictionary[str_replace('@:', '', $key)] = $val;
}

return $this;
Expand All @@ -130,7 +130,7 @@ public function load($locale)
*/
public static function parseFile($locale)
{
$path = self::$_fileLocation . DIRECTORY_SEPARATOR;
$path = self::$fileLocation . DIRECTORY_SEPARATOR;
$file = $path . 'hyph_' . $locale . '.dic';
if (! file_Exists($file)) {
throw new \Org\Heigl\Hyphenator\Exception\PathNotFoundException('The given Path does not exist');
Expand Down Expand Up @@ -187,10 +187,10 @@ public function getPatternsForWord($word)
for ($i = 0; $i <= $strlen; $i ++) {
for ($j = 2; $j <= ($strlen-$i); $j++) {
$substr = mb_substr($word, $i, $j);
if (! isset($this->_dictionary[$substr])) {
if (! isset($this->dictionary[$substr])) {
continue;
}
$return[$substr] = $this->_dictionary[$substr];
$return[$substr] = $this->dictionary[$substr];
}
}

Expand All @@ -207,13 +207,13 @@ public function getPatternsForWord($word)
*/
public function addPAttern($string, $pattern)
{
$this->_dictionary[$string] = $pattern;
$this->dictionary[$string] = $pattern;

return $this;
}

/**
* Unify the given locale to a defsult format.
* Unify the given locale to a default format.
*
* For that in a 2 by 2 format the whole string is splited, the first part
* lowercased, the sewcond part upercased and concatenated with n under-
Expand All @@ -227,7 +227,7 @@ public function addPAttern($string, $pattern)
*
* @return string
*/
protected function _unifyLocale($locale)
private function unifyLocale($locale)
{
if (2 == strlen($locale)) {
return strtolower($locale);
Expand Down
Loading

0 comments on commit 233a361

Please sign in to comment.