diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b65d22..3aeb474 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,21 +13,14 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.4', '8.0', '8.1'] composer-args: ['', '--prefer-lowest'] - include: - - operating-system: ubuntu-latest - php-versions: '8.0' - composer-args: '--ignore-platform-reqs --no-scripts' - - operating-system: ubuntu-latest - php-versions: '8.0' - composer-args: '--prefer-lowest --ignore-platform-reqs --no-scripts' runs-on: ${{ matrix.operating-system }} steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Setup PHP - uses: shivammathur/setup-php@2.10.0 + uses: shivammathur/setup-php@2.16.0 with: php-version: ${{ matrix.php-versions }} extensions: mbstring @@ -39,7 +32,7 @@ jobs: id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2.1.4 + uses: actions/cache@v2.1.7 with: path: ${{ steps.composer-cache.outputs.dir }} key: php${{ matrix.php-versions }}-composer-${{ matrix.composer-args }}-${{ hashFiles('**/composer.json') }} @@ -50,21 +43,14 @@ jobs: - name: PHPStan run: composer phpstan - name: Code Style Check + env: + PHP_CS_FIXER_IGNORE_ENV: true run: composer style-check -- --format=checkstyle | cs2pr - name: Test run: composer test-with-coverage - name: Upload Coverage - run: bash <(curl -s https://codecov.io/bash) -f ./clover.xml - merge-me: - name: Merge me! - needs: - - build - runs-on: ubuntu-latest - steps: - - name: Merge me! - uses: ridedott/merge-me-action@master + uses: codecov/codecov-action@v2 with: - # This must be used as GitHub Actions token does not support - # pushing to protected branches. - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_LOGIN: 'dependabot[bot]' + files: ./clover.xml + fail_ci_if_error: true + verbose: true diff --git a/.github/workflows/merge-me.yml b/.github/workflows/merge-me.yml new file mode 100644 index 0000000..c7559ae --- /dev/null +++ b/.github/workflows/merge-me.yml @@ -0,0 +1,32 @@ +name: Merge me! + +on: + workflow_run: + types: + - completed + workflows: + - 'Build' + +jobs: + merge-me: + name: Merge me! + runs-on: ubuntu-latest + steps: + - # It is often a desired behavior to merge only when a workflow execution + # succeeds. This can be changed as needed. + if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Merge me! + uses: ridedott/merge-me-action@v2 + with: + # Depending on branch protection rules, a manually populated + # `GITHUB_TOKEN_WORKAROUND` secret with permissions to push to + # a protected branch must be used. This secret can have an arbitrary + # name, as an example, this repository uses `DOTTBOTT_TOKEN`. + # + # When using a custom token, it is recommended to leave the following + # comment for other developers to be aware of the reasoning behind it: + # + # This must be used as GitHub Actions token does not support pushing + # to protected branches. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ENABLE_GITHUB_API_PREVIEW: true diff --git a/.gitignore b/.gitignore index 0c9c4f0..e5b8007 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /composer.lock /clover.xml .php_cs.cache -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 64% rename from .php_cs rename to .php-cs-fixer.php index e14f877..2ec4112 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -6,17 +6,16 @@ ->in(__DIR__) ; -return PhpCsFixer\Config::create() - ->setRiskyAllowed(true) +$config = new PhpCsFixer\Config(); +return $config->setRiskyAllowed(true) ->setRules(array( '@PSR2' => true, '@PHPUnit60Migration:risky' => true, - '@PHPUnit84Migration:risky' => true, - 'binary_operator_spaces' => array('align_double_arrow' => true, 'align_equals' => true), + 'binary_operator_spaces' => array('operators' => array('=' => 'align', '=>' => 'align')), 'single_quote' => true, 'array_syntax' => array('syntax' => 'long'), 'concat_space' => array('spacing' => 'one'), - 'psr0' => false + 'psr_autoloading' => array('dir' => 'src'), )) ->setUsingCache(true) ->setFinder($finder); diff --git a/composer.json b/composer.json index becd8db..ef531ff 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "homepage": "http://framework.zend.com/", "license": "BSD-3-Clause", "require": { - "php": "^7.0 || ^8.0", + "php": "^7.4 || ~8.0.0 || ~8.1.0", "diablomedia/zendframework1-exception": "^1.0.0", "diablomedia/zendframework1-config": "^1.0.0 || ^2.0.0", "diablomedia/zendframework1-loader": "^1.0.0" @@ -28,11 +28,11 @@ } }, "require-dev": { - "phpunit/phpunit": "^8.0", - "phpstan/phpstan": "0.12.82", - "friendsofphp/php-cs-fixer": "2.18.4", - "maglnet/composer-require-checker": "^1.1.0 || ^2.0.0", - "phpro/grumphp-shim": "^0.22.0 || ^1.1" + "phpunit/phpunit": "^9.5.10", + "phpstan/phpstan": "1.2.0", + "friendsofphp/php-cs-fixer": "3.3.2", + "maglnet/composer-require-checker": "^3.0.0", + "phpro/grumphp-shim": "^1.5.0" }, "archive": { "exclude": [ diff --git a/grumphp.yml.dist b/grumphp.yml.dist index 6e05858..70ff16c 100644 --- a/grumphp.yml.dist +++ b/grumphp.yml.dist @@ -7,7 +7,7 @@ grumphp: config_file: require-checker-config.json phpcsfixer2: allow_risky: true - config: .php_cs + config: .php-cs-fixer.php phpstan: configuration: phpstan.neon phpunit: diff --git a/phpstan.neon b/phpstan.neon index d4105d9..5461c9c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,7 @@ parameters: level: 8 paths: - ./ - excludes_analyse: + excludePaths: - ./tests/* - ./vendor/* bootstrapFiles: @@ -12,24 +12,26 @@ parameters: # Zend_Config has an __isset overload defined so that these array-like calls will work - '#Cannot access offset .+ on array\|Zend_Config\.#' # call_user_func does accept an array as the callable - - '#Parameter \#1 \$(function|callback) of function call_user_func expects callable\(\): mixed, array\(string, .factory.\) given\.#' + - + message: '#Parameter \#1 \$(function|callback) of function call_user_func expects callable\(\): mixed, array{string, .factory.} given\.#' + path: './src/Zend/Log.php' - message: '#Parameter \#2 \$priority of method Zend_Log::log\(\) expects int, int\|string given\.#' - path: %currentWorkingDirectory%/src/Zend/Log.php + path: './src/Zend/Log.php' - message: '#Cannot access offset int on array\|bool\.#' - path: %currentWorkingDirectory%/src/Zend/Log.php + path: './src/Zend/Log.php' - message: '#Property Zend_Log_Writer_Stream::\$_stream \(resource\|null\) does not accept resource\|false\.#' - path: %currentWorkingDirectory%/src/Zend/Log/Writer/Stream.php + path: './src/Zend/Log/Writer/Stream.php' - message: '#Parameter \#1 \$(fp|stream) of function fwrite expects resource, resource\|null given\.#' - path: %currentWorkingDirectory%/src/Zend/Log/Writer/Stream.php + path: './src/Zend/Log/Writer/Stream.php' # All of these are defensive coding in case an object isn't returned from _constructFromConfig (which is # possible, since it's a call_user_func return) - message: '#Else branch is unreachable because ternary operator condition is always true.#' - path: %currentWorkingDirectory%/src/Zend/Log.php + path: './src/Zend/Log.php' - message: '#Parameter \#1 \$(argument|objectOrClass) of class ReflectionClass constructor expects class-string\|T of object, string given\.#' path: ./src/Zend/Log.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2204d13..d55ddf3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,13 @@ - - - - ./tests - - - - - ./src - - + + + + + ./src + + + + + ./tests + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..2204d13 --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,19 @@ + + + + ./tests + + + + + ./src + + + diff --git a/tests/Zend/Log/Filter/MessageTest.php b/tests/Zend/Log/Filter/MessageTest.php index 938e119..6009fab 100644 --- a/tests/Zend/Log/Filter/MessageTest.php +++ b/tests/Zend/Log/Filter/MessageTest.php @@ -38,7 +38,7 @@ public function testMessageFilterRecognizesInvalidRegularExpression() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/invalid reg/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/invalid reg/i', $e->getMessage()); } } diff --git a/tests/Zend/Log/Filter/PriorityTest.php b/tests/Zend/Log/Filter/PriorityTest.php index 3eb273a..3621370 100644 --- a/tests/Zend/Log/Filter/PriorityTest.php +++ b/tests/Zend/Log/Filter/PriorityTest.php @@ -58,7 +58,7 @@ public function testConstructorThrowsOnInvalidPriority() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/must be an integer/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/must be an integer/i', $e->getMessage()); } } @@ -86,7 +86,7 @@ public function testFactory() ); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/must be an integer/', $e->getMessage()); + $this->assertMatchesRegularExpression('/must be an integer/', $e->getMessage()); } } } diff --git a/tests/Zend/Log/Formatter/SimpleTest.php b/tests/Zend/Log/Formatter/SimpleTest.php index a4f56c3..3d2c3d0 100644 --- a/tests/Zend/Log/Formatter/SimpleTest.php +++ b/tests/Zend/Log/Formatter/SimpleTest.php @@ -38,7 +38,7 @@ public function testConstructorThrowsOnBadFormatString() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/must be a string/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/must be a string/i', $e->getMessage()); } } diff --git a/tests/Zend/Log/LogTest.php b/tests/Zend/Log/LogTest.php index 30dd4dc..92d1a0e 100644 --- a/tests/Zend/Log/LogTest.php +++ b/tests/Zend/Log/LogTest.php @@ -94,7 +94,7 @@ public function testLoggerThrowsWhenNoWriters() $logger->log('message', Zend_Log::INFO); $this->fail(); } catch (Zend_Log_Exception $e) { - $this->assertRegExp('/no writer/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/no writer/i', $e->getMessage()); } } @@ -126,7 +126,7 @@ public function testLogThrowsOnBadLogPriority() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/bad log priority/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/bad log priority/i', $e->getMessage()); } } @@ -138,7 +138,7 @@ public function testLogThrough__callThrowsOnBadLogPriority() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/bad log priority/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/bad log priority/i', $e->getMessage()); } } @@ -150,7 +150,7 @@ public function testAddingPriorityThrowsWhenOverridingBuiltinLogPriority() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/existing priorities/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/existing priorities/i', $e->getMessage()); } } @@ -370,7 +370,7 @@ public function testExceptionConstructWriterFromConfig() $logger->addWriter($writer); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#^(Zend_Log_Writer_NotExtendedWriterAbstract|The\sspecified\swriter)#', $e->getMessage() ); @@ -388,7 +388,7 @@ public function testExceptionConstructFilterFromConfig() $logger->addFilter($filter); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp( + $this->assertMatchesRegularExpression( '#^(Zend_Log_Filter_NotImplementsFilterInterface|The\sspecified\sfilter)#', $e->getMessage() ); @@ -517,10 +517,6 @@ public function testFactoryShouldKeepDefaultTimestampFormat() */ public function testFactorySupportsPHP53Namespaces() { - if (version_compare(PHP_VERSION, '5.3.0') < 0) { - $this->markTestSkipped('PHP < 5.3.0 does not support namespaces'); - } - // preload namespaced class from custom path Zend_Loader::loadClass('\Zfns\Writer', array(dirname(__FILE__) . '/_files')); diff --git a/tests/Zend/Log/Writer/StreamTest.php b/tests/Zend/Log/Writer/StreamTest.php index c7ae3ae..6794371 100644 --- a/tests/Zend/Log/Writer/StreamTest.php +++ b/tests/Zend/Log/Writer/StreamTest.php @@ -39,7 +39,7 @@ public function testConstructorThrowsWhenResourceIsNotStream() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/not a stream/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/not a stream/i', $e->getMessage()); } catch (Throwable $e) { // PHP 8 throws a TypeError here $this->assertInstanceOf(TypeError::class, $e); @@ -72,7 +72,7 @@ public function testConstructorThrowsWhenModeSpecifiedForExistingStream() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/existing stream/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/existing stream/i', $e->getMessage()); } } @@ -83,7 +83,7 @@ public function testConstructorThrowsWhenStreamCannotBeOpened() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/cannot be opened/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/cannot be opened/i', $e->getMessage()); } catch (Throwable $e) { // PHP 8 throws a ValueError here $this->assertInstanceOf(ValueError::class, $e); @@ -116,7 +116,7 @@ public function testWriteThrowsWhenStreamWriteFails() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/unable to write/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/unable to write/i', $e->getMessage()); } } @@ -132,7 +132,7 @@ public function testShutdownClosesStreamResource() $this->fail(); } catch (Exception $e) { $this->assertTrue($e instanceof Zend_Log_Exception); - $this->assertRegExp('/unable to write/i', $e->getMessage()); + $this->assertMatchesRegularExpression('/unable to write/i', $e->getMessage()); } }