diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9814f1a..2a229cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,63 +1,43 @@ name: Build on: - push: - branches: - - master - pull_request: - branches: - - master + push: + branches: + - master + pull_request: + branches: + - master jobs: - build: - name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-args }} - strategy: - fail-fast: false - matrix: - operating-system: [ubuntu-latest] - php-versions: ['7.3', '7.4'] - 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 - - name: Setup PHP - uses: shivammathur/setup-php@2.10.0 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring - tools: cs2pr - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache dependencies - uses: actions/cache@v2.1.4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install Dependencies - run: | - composer update --no-progress --no-suggest --prefer-stable --optimize-autoloader ${{ matrix.composer-args }} - - name: PHPStan - run: composer phpstan - - name: Code Style Check - run: composer check-style -- --format=checkstyle | cs2pr - merge-me: - name: Merge me! - needs: - - build - runs-on: ubuntu-latest - steps: - - name: Merge me! - uses: ridedott/merge-me-action@master - 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]' + build: + name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-args }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest] + php-versions: ["7.4", "8.0", "8.1", "8.2", "8.3"] + composer-args: ["", "--prefer-lowest"] + runs-on: ${{ matrix.operating-system }} + steps: + - name: Checkout + uses: actions/checkout@v4.1.4 + - name: Setup PHP + uses: shivammathur/setup-php@2.23.0 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring + tools: cs2pr + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache dependencies + uses: actions/cache@v4.0.2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install Dependencies + run: | + composer update --no-progress --no-suggest --prefer-stable --optimize-autoloader ${{ matrix.composer-args }} + - name: PHPStan + run: composer phpstan + - name: Code Style Check + run: composer check-style -- --format=checkstyle | cs2pr diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..3aaaca1 --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,22 @@ +name: Dependabot auto-merge +on: pull_request + +permissions: + contents: write + pull-requests: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.gitignore b/.gitignore index bd73404..a99b54a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /composer.lock /vendor /.php_cs.cache +/.php-cs-fixer.cache \ No newline at end of file diff --git a/.php_cs b/.php-cs-fixer.php similarity index 69% rename from .php_cs rename to .php-cs-fixer.php index 7bbe010..56bf461 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -6,11 +6,12 @@ ->in(__DIR__) ; -return PhpCsFixer\Config::create() - ->setRiskyAllowed(true) +$config = new PhpCsFixer\Config(); + +return $config->setRiskyAllowed(true) ->setRules([ '@PSR2' => true, - 'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => true], + 'binary_operator_spaces' => ['operators' => ['=' => 'align', '=>' => 'align']], 'single_quote' => false, 'array_syntax' => ['syntax' => 'short'], 'concat_space' => ['spacing' => 'one'], diff --git a/Module.php b/Module.php index 755f3a2..c9bec0d 100644 --- a/Module.php +++ b/Module.php @@ -52,7 +52,7 @@ public function getServiceConfig() }, 'OAuth2Server\AuthorizeForm' => function (ServiceManager $serviceManager) { $config = $serviceManager->get('Config'); - $form = new $config['oauth2server']['authorize_form_class']( + $form = new $config['oauth2server']['authorize_form_class']( 'Authorize', $config['oauth2server']['csrf_salt'] ); diff --git a/composer.json b/composer.json index fd23c2a..198cc9d 100644 --- a/composer.json +++ b/composer.json @@ -25,13 +25,13 @@ ], "homepage": "https://github.com/diablomedia/zf2-oauth2-server", "require": { - "php": "^7.3 || ^8.0", + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", "bshaffer/oauth2-server-php": "^1.10", "diablomedia/oauth2-server-zendhttp-bridge": "^3.0.0", - "laminas/laminas-form": "^2.0.0", + "laminas/laminas-form": "^2.0.0 || ^3.0.0", "laminas/laminas-view": "^2.0.0", "laminas/laminas-mvc": "^2.0 || ^3.0", - "container-interop/container-interop": "^1.2", + "psr/container": "^1.0 || ^2.0", "laminas/laminas-modulemanager": "^2.10", "laminas/laminas-servicemanager": "^3.6" }, @@ -44,8 +44,8 @@ ] }, "require-dev": { - "friendsofphp/php-cs-fixer": "2.18.4", - "phpstan/phpstan": "0.12.82", + "friendsofphp/php-cs-fixer": "3.51.0", + "phpstan/phpstan": "1.10.67", "maglnet/composer-require-checker": "^2.0 || ^3.0", "phpro/grumphp-shim": "^0.22.0 || ^1.1" }, @@ -53,5 +53,11 @@ "fix-style": "php-cs-fixer fix", "check-style": "php-cs-fixer fix --dry-run -vv", "phpstan": "phpstan analyze -c phpstan.neon --no-progress --ansi" + }, + "config": { + "allow-plugins": { + "phpro/grumphp-shim": true, + "ocramius/package-versions": true + } } } diff --git a/grumphp.yml.dist b/grumphp.yml.dist index 935b80f..20d08e5 100644 --- a/grumphp.yml.dist +++ b/grumphp.yml.dist @@ -6,6 +6,6 @@ grumphp: composer_require_checker: ~ phpcsfixer2: allow_risky: true - config: .php_cs + config: .php-cs-fixer.php phpstan: memory_limit: 768M diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 43d0913..bc83c2d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -39,9 +39,3 @@ parameters: message: "#^Parameter \\#2 \\$response of method OAuth2\\\\Server\\:\\:handleTokenRequest\\(\\) expects OAuth2\\\\ResponseInterface\\|null, Laminas\\\\Stdlib\\\\ResponseInterface given\\.$#" count: 1 path: src/OAuth2Server/Controller/AuthorizeController.php - - - - message: "#^Call to an undefined method Laminas\\\\ServiceManager\\\\ServiceLocatorInterface\\:\\:getServiceLocator\\(\\)\\.$#" - count: 1 - path: src/OAuth2Server/Controller/Factory/AuthorizeControllerFactory.php - diff --git a/phpstan.neon b/phpstan.neon index 3101302..170a443 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,10 +2,11 @@ includes: - ./phpstan-baseline.neon parameters: checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false inferPrivatePropertyTypeFromConstructor: true level: 8 paths: - ./ - excludes_analyse: + excludePaths: - ./vendor/* ignoreErrors: diff --git a/src/OAuth2Server/Controller/Factory/AuthorizeControllerFactory.php b/src/OAuth2Server/Controller/Factory/AuthorizeControllerFactory.php index bb0c5d4..774367e 100644 --- a/src/OAuth2Server/Controller/Factory/AuthorizeControllerFactory.php +++ b/src/OAuth2Server/Controller/Factory/AuthorizeControllerFactory.php @@ -2,20 +2,12 @@ namespace OAuth2Server\Controller\Factory; -use Laminas\ServiceManager\FactoryInterface; +use Laminas\ServiceManager\Factory\FactoryInterface; use OAuth2Server\Controller\AuthorizeController; -use Interop\Container\ContainerInterface; -use Laminas\ServiceManager\ServiceLocatorInterface; +use Psr\Container\ContainerInterface; class AuthorizeControllerFactory implements FactoryInterface { - public function createService(ServiceLocatorInterface $serviceLocator) - { - // This only gets called in older versions of Laminas\ServiceManager, - // left for backwards compatibility - return $this($serviceLocator->getServiceLocator(), AuthorizeController::class); - } - public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { return new AuthorizeController(