Skip to content

Commit

Permalink
Merge pull request #25 from bearsunday/php7.4
Browse files Browse the repository at this point in the history
Support php 7.4 and drop EOL php 7.1
  • Loading branch information
koriym authored Dec 4, 2019
2 parents 17417a1 + c5a0575 commit 1999aa4
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 61 deletions.
62 changes: 32 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: php
sudo: false

php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot

cache:
directories:
Expand All @@ -16,6 +16,7 @@ matrix:

before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
- composer self-update

install:
Expand All @@ -26,32 +27,33 @@ script:

jobs:
include:
- stage: Test
name: Lowest dependencies
php: 7.2
install: composer update --prefer-dist --prefer-lowest

- stage: Test
name: Code coverage
php: 7.2
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 -v --coverage-clover ./build/logs/clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover;

- stage: Code Quality
name: Static analysis
php: 7.2
install: composer require --dev phpstan/phpstan-shim ^0.11;
script:
- ./vendor/bin/phpstan analyse -l max -c phpstan.neon src tests --no-progress --no-interaction;

- stage: Code Quality
name: Coding standards
php: 7.2
install: composer require --dev friendsofphp/php-cs-fixer ^2.0;
script:
- ./vendor/bin/php-cs-fixer --dry-run -v fix;
- stage: Test
name: Lowest dependencies
php: 7.2
install: composer update --prefer-dist --prefer-lowest

- stage: Test
name: Code coverage
php: 7.2
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 -v --coverage-clover ./build/logs/clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover;

- stage: Code Quality
name: Static analysis
php: 7.2
install: composer global require --dev phpstan/phpstan ^0.11 vimeo/psalm ^3.7;
script:
- ~/.composer/vendor/bin/phpstan analyse -l max -c phpstan.neon src tests --no-progress --no-interaction;
- ~/.composer/vendor/bin/psalm --show-info=false

- stage: Code Quality
name: Coding standards
php: 7.2
install: composer global require --dev friendsofphp/php-cs-fixer ^2.0;
script:
- ~/.composer/vendor/bin/php-cs-fixer --dry-run -v fix;
31 changes: 9 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"license": "MIT",
"require": {
"php": ">=7.1.0",
"php": ">=7.2.0",
"koriym/psr4list": "^1.0"
},
"autoload":{
Expand All @@ -23,27 +23,14 @@
},
"require-dev": {
"bear/resource": "^1.0",
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^7.5"
},
"scripts" : {
"test": [
"phpunit"
],
"tests": [
"@cs",
"phpstan analyse -l max src tests -c phpstan.neon --no-progress",
"@test"
],
"coverage": [
"php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"
],
"cs": [
"php-cs-fixer fix -v --dry-run",
"phpcs --standard=./phpcs.xml src"
],
"cs-fix": [
"php-cs-fixer fix -v",
"phpcbf src"
]
"scripts" :{
"test": ["phpunit"],
"tests": ["@cs", "phpstan analyse -l max src tests -c phpstan.neon --no-progress", "psalm --show-info=false", "@test"],
"coverage": ["php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"],
"cs": ["php-cs-fixer fix -v --dry-run", "phpcs --standard=./phpcs.xml src"],
"cs-fix": ["php-cs-fixer fix -v", "phpcbf src"],
"metrics": ["phpmetrics --report-html=build/metrics/ --extensions=php src,composer.json,composer.lock"]
}
}
55 changes: 55 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/AbstractAppMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getGenerator(string $scheme = '*') : \Generator
}
}

private function camel2kebab(string &$str)
private function camel2kebab(string &$str) : void
{
$str = ltrim(strtolower((string) preg_replace('/[A-Z]/', '-\0', $str)), '-');
}
Expand Down
19 changes: 11 additions & 8 deletions src/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use BEAR\AppMeta\Exception\AppNameException;
use BEAR\AppMeta\Exception\NotWritableException;

/**
* Application Meta-Data
*/
class Meta extends AbstractAppMeta
{
/**
Expand All @@ -20,11 +17,7 @@ class Meta extends AbstractAppMeta
public function __construct(string $name, string $context = 'app', string $appDir = '')
{
$this->name = $name;
try {
$this->appDir = $appDir ?: dirname((string) (new \ReflectionClass($name . '\Module\AppModule'))->getFileName(), 3);
} catch (\ReflectionException $e) {
throw new AppNameException($name);
}
$this->appDir = $appDir ?: $this->getAppDir($name);
$this->tmpDir = $this->appDir . '/var/tmp/' . $context;
if (! file_exists($this->tmpDir) && ! @mkdir($this->tmpDir, 0777, true) && ! is_dir($this->tmpDir)) {
throw new NotWritableException($this->tmpDir);
Expand All @@ -34,4 +27,14 @@ public function __construct(string $name, string $context = 'app', string $appDi
throw new NotWritableException($this->logDir);
}
}

private function getAppDir(string $name) : string
{
$module = $name . '\Module\AppModule';
if (! class_exists($module)) {
throw new AppNameException($name);
}

return dirname((string) (new \ReflectionClass($module))->getFileName(), 3);
}
}

0 comments on commit 1999aa4

Please sign in to comment.