diff --git a/.travis.yml b/.travis.yml index bfab435..0d6e44e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,15 @@ language: php -sudo: false php: - 7.2 - 7.3 - - 7.4snapshot + - 7.4 cache: directories: - vendor - $HOME/.composer/cache -matrix: - fast_finish: true - 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; @@ -26,13 +22,14 @@ script: - ./vendor/bin/phpunit; jobs: + fast_finish: true include: - stage: Test name: Lowest dependencies php: 7.2 install: composer update --prefer-dist --prefer-lowest - - stage: Test + - stage: Code Quality name: Code coverage php: 7.2 before_script: @@ -46,10 +43,13 @@ jobs: - stage: Code Quality name: Static analysis php: 7.2 - install: composer global require --dev phpstan/phpstan ^0.11 vimeo/psalm ^3.7; + install: + - composer update + - composer global require --dev phpstan/phpstan ^0.12 vimeo/psalm ^3.11 phpmetrics/phpmetrics ^2.6; script: - - ~/.composer/vendor/bin/phpstan analyse -l max -c phpstan.neon src tests --no-progress --no-interaction; + - ~/.composer/vendor/bin/phpstan analyse -c phpstan.neon --no-progress --no-interaction; - ~/.composer/vendor/bin/psalm --show-info=false + - ~/.composer/vendor/bin/phpmetrics --exclude=Exception src - stage: Code Quality name: Coding standards diff --git a/composer.json b/composer.json index faee90e..2e351e6 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "license": "MIT", "require": { "php": ">=7.2.0", - "koriym/psr4list": "^1.0" + "koriym/psr4list": "^1.0.2" }, "autoload":{ "psr-4":{ diff --git a/phpstan.neon b/phpstan.neon index e69de29..06dfd19 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -0,0 +1,8 @@ +parameters: + level: max + paths: + - src + - tests + excludes_analyse: + - */tests/*/tmp/* + - */tests/Fake/* diff --git a/psalm.xml b/psalm.xml index 42f355b..e1c8ce1 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,10 +1,10 @@ @@ -12,44 +12,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/AbstractAppMeta.php b/src/AbstractAppMeta.php index 4437bc8..2836268 100644 --- a/src/AbstractAppMeta.php +++ b/src/AbstractAppMeta.php @@ -30,6 +30,9 @@ abstract class AbstractAppMeta */ public $logDir; + /** + * @return \Generator + */ public function getResourceListGenerator() : \Generator { $list = new Psr4List; @@ -39,15 +42,18 @@ public function getResourceListGenerator() : \Generator /** * @param string $scheme 'app' | 'page' | '*' + * + * @return \Generator */ public function getGenerator(string $scheme = '*') : \Generator { foreach ($this->getResourceListGenerator() as list($class, $file)) { $paths = explode('\\', $class); + /** @var array $paths */ $path = array_slice($paths, 3); array_walk($path, [$this, 'camel2kebab']); if ($scheme === '*') { - $uri = sprintf('%s://self/%s', $path[0], implode('/', array_slice($path, 1))); + $uri = sprintf('%s://self/%s', (string) $path[0], implode('/', array_slice($path, 1))); yield new ResMeta($uri, $class, $file); } diff --git a/tests/AppMetaTest.php b/tests/AppMetaTest.php index a3cd719..955ed4d 100644 --- a/tests/AppMetaTest.php +++ b/tests/AppMetaTest.php @@ -30,14 +30,14 @@ protected function tearDown() : void chmod(__DIR__ . '/Fake/fake-not-writable/var', 0777); } - public function testNew() + public function testNew() : void { $actual = $this->appMeta; $this->assertInstanceOf('\BEAR\AppMeta\Meta', $actual); $this->assertFileExists($this->appMeta->tmpDir); } - public function testAppReflectorResourceList() + public function testAppReflectorResourceList() : void { $appMeta = new Meta('FakeVendor\HelloWorld'); $classes = $files = []; @@ -64,32 +64,32 @@ public function testAppReflectorResourceList() $this->assertSame($expect, $files); } - public function testInvalidName() + public function testInvalidName() : void { $this->expectException(AppNameException::class); new Meta('Invalid\Invalid'); } - public function testNotWritable() + public function testNotWritable() : void { $this->expectException(NotWritableException::class); new Meta('FakeVendor\NotWritable'); } - public function testVarTmpFolderCreation() + public function testVarTmpFolderCreation() : void { new Meta('FakeVendor\HelloWorld', 'stage-app'); $this->assertFileExists(__DIR__ . '/Fake/fake-app/var/log/stage-app'); $this->assertFileExists(__DIR__ . '/Fake/fake-app/var/tmp/stage-app'); } - public function testDoNotClear() + public function testDoNotClear() : void { new Meta('FakeVendor\HelloWorld', 'test-app'); $this->assertFileExists(__DIR__ . '/Fake/fake-app/var/tmp/test-app/not-cleared.txt'); } - public function testGetGeneratorApp() + public function testGetGeneratorApp() : void { $appMeta = new Meta('FakeVendor\HelloWorld'); $uris = []; @@ -102,7 +102,7 @@ public function testGetGeneratorApp() $this->assertContains('tests/Fake/fake-app/src/Resource/App/One.php', $uris[0]->filePath); } - public function testGetGeneratorAll() + public function testGetGeneratorAll() : void { $appMeta = new Meta('FakeVendor\HelloWorld'); $uris = []; diff --git a/tests/MetaTest.php b/tests/MetaTest.php index dc8a02a..e0784aa 100644 --- a/tests/MetaTest.php +++ b/tests/MetaTest.php @@ -29,14 +29,14 @@ protected function tearDown() : void chmod(__DIR__ . '/Fake/fake-not-writable/var', 0777); } - public function testNew() + public function testNew() : void { $actual = $this->meta; $this->assertInstanceOf(Meta::class, $actual); $this->assertFileExists($this->meta->tmpDir); } - public function testAppReflectorResourceList() + public function testAppReflectorResourceList() : void { $Meta = new Meta('FakeVendor\HelloWorld'); $classes = $files = []; @@ -63,26 +63,26 @@ public function testAppReflectorResourceList() $this->assertSame($expect, $files); } - public function testInvalidName() + public function testInvalidName() : void { $this->expectException(AppNameException::class); new Meta('Invalid\Invalid'); } - public function testNotWritable() + public function testNotWritable() : void { $this->expectException(NotWritableException::class); new Meta('FakeVendor\NotWritable'); } - public function testVarTmpFolderCreation() + public function testVarTmpFolderCreation() : void { new Meta('FakeVendor\HelloWorld', 'stage-app'); $this->assertFileExists(__DIR__ . '/Fake/fake-app/var/log/stage-app'); $this->assertFileExists(__DIR__ . '/Fake/fake-app/var/tmp/stage-app'); } - public function testDoNotClear() + public function testDoNotClear() : void { new Meta('FakeVendor\HelloWorld', 'test-app'); $this->assertFileExists(__DIR__ . '/Fake/fake-app/var/tmp/test-app/not-cleared.txt');