diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 181bf27..5563f30 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -6,8 +6,8 @@ on: pull_request: paths-ignore: ["**.md"] -env: - COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist +permissions: + contents: read jobs: tests: @@ -40,29 +40,16 @@ jobs: experimental: true steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install PHP - uses: shivammathur/setup-php@v2 + - uses: shivammathur/setup-php@v2 with: - coverage: none - php-version: ${{ matrix.php-version }} + php-version: "${{ matrix.php-version }}" + coverage: xdebug - - name: Get composer cache directory - id: composercache - shell: bash - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Restore cached dependencies - uses: actions/cache@v4 + - uses: ramsey/composer-install@v3 with: - path: ${{ steps.composercache.outputs.dir }} - key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: php-${{ matrix.php-version }}-composer- - - - name: Install latest dependencies - run: composer update ${{ env.COMPOSER_FLAGS }} + dependency-versions: highest - name: Run tests if: ${{ !matrix.experimental }} diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 6e579f1..47b6442 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -6,8 +6,8 @@ on: pull_request: paths-ignore: ["**.md"] -env: - COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist +permissions: + contents: read jobs: tests: @@ -35,29 +35,16 @@ jobs: experimental: true steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install PHP - uses: shivammathur/setup-php@v2 + - uses: shivammathur/setup-php@v2 with: - coverage: xdebug - php-version: ${{ matrix.php-version }} + php-version: "${{ matrix.php-version }}" + coverage: none - - name: Get composer cache directory - id: composercache - shell: bash - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Restore cached dependencies - uses: actions/cache@v4 + - uses: ramsey/composer-install@v3 with: - path: ${{ steps.composercache.outputs.dir }} - key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: php-${{ matrix.php-version }}-composer- - - - name: Install latest dependencies - run: composer update ${{ env.COMPOSER_FLAGS }} + dependency-versions: highest - name: Run tests if: ${{ !matrix.experimental }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f8a83dc..3071c10 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,9 +6,12 @@ on: pull_request: paths-ignore: ["**.md"] +permissions: + contents: read + jobs: tests: - name: Lint + name: "Lint" runs-on: ubuntu-latest @@ -16,17 +19,27 @@ jobs: matrix: php-version: - "7.2" - - "latest" + - "nightly" steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install PHP - uses: shivammathur/setup-php@v2 + - uses: shivammathur/setup-php@v2 with: + php-version: "${{ matrix.php-version }}" coverage: none - php-version: ${{ matrix.php-version }} - - name: Lint PHP files - run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f" + - name: "Lint PHP files" + run: | + hasErrors=0 + for f in $(find src/ tests/ -type f -name '*.php' ! -path '*/vendor/*' ! -path '*/Fixtures/*') + do + { error="$(php -derror_reporting=-1 -ddisplay_errors=1 -l -f $f 2>&1 1>&3 3>&-)"; } 3>&1; + if [ "$error" != "" ]; then + while IFS= read -r line; do echo "::error file=$f::$line"; done <<< "$error" + hasErrors=1 + fi + done + if [ $hasErrors -eq 1 ]; then + exit 1 + fi diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 5cec80a..8af542c 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -6,8 +6,8 @@ on: pull_request: paths-ignore: ["**.md"] -env: - COMPOSER_FLAGS: --ansi --no-interaction --no-progress --prefer-dist +permissions: + contents: read jobs: tests: @@ -21,29 +21,16 @@ jobs: - "8.1" steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install PHP - uses: shivammathur/setup-php@v2 + - uses: shivammathur/setup-php@v2 with: + php-version: "${{ matrix.php-version }}" coverage: none - php-version: ${{ matrix.php-version }} - - name: Get composer cache directory - id: composercache - shell: bash - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Restore cached dependencies - uses: actions/cache@v4 + - uses: ramsey/composer-install@v3 with: - path: ${{ steps.composercache.outputs.dir }} - key: php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: php-${{ matrix.php-version }}-composer - - - name: Install latest dependencies - run: composer update ${{ env.COMPOSER_FLAGS }} + dependency-versions: highest - name: Run PHPStan run: vendor/bin/phpstan analyse diff --git a/composer.json b/composer.json index d205dc1..d87d7e3 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "composer/pcre": "^1 || ^2 || ^3" }, "require-dev": { - "phpstan/phpstan": "^1.0", + "phpstan/phpstan": "^1.11", "phpstan/phpstan-strict-rules": "^1.1", "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" }, diff --git a/tests/App/Framework/Logger.php b/tests/App/Framework/Logger.php index a0fb1b5..07b36b8 100644 --- a/tests/App/Framework/Logger.php +++ b/tests/App/Framework/Logger.php @@ -28,6 +28,7 @@ public function __construct(Output $output) /** * @inheritdoc * @phpstan-param mixed[] $context + * @param string|\Stringable $message */ public function log($level, $message, array $context = array()): void { diff --git a/tests/App/Framework/Logs.php b/tests/App/Framework/Logs.php index 148f671..4d4974a 100644 --- a/tests/App/Framework/Logs.php +++ b/tests/App/Framework/Logs.php @@ -31,7 +31,8 @@ public function __construct(array $outputLines) foreach ($outputLines as $line) { $line = trim($line); - if (!(bool) preg_match('/^(.+)\\[(\\d+)\\](.+)$/', $line, $matches)) { + // @phpstan-ignore booleanNot.exprNotBoolean + if (!preg_match('/^(.+)\\[(\\d+)\\](.+)$/', $line, $matches)) { continue; } diff --git a/tests/Helpers/Logger.php b/tests/Helpers/Logger.php index d898921..5fadbd7 100644 --- a/tests/Helpers/Logger.php +++ b/tests/Helpers/Logger.php @@ -24,6 +24,7 @@ class Logger extends AbstractLogger /** * @inheritdoc * @phpstan-param mixed[] $context + * @param string|\Stringable $message */ public function log($level, $message, array $context = []): void {