Skip to content

Commit

Permalink
Merge pull request #68 from markstory/fix-php81
Browse files Browse the repository at this point in the history
Fix PHP8 deprecations and update deprecated usage of PHPUnit
  • Loading branch information
markstory authored Jun 10, 2022
2 parents d59f254 + d4fd0c2 commit 0542e03
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
}
}
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
1 change: 1 addition & 0 deletions src/Filter/FilterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function output($target, $content)
*
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->filters);
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/PipeInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
4 changes: 2 additions & 2 deletions src/Output/AssetWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Cli/ClearTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
14 changes: 9 additions & 5 deletions tests/TestCase/Filter/ClosureJsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 0542e03

Please sign in to comment.