diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 681cfdd..eb3b7ae 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -14,131 +14,33 @@ on: # yamllint disable-line rule:truthy workflow_dispatch: jobs: - linter: - name: Linter - runs-on: ['ubuntu-latest'] - - steps: - - uses: actions/checkout@v4 - with: - # super-linter needs the full git history to get the - # list of files that changed across commits - fetch-depth: 0 - - - name: Lint Code Base - uses: super-linter/super-linter/slim@v7 - env: - SAVE_SUPER_LINTER_OUTPUT: false - # To report GitHub Actions status checks - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - LINTER_RULES_PATH: 'tools/linters' - LOG_LEVEL: NOTICE - VALIDATE_ALL_CODEBASE: true - VALIDATE_GITHUB_ACTIONS: true - VALIDATE_JSON: true - VALIDATE_PHP_BUILTIN: true - VALIDATE_YAML: true - VALIDATE_XML: true - - quality: - name: Quality control - runs-on: [ubuntu-latest] - - steps: - - name: Setup PHP, with composer and extensions - id: setup-php - # https://github.com/shivammathur/setup-php - uses: shivammathur/setup-php@v2 - with: - # Should be the higest supported version, so we can use the newest tools - php-version: '8.4' - tools: composer, phpcs, composer-require-checker, composer-unused - extensions: ctype, date, filter, pcre, spl - coverage: none - - - name: Setup problem matchers for PHP - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - - uses: actions/checkout@v4 - - - name: Get composer cache directory - run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: $COMPOSER_CACHE - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Validate composer.json and composer.lock - run: composer validate - - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Check code for hard dependencies missing in composer.json - run: composer-require-checker check composer.json - - - name: Check code for unused dependencies in composer.json - run: composer-unused - - - name: PHP Code Sniffer - run: phpcs - - - name: PHPStan - run: | - vendor/bin/phpstan analyze -c phpstan.neon --debug - - - name: PHPStan (testsuite) - run: | - vendor/bin/phpstan analyze -c phpstan-dev.neon --debug - - security: - name: Security checks - runs-on: [ubuntu-latest] - steps: - - name: Setup PHP, with composer and extensions - # https://github.com/shivammathur/setup-php - uses: shivammathur/setup-php@v2 - with: - # Should be the lowest supported version - php-version: '8.1' - extensions: ctype, date, filter, pcre, spl - tools: composer - coverage: none - - - name: Setup problem matchers for PHP - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - - uses: actions/checkout@v4 - - - name: Get composer cache directory - run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: $COMPOSER_CACHE - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + phplinter: + name: 'PHP-Linter' + strategy: + fail-fast: false + matrix: + php-version: ['8.1', '8.2', '8.3', '8.4'] - - name: Security check for locked dependencies - run: composer audit + uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.9.2 + with: + php-version: ${{ matrix.php-version }} - - name: Update Composer dependencies - run: composer update --no-progress --prefer-dist --optimize-autoloader + linter: + name: 'Linter' + strategy: + fail-fast: false - - name: Security check for updated dependencies - run: composer audit + uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.9.2 + with: + enable_eslinter: false + enable_jsonlinter: true + enable_stylelinter: false + enable_yamllinter: true unit-tests-linux: name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}" runs-on: ${{ matrix.operating-system }} - needs: [linter, quality, security] + needs: [phplinter, linter] strategy: fail-fast: false matrix: @@ -200,7 +102,7 @@ jobs: unit-tests-windows: name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}" runs-on: ${{ matrix.operating-system }} - needs: [linter, quality, security] + needs: [phplinter, linter] strategy: fail-fast: true matrix: @@ -247,6 +149,102 @@ jobs: - name: Run unit tests run: vendor/bin/phpunit --no-coverage + + quality: + name: Quality control + runs-on: [ubuntu-latest] + + steps: + - name: Setup PHP, with composer and extensions + id: setup-php + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + # Should be the higest supported version, so we can use the newest tools + php-version: '8.4' + tools: composer, phpcs, composer-require-checker, composer-unused + extensions: ctype, date, filter, pcre, spl + coverage: none + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: $COMPOSER_CACHE + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Check code for hard dependencies missing in composer.json + run: composer-require-checker check composer.json + + - name: Check code for unused dependencies in composer.json + run: composer-unused + + - name: PHP Code Sniffer + run: phpcs + + - name: PHPStan + run: | + vendor/bin/phpstan analyze -c phpstan.neon --debug + + - name: PHPStan (testsuite) + run: | + vendor/bin/phpstan analyze -c phpstan-dev.neon --debug + + security: + name: Security checks + runs-on: [ubuntu-latest] + steps: + - name: Setup PHP, with composer and extensions + # https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 + with: + # Should be the lowest supported version + php-version: '8.1' + extensions: ctype, date, filter, pcre, spl + tools: composer + coverage: none + + - name: Setup problem matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - uses: actions/checkout@v4 + + - name: Get composer cache directory + run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: $COMPOSER_CACHE + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Security check for locked dependencies + run: composer audit + + - name: Update Composer dependencies + run: composer update --no-progress --prefer-dist --optimize-autoloader + + - name: Security check for updated dependencies + run: composer audit + coverage: name: Code coverage runs-on: [ubuntu-latest] diff --git a/composer.json b/composer.json index 902bd9a..2da47a3 100644 --- a/composer.json +++ b/composer.json @@ -19,13 +19,13 @@ "ext-pcre": "*", "ext-spl": "*", - "guzzlehttp/psr7": "~2.7.0", + "guzzlehttp/psr7": "~2.7.1", "webmozart/assert": "~1.11.0" }, "require-dev": { "ext-intl": "*", - "simplesamlphp/simplesamlphp-test-framework": "~1.8.0" + "simplesamlphp/simplesamlphp-test-framework": "~1.9.2" }, "autoload": { "psr-4": { diff --git a/src/Assert.php b/src/Assert.php index ccf751b..639929c 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -357,7 +357,7 @@ public static function __callStatic(string $name, array $arguments): void } elseif (method_exists(static::class, $name)) { call_user_func_array([static::class, $name], $arguments); return; - } elseif (preg_match('/^nullOr(.*)$/i', $name, $matches)) { + } elseif (preg_match('/^nullOr(.+)$/i', $name, $matches)) { $method = lcfirst($matches[1]); if (method_exists(Webmozart::class, $method)) { call_user_func_array([static::class, 'nullOr'], [[Webmozart::class, $method], $arguments]); @@ -366,7 +366,7 @@ public static function __callStatic(string $name, array $arguments): void } else { throw new BadMethodCallException(sprintf("Assertion named `%s` does not exists.", $method)); } - } elseif (preg_match('/^all(.*)$/i', $name, $matches)) { + } elseif (preg_match('/^all(.+)$/i', $name, $matches)) { $method = lcfirst($matches[1]); if (method_exists(Webmozart::class, $method)) { call_user_func_array([static::class, 'all'], [[Webmozart::class, $method], $arguments]);