From 214ed114e5094931268b6cabce0bcf4053751cee Mon Sep 17 00:00:00 2001 From: martinlagler Date: Tue, 18 Feb 2025 14:04:26 +0000 Subject: [PATCH] Fix last modified by check the interface correctly (#716) --- .php-cs-fixer.dist.php | 2 +- DependencyInjection/SuluArticleExtension.php | 4 +- Document/LocalizedLastModifiedBehavior.php | 4 +- phpstan-baseline.neon | 65 -------------------- 4 files changed, 5 insertions(+), 70 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ceff60b6..ef232027 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -45,7 +45,7 @@ 'phpdoc_to_comment' => [ 'ignored_tags' => ['todo', 'var', 'see', 'phpstan-ignore-next-line'], ], - 'trailing_comma_in_multiline' => false, + 'trailing_comma_in_multiline' => ['after_heredoc' => true, 'elements' => ['array_destructuring', 'arrays', 'match']], ]) ->setFinder($finder); diff --git a/DependencyInjection/SuluArticleExtension.php b/DependencyInjection/SuluArticleExtension.php index 8670894a..136bd991 100644 --- a/DependencyInjection/SuluArticleExtension.php +++ b/DependencyInjection/SuluArticleExtension.php @@ -15,11 +15,11 @@ use Sulu\Bundle\ArticleBundle\Document\ArticlePageDocument; use Sulu\Bundle\ArticleBundle\Document\Form\ArticleDocumentType; use Sulu\Bundle\ArticleBundle\Document\Form\ArticlePageDocumentType; -use Sulu\Bundle\ArticleBundle\Document\LocalizedLastModifiedBehavior; use Sulu\Bundle\ArticleBundle\Document\Structure\ArticleBridge; use Sulu\Bundle\ArticleBundle\Document\Structure\ArticlePageBridge; use Sulu\Bundle\ArticleBundle\Exception\ArticlePageNotFoundException; use Sulu\Bundle\ArticleBundle\Exception\ParameterNotAllowedException; +use Sulu\Component\Content\Document\Behavior\LocalizedLastModifiedBehavior as SuluLocalizedLastModifiedBehavior; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; @@ -189,7 +189,7 @@ public function prepend(ContainerBuilder $container) ], 'forms' => [ 'directories' => [ - \class_exists(LocalizedLastModifiedBehavior::class) + \interface_exists(SuluLocalizedLastModifiedBehavior::class) ? __DIR__ . '/../Resources/config/forms' : __DIR__ . '/../Resources/config/forms_sulu_25_or_lower', ], diff --git a/Document/LocalizedLastModifiedBehavior.php b/Document/LocalizedLastModifiedBehavior.php index fc55cfb7..1b85daae 100644 --- a/Document/LocalizedLastModifiedBehavior.php +++ b/Document/LocalizedLastModifiedBehavior.php @@ -11,11 +11,11 @@ namespace Sulu\Bundle\ArticleBundle\Document; -use Sulu\Component\DocumentManager\Behavior\LocalizedLastModifiedBehavior as SuluLocalizedLastModifiedBehavior; +use Sulu\Component\Content\Document\Behavior\LocalizedLastModifiedBehavior as SuluLocalizedLastModifiedBehavior; if (\interface_exists(SuluLocalizedLastModifiedBehavior::class)) { /** - * @internal BC Layer for Sulu <2.6 + * @internal BC Layer for Sulu >=2.6 */ interface LocalizedLastModifiedBehavior extends SuluLocalizedLastModifiedBehavior { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6a939762..8537c5f2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,11 +10,6 @@ parameters: count: 1 path: Admin/ArticleAdmin.php - - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Admin\\\\ArticleAdmin\\:\\:getSecurityContexts\\(\\) should return array\\\\>\\>\\> but returns array\\\\>\\>\\>\\.$#" - count: 1 - path: Admin/ArticleAdmin.php - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Admin\\\\ArticleAdmin\\:\\:getTypes\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -40,11 +35,6 @@ parameters: count: 1 path: Admin/Helper/WebspaceSelect.php - - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Builder\\\\ArticleIndexBuilder\\:\\:getDependencies\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: Builder/ArticleIndexBuilder.php - - message: "#^Strict comparison using \\=\\=\\= between 0 and bool will always evaluate to false\\.$#" count: 1 @@ -955,11 +945,6 @@ parameters: count: 1 path: Document/Index/ArticleIndexer.php - - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\Index\\\\ArticleIndexer\\:\\:getDocumentInspector\\(\\) has no return type specified\\.$#" - count: 1 - path: Document/Index/ArticleIndexer.php - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\Index\\\\ArticleIndexer\\:\\:getViewDocumentIds\\(\\) has parameter \\$uuids with no value type specified in iterable type array\\.$#" count: 1 @@ -1085,56 +1070,11 @@ parameters: count: 1 path: Document/Index/DocumentFactory.php - - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Cannot access offset 'id' on mixed\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Cannot access offset 'key' on mixed\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Cannot access offset 'keyword' on mixed\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Cannot access offset 'name' on mixed\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Cannot cast mixed to int\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\Index\\\\Factory\\\\CategoryCollectionFactory\\:\\:__construct\\(\\) has parameter \\$categoryRepository with generic class Doctrine\\\\ORM\\\\EntityRepository but does not specify its types\\: TEntityClass$#" count: 1 path: Document/Index/Factory/CategoryCollectionFactory.php - - - message: "#^Property Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\CategoryViewObject\\:\\:\\$key \\(string\\) does not accept mixed\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Property Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\CategoryViewObject\\:\\:\\$keywords \\(array\\\\) does not accept array\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - - - message: "#^Property Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\CategoryViewObject\\:\\:\\$name \\(string\\) does not accept mixed\\.$#" - count: 1 - path: Document/Index/Factory/CategoryCollectionFactory.php - - message: "#^Property Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\Index\\\\Factory\\\\CategoryCollectionFactory\\:\\:\\$categoryRepository with generic class Doctrine\\\\ORM\\\\EntityRepository does not specify its types\\: TEntityClass$#" count: 1 @@ -1735,11 +1675,6 @@ parameters: count: 1 path: Document/Subscriber/RoutableSubscriber.php - - - message: "#^Method Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\Subscriber\\\\WebspaceSubscriber\\:\\:getDocumentInspector\\(\\) has no return type specified\\.$#" - count: 1 - path: Document/Subscriber/WebspaceSubscriber.php - - message: "#^Parameter \\#1 \\$additionalWebspaces of method Sulu\\\\Bundle\\\\ArticleBundle\\\\Document\\\\Behavior\\\\WebspaceBehavior\\:\\:setAdditionalWebspaces\\(\\) expects array\\\\|null, mixed given\\.$#" count: 1