From d997f63fc1c2d9dc3eb1ef6f523c9d84a68f75cb Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Sat, 17 Feb 2024 17:21:10 +0100 Subject: [PATCH] allow installation with symfony 6 --- .github/workflows/test-application.yaml | 27 ++++------ CHANGELOG.md | 3 +- composer.json | 51 +++++++++---------- .../Phpcr/NonTranslatableMetadataListener.php | 2 +- .../Phpcr/TranslatableMetadataListener.php | 2 +- src/Templating/Helper/Cmf.php | 36 +++++++------ .../Form/CheckboxUrlLabelFormTypeTest.php | 1 + 7 files changed, 60 insertions(+), 62 deletions(-) diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 94389b8..ff97e8a 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -22,21 +22,16 @@ jobs: fail-fast: false matrix: include: - - php-version: '7.4' + - php-version: '8.1' dependencies: 'lowest' - - php-version: '7.4' - symfony-version: 4.4.* - test-installation: true - - php-version: '7.4' - symfony-version: 5.0.* - test-installation: true - - php-version: '8.0' - symfony-version: 5.1.* - test-installation: true + - php-version: '8.1' + - php-version: '8.2' + - php-version: '8.3' + symfony-version: 6.4.* steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -45,17 +40,15 @@ jobs: tools: 'composer:v2' - name: Install Symfony Flex - run: composer global require --no-progress --no-scripts --no-plugins symfony/flex + run: | + composer global require --no-progress --no-scripts --no-plugins symfony/flex + composer global config --no-plugins allow-plugins.symfony/flex true - name: Install dependencies with Composer - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependencies }} composer-options: --prefer-dist - name: Execute test cases run: make test - - - name: Test installation - if: ${{ matrix.test-installation == true }} - run: make test diff --git a/CHANGELOG.md b/CHANGELOG.md index cc949f3..d391129 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changelog 3.0.0 (unreleased) ----- +* Support Symfony 6 * Adjust to doctrine and twig BC breaks. If you extended classes or customized services, check for old `Twig_*` classes or `Doctrine\Common\Persistence` namespace. * Drop support for old Symfony versions * Drop support for old PHP versions @@ -41,7 +42,7 @@ Released 2.0.0 2.0.0-RC1 --------- - * **2017-01-17**: [BC BREAK] Removed DoctrineOrmMappingsPass - all active Doctrine versions contain the mapping pass. Use `Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass` instead. + * **2017-01-17**: [BC BREAK] Removed DoctrineOrmMappingsPass - all active Doctrine versions contain the mapping pass. Use `Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass` instead. * **2017-01-13**: [BC BREAK] Removed the `Slugifier` classes and the dependency on `symfony-cmf/slugifier-api`. * **2016-12-03**: [BC BREAK] Moved sonata admin related classes and diff --git a/composer.json b/composer.json index 2fc3dd0..44c851c 100644 --- a/composer.json +++ b/composer.json @@ -14,39 +14,37 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "symfony/framework-bundle": "^4.4 || ^5.0", - "symfony/security-core": "^4.4 || ^5.0" + "php": "^8.1", + "symfony/framework-bundle": "^6.4", + "symfony/security-core": "^6.4" }, "require-dev": { - "jackalope/jackalope-doctrine-dbal": "^1.3", - "symfony/security-bundle": "^4.4 || ^5.0", - "symfony/phpunit-bridge": "^4.4.34 || ^5.0", + "jackalope/jackalope-doctrine-dbal": "^1.3 || ^2.0", "mockery/mockery": "^1.4.1", - "symfony-cmf/routing-bundle": "^2.1.0", + "symfony-cmf/routing-bundle": "dev-sf7 as 3.1.0", "symfony-cmf/testing": "^4.0.0", - "doctrine/dbal": "^2.5", + "doctrine/dbal": "^3.8.1 || ^4.0", "doctrine/doctrine-bundle": "^2.0", - "doctrine/phpcr-odm": "^1.4|^2.0 ", - "doctrine/phpcr-bundle": "^2.3.0", - "symfony/browser-kit": "^4.4 || ^5.0", - "symfony/form": "^4.4 || ^5.0", - "symfony/monolog-bridge": "^4.4 || ^5.0", + "doctrine/phpcr-bundle": "^3.0", + "doctrine/phpcr-odm": "^1.4 || ^2.0 ", + "symfony/browser-kit": "^6.4", + "symfony/form": "^6.4", + "symfony/monolog-bridge": "^6.4", "symfony/monolog-bundle": "^3.0", - "symfony/templating": "^4.4 || ^5.0", - "symfony/translation": "^4.4 || ^5.0", - "symfony/twig-bundle": "^4.4 || ^5.0", - "symfony/validator": "^4.4 || ^5.0", - "symfony/yaml": "^4.4 || ^5.0", - "symfony/asset": "^4.4 || ^5.0" + "symfony/phpunit-bridge": "^7.0.3", + "symfony/security-bundle": "^6.4", + "symfony/templating": "^6.4", + "symfony/translation": "^6.4", + "symfony/twig-bundle": "^6.4", + "symfony/validator": "^6.4", + "symfony/yaml": "^6.4", + "symfony/asset": "^6.4" }, "suggest": { - "symfony/twig-bundle": "To get access to the CMF twig extension (^4.4 || ^5.0)", - "doctrine/phpcr-bundle": "To be able to use the CMF twig extension (^1.0)", - "doctrine/phpcr-odm": "To be able to use the CMF twig extension (^1.0)", - "symfony/security-bundle": "To be able to use the publish workflow system (^4.4 || ^5.0)", - "symfony-cmf/routing": "To be able to use the CMF twig extension functions cmf_prev_linkable/cmf_next_linkable (^2.1)", - "symfony-cmf/routing-bundle": "To be able to enable the publish_workflow_listener (^2.1)", + "symfony/twig-bundle": "To get access to the CMF twig extension", + "symfony/security-bundle": "To be able to use the publish workflow system", + "symfony-cmf/routing": "To be able to use the CMF twig extension functions cmf_prev_linkable/cmf_next_linkable", + "symfony-cmf/routing-bundle": "To be able to enable the publish_workflow_listener", "symfony-cmf/sonata-admin-integration-bundle": "To provide an admin interface for the PHPCR ODM documents." }, "autoload": { @@ -63,5 +61,6 @@ "branch-alias": { "dev-master": "3.x-dev" } - } + }, + "minimum-stability": "dev" } diff --git a/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php b/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php index 7fef30b..0447f6f 100644 --- a/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php +++ b/src/Doctrine/Phpcr/NonTranslatableMetadataListener.php @@ -39,7 +39,7 @@ public function getSubscribedEvents() */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { - /** @var $meta ClassMetadata */ + /** @var ClassMetadata $meta */ $meta = $eventArgs->getClassMetadata(); if (!$meta->translator) { diff --git a/src/Doctrine/Phpcr/TranslatableMetadataListener.php b/src/Doctrine/Phpcr/TranslatableMetadataListener.php index d5e1aab..3524830 100644 --- a/src/Doctrine/Phpcr/TranslatableMetadataListener.php +++ b/src/Doctrine/Phpcr/TranslatableMetadataListener.php @@ -51,7 +51,7 @@ public function getSubscribedEvents() */ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { - /** @var $meta ClassMetadata */ + /** @var ClassMetadata $meta */ $meta = $eventArgs->getClassMetadata(); if ($meta->getReflectionClass()->implementsInterface(TranslatableInterface::class)) { diff --git a/src/Templating/Helper/Cmf.php b/src/Templating/Helper/Cmf.php index 8da1b4c..4b8e11a 100644 --- a/src/Templating/Helper/Cmf.php +++ b/src/Templating/Helper/Cmf.php @@ -175,7 +175,7 @@ private function getDocument($document, ?bool $ignoreRole = false, ?string $clas try { $document = $this->getDm()->find(null, $document); } catch (MissingTranslationException $e) { - return; + return null; } } @@ -188,7 +188,7 @@ private function getDocument($document, ?bool $ignoreRole = false, ?string $clas || (true === $ignoreRole && !$this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $document)) || (null !== $class && !($document instanceof $class)) ) { - return; + return null; } return $document; @@ -234,7 +234,7 @@ public function findMany(array $paths = [], $limit = false, $offset = false, ?bo * If you need the bypass role, you will have a firewall configured and can * simply use {{ is_granted('VIEW', document) }} * - * @param object $document + * @param ?object $document */ public function isPublished($document): bool { @@ -426,12 +426,12 @@ public function isLinkable($document): bool */ private function getChildrenPaths(string $path, array &$children, ?int $depth) { - if (null !== $depth && $depth < 1) { - return; + if (null !== $depth) { + if ($depth-- < 1) { + return; + } } - --$depth; - $node = $this->getDm()->getPhpcrSession()->getNode($path); $names = (array) $node->getNodeNames(); foreach ($names as $name) { @@ -485,7 +485,7 @@ private function checkChildren(array $childNames, string $path, ?bool $ignoreRol } } - return; + return null; } /** @@ -515,7 +515,7 @@ private function traversePrevDepth(?int $depth, int $anchorDepth, array $childNa } } - return; + return null; } /** @@ -536,7 +536,7 @@ private function searchDepthPrev($path, $anchor, ?int $depth = null, ?bool $igno } if (null === $path || '/' === $path) { - return; + return null; } $node = $this->getDm()->getPhpcrSession()->getNode($path); @@ -550,7 +550,7 @@ private function searchDepthPrev($path, $anchor, ?int $depth = null, ?bool $igno } if ($path === $anchor) { - return; + return null; } $parent = $node->getParent(); @@ -592,7 +592,7 @@ private function searchDepthPrev($path, $anchor, ?int $depth = null, ?bool $igno } } - return; + return null; } /** @@ -613,7 +613,7 @@ private function searchDepthNext($path, $anchor, ?int $depth = null, ?bool $igno } if (null === $path || '/' === $path) { - return; + return null; } $node = $this->getDm()->getPhpcrSession()->getNode($path); @@ -653,7 +653,7 @@ private function searchDepthNext($path, $anchor, ?int $depth = null, ?bool $igno while ('/' !== $parentPath) { $parent = $parent->getParent(); if (false === strpos($parent->getPath(), $anchor)) { - return; + return null; } $childNames = $parent->getNodeNames()->getArrayCopy(); @@ -666,7 +666,7 @@ private function searchDepthNext($path, $anchor, ?int $depth = null, ?bool $igno } } - return; + return null; } /** @@ -686,7 +686,7 @@ private function search($path, ?bool $reverse = false, ?bool $ignoreRole = false } if (null === $path || '/' === $path) { - return; + return null; } $node = $this->getDm()->getPhpcrSession()->getNode($path); @@ -770,6 +770,8 @@ public function getPrevLinkable($current, $anchor = null, ?int $depth = null, ?b $current = $candidate; } + + return null; } /** @@ -800,5 +802,7 @@ public function getNextLinkable($current, $anchor = null, ?int $depth = null, ?b $current = $candidate; } + + return null; } } diff --git a/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php b/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php index 086c068..95330a9 100644 --- a/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php +++ b/tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php @@ -101,5 +101,6 @@ protected function assertMatchesXpath($html, $expression, $count = 1) substr($dom->saveHTML(), 6, -8) )); } + $this->addToAssertionCount(1); } }