diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45e8be0..1786076 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2', '7.4', '8.0'] + php-version: ['7.2', '7.4', '8.0', '8.1'] prefer-lowest: [''] include: - php-version: '7.2' @@ -49,7 +49,7 @@ jobs: - name: Composer install run: | - if [[ ${{ matrix.php-version }} == '8.0' ]]; then + if [[ ${{ matrix.php-version }} == '8.0' || ${{ matrix.php-version }} == '8.1' ]]; then composer install --ignore-platform-reqs elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then composer update --prefer-lowest --prefer-stable @@ -59,14 +59,14 @@ jobs: - name: Run PHPUnit run: | - if [[ ${{ matrix.php-version }} == '7.4' ]]; then + if [[ ${{ matrix.php-version }} == '8.1' ]]; then vendor/bin/phpunit --coverage-clover=coverage.xml else vendor/bin/phpunit fi - name: Code Coverage Report - if: success() && matrix.php-version == '7.4' + if: success() && matrix.php-version == '8.1' uses: codecov/codecov-action@v1 cs-stan: @@ -84,16 +84,18 @@ jobs: php-version: '7.4' extensions: mbstring, intl coverage: none - tools: psalm:~4.1.0, phpstan:^0.12 - name: Composer Install run: composer install + - name: Install tools + run: composer stan-setup + - name: Run phpcs run: vendor/bin/phpcs -p src/ tests/ - name: Run psalm - run: psalm --output-format=github + run: vendor/bin/psalm.phar --output-format=github - name: Run phpstan - run: phpstan analyse + run: vendor/bin/phpstan.phar analyse --error-format=github diff --git a/composer.json b/composer.json index 281d053..c5bafca 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "source": "https://github.com/markstory/mini-asset" }, "require": { - "php": ">=7.2", + "php": ">=7.2,<8.2", "league/climate": "~3.0" }, "require-dev": { @@ -54,9 +54,9 @@ "cs-check": "phpcs -p src/ tests/TestCase/", "cs-fix": "phpcbf src/ tests/TestCase/", "test": "phpunit --stderr", - "stan": "phpstan analyse src/ && psalm --show-info=false", "stan-test": "phpstan analyse tests/", - "psalm": "psalm", - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 vimeo/psalm:^4.1.0 && mv composer.backup composer.json" + "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^1.5 psalm/phar:~4.22.0 && mv composer.backup composer.json", + "stan": "phpstan analyse src/ && psalm.phar --show-info=false", + "psalm": "psalm.phar --show-info=false" } } diff --git a/phpstan.neon b/phpstan.neon index 71c735a..19de79a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,10 +5,6 @@ parameters: paths: - src/ ignoreErrors: - - - message: "#^Function jsmin not found.#" - count: 1 - path: src/Filter/JsMinFilter.php - message: "#^Call to method minify\\(\\) on an unknown class.*#" count: 2 diff --git a/psalm.xml b/psalm.xml index 42c31eb..80f1fd0 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,5 @@ filters); diff --git a/src/Filter/PipeInputFilter.php b/src/Filter/PipeInputFilter.php index 645f45b..527f760 100644 --- a/src/Filter/PipeInputFilter.php +++ b/src/Filter/PipeInputFilter.php @@ -55,12 +55,12 @@ public function hasDependencies() return $this->_settings['dependencies']; } - public function getDependencies(AssetTarget $file) + public function getDependencies(AssetTarget $target) { if ($this->_settings['dependencies']) { $this->optionalDependencyPrefix = $this->_settings['optional_dependency_prefix']; - return $this->getCssDependencies($file); + return $this->getCssDependencies($target); } return []; diff --git a/src/Output/AssetWriter.php b/src/Output/AssetWriter.php index 0c86264..4c22ea3 100644 --- a/src/Output/AssetWriter.php +++ b/src/Output/AssetWriter.php @@ -188,8 +188,8 @@ public function getTimestamp(AssetTarget $build) */ protected function _readTimestamp() { - $data = array(); - if (empty($data) && file_exists($this->path . static::BUILD_TIME_FILE)) { + $data = []; + if (file_exists($this->path . static::BUILD_TIME_FILE)) { $data = file_get_contents($this->path . static::BUILD_TIME_FILE); if ($data) { $data = unserialize($data); diff --git a/tests/TestCase/Cli/ClearTaskTest.php b/tests/TestCase/Cli/ClearTaskTest.php index bef5025..710ed57 100644 --- a/tests/TestCase/Cli/ClearTaskTest.php +++ b/tests/TestCase/Cli/ClearTaskTest.php @@ -96,7 +96,7 @@ public function testMainClearsManagedFiles() $this->task->main(['clear', '--config', APP . 'config/integration.ini']); foreach ($files as $file) { - $this->assertFileNotExists($file, "$file was not cleared"); + $this->assertFalse(file_exists($file), "$file was not cleared"); } } diff --git a/tests/TestCase/Filter/ClosureJsTest.php b/tests/TestCase/Filter/ClosureJsTest.php index 970e410..937bcfa 100644 --- a/tests/TestCase/Filter/ClosureJsTest.php +++ b/tests/TestCase/Filter/ClosureJsTest.php @@ -22,21 +22,25 @@ class ClosureJsTest extends TestCase public function testCommand() { $filter = $this->getMockBuilder('MiniAsset\Filter\ClosureJs') - ->setMethods(['_findExecutable', '_runCmd']) + ->onlyMethods(['_findExecutable', '_runCmd']) ->getMock(); - $filter->expects($this->at(0)) + $filter->expects($this->any()) ->method('_findExecutable') ->will($this->returnValue('closure/compiler.jar')); - $filter->expects($this->at(1)) + $filter->expects($this->once()) ->method('_runCmd') ->with($this->matchesRegularExpression('/java -jar "closure\/compiler\.jar" --js=(.*)\/CLOSURE(.*) --warning_level="QUIET"/')); $filter->output('file.js', 'var a = 1;'); - $filter->expects($this->at(0)) + + $filter = $this->getMockBuilder('MiniAsset\Filter\ClosureJs') + ->onlyMethods(['_findExecutable', '_runCmd']) + ->getMock(); + $filter->expects($this->any()) ->method('_findExecutable') ->will($this->returnValue('closure/compiler.jar')); - $filter->expects($this->at(1)) + $filter->expects($this->once()) ->method('_runCmd') ->with($this->matchesRegularExpression('/java -jar "closure\/compiler\.jar" --js=(.*)\/CLOSURE(.*) --warning_level="QUIET" --language_in="ECMASCRIPT5"/')); $filter->settings(array('language_in' => 'ECMASCRIPT5'));