From ca6da206f4240b1944e2114c1fa52c8ce43bde35 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Wed, 11 Oct 2023 22:12:36 -0400 Subject: [PATCH] Add PHPCR ODM 2.x compat --- .github/workflows/run-tests.yml | 15 +++++++++++++-- composer.json | 2 +- lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php | 1 + lib/Adapter/Doctrine/PHPCRODM/Tests/bootstrap.php | 11 +++++++++++ lib/Adapter/Doctrine/PHPCRODM/composer.json | 3 ++- lib/Adapter/Doctrine/PHPCRODM/phpunit.xml.dist | 2 +- phpstan-baseline.neon | 10 ++++++++++ tests/bootstrap.php | 1 + 8 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 lib/Adapter/Doctrine/PHPCRODM/Tests/bootstrap.php diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 01d5847c..0d8cfb80 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -203,7 +203,7 @@ jobs: composer-flags: '--prefer-stable --prefer-dist --prefer-lowest' next-php: false - php: '8.3' - orm: '^3.0@beta' + orm: '^3.0' composer-flags: '--prefer-stable --prefer-dist' next-php: false - php: '8.3' @@ -248,19 +248,26 @@ jobs: fail-fast: true matrix: php: ['8.1', '8.2', '8.3'] + odm: [''] composer-flags: ['--prefer-stable --prefer-dist'] next-php: [false] patch-packages: [false] include: - php: '8.1' + odm: '' composer-flags: '--prefer-stable --prefer-dist --prefer-lowest' next-php: false - php: '8.3' + odm: '^2.0' + composer-flags: '--prefer-dist --prefer-lowest' + next-php: false + - php: '8.3' + odm: '' composer-flags: '--prefer-stable --prefer-dist' next-php: false patch-packages: true - name: Doctrine PHPCR ODM - PHP ${{ matrix.php }} - Composer ${{ matrix.composer-flags }}${{ matrix.patch-packages && ' (Patched Packages)' || '' }} + name: Doctrine PHPCR ODM${{ matrix.odm != '' && format(' {0}', matrix.odm) || '' }} - PHP ${{ matrix.php }} - Composer ${{ matrix.composer-flags }}${{ matrix.patch-packages && ' (Patched Packages)' || '' }} steps: - name: Checkout code @@ -278,6 +285,10 @@ jobs: if: ${{ matrix.patch-packages }} run: php .github/patch-packages.php + - name: Restrict ODM version + if: ${{ matrix.odm }} + run: (cd lib/Adapter/Doctrine/PHPCRODM && composer require --no-update doctrine/phpcr-odm:${{ matrix.odm }}) + - name: Install dependencies run: (cd lib/Adapter/Doctrine/PHPCRODM && composer update ${{ matrix.composer-flags }}) diff --git a/composer.json b/composer.json index 1d7065f2..47148908 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "doctrine/dbal": "^3.5 || ^4.0", "doctrine/mongodb-odm": "^2.4", "doctrine/orm": "^2.14 || ^3.0", - "doctrine/phpcr-odm": "^1.7", + "doctrine/phpcr-odm": "^1.7 || ^2.0", "dg/bypass-finals": "^1.5.1", "jackalope/jackalope-doctrine-dbal": "^1.9", "phpstan/extension-installer": "^1.3.1", diff --git a/lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php b/lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php index 419667f4..d9619337 100644 --- a/lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php +++ b/lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php @@ -5,6 +5,7 @@ use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; use Doctrine\ODM\PHPCR\Query\Query; use Pagerfanta\Adapter\AdapterInterface; +use PHPCR\Query\QueryResultInterface; /** * Adapter which calculates pagination from a Doctrine PHPCR ODM QueryBuilder. diff --git a/lib/Adapter/Doctrine/PHPCRODM/Tests/bootstrap.php b/lib/Adapter/Doctrine/PHPCRODM/Tests/bootstrap.php new file mode 100644 index 00000000..bc195cbe --- /dev/null +++ b/lib/Adapter/Doctrine/PHPCRODM/Tests/bootstrap.php @@ -0,0 +1,11 @@ + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1cf70407..3dd0e59b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -65,6 +65,16 @@ parameters: count: 3 path: lib/Adapter/Doctrine/ORM/Tests/QueryAdapterTest.php + - + message: "#^Call to an undefined method Doctrine\\\\Common\\\\Collections\\\\Collection\\|PHPCR\\\\Query\\\\QueryResultInterface\\:\\:getRows\\(\\)\\.$#" + count: 1 + path: lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php + + - + message: "#^Call to an undefined method Iterator\\\\:\\:count\\(\\)\\.$#" + count: 1 + path: lib/Adapter/Doctrine/PHPCRODM/QueryAdapter.php + - message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with ArrayIterator\\<\\*NEVER\\*, \\*NEVER\\*\\> and iterable will always evaluate to false\\.$#" count: 1 diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 959178bb..6c520378 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,6 +6,7 @@ BypassFinals::setWhitelist([ '*/Doctrine/ODM/MongoDB/*', + '*/Doctrine/ODM/PHPCR/*', ]); BypassFinals::enable(bypassReadOnly: false);