From 09b54e97860554b2e7a7ae0af78c3cc2525a3897 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Tue, 29 Aug 2023 08:51:33 +0100 Subject: [PATCH] Issue #3383591 by Spokje: Use type-hinting on deprecation warnings for deleteRevision() introduced by mglaman/phpstan-drupal:1.2.0 --- .../Core/Entity/Form/RevisionDeleteForm.php | 1 + .../src/Kernel/ContentModerationStateTest.php | 3 ++ .../node/src/Form/NodeRevisionDeleteForm.php | 4 ++- .../workspaces/src/WorkspaceManager.php | 1 + core/phpstan-baseline.neon | 36 ------------------- 5 files changed, 8 insertions(+), 37 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/Form/RevisionDeleteForm.php b/core/lib/Drupal/Core/Entity/Form/RevisionDeleteForm.php index 40b73e2cfaf6..f38775a2dd2c 100644 --- a/core/lib/Drupal/Core/Entity/Form/RevisionDeleteForm.php +++ b/core/lib/Drupal/Core/Entity/Form/RevisionDeleteForm.php @@ -140,6 +140,7 @@ public function getDescription() { */ public function submitForm(array &$form, FormStateInterface $form_state) { $entityTypeId = $this->revision->getEntityTypeId(); + /** @var \Drupal\Core\Entity\RevisionableStorageInterface $entityStorage */ $entityStorage = $this->entityTypeManager->getStorage($entityTypeId); $entityStorage->deleteRevision($this->revision->getRevisionId()); diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php index 90bad5caf694..4cdf77d83740 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php @@ -231,6 +231,7 @@ public function testContentModerationStateRevisionDataRemoval($entity_type_id) { // Delete the second revision and check that its content moderation state is // removed as well, while the content moderation states for revisions 1 and // 3 are kept in place. + /** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */ $entity_storage = $this->entityTypeManager->getStorage($entity_type_id); $entity_storage->deleteRevision($revision_2->getRevisionId()); @@ -253,6 +254,7 @@ public function testContentModerationStatePendingRevisionDataRemoval($entity_typ $content_moderation_state = ContentModerationState::loadFromModeratedEntity($entity); $this->assertNotEmpty($content_moderation_state); + /** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */ $entity_storage = $this->entityTypeManager->getStorage($entity_type_id); $entity_storage->deleteRevision($entity->getRevisionId()); @@ -264,6 +266,7 @@ public function testContentModerationStatePendingRevisionDataRemoval($entity_typ * Tests removal of content moderation state entities for preexisting content. */ public function testExistingContentModerationStateDataRemoval() { + /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */ $storage = $this->entityTypeManager->getStorage('entity_test_mulrevpub'); $entity = $this->createEntity('entity_test_mulrevpub', 'published', FALSE); diff --git a/core/modules/node/src/Form/NodeRevisionDeleteForm.php b/core/modules/node/src/Form/NodeRevisionDeleteForm.php index a413c8fe11fa..1d6af272b731 100644 --- a/core/modules/node/src/Form/NodeRevisionDeleteForm.php +++ b/core/modules/node/src/Form/NodeRevisionDeleteForm.php @@ -142,7 +142,9 @@ public function buildForm(array $form, FormStateInterface $form_state, NodeInter * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $this->nodeStorage->deleteRevision($this->revision->getRevisionId()); + /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */ + $storage = $this->nodeStorage; + $storage->deleteRevision($this->revision->getRevisionId()); $this->logger('content')->info('@type: deleted %title revision %revision.', ['@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); $node_type = $this->nodeTypeStorage->load($this->revision->bundle())->label(); diff --git a/core/modules/workspaces/src/WorkspaceManager.php b/core/modules/workspaces/src/WorkspaceManager.php index f48d1c805d59..e6663f7ea749 100644 --- a/core/modules/workspaces/src/WorkspaceManager.php +++ b/core/modules/workspaces/src/WorkspaceManager.php @@ -325,6 +325,7 @@ public function purgeDeletedWorkspacesBatch() { $count = 1; foreach ($all_associated_revisions as $entity_type_id => $associated_revisions) { + /** @var \Drupal\Core\Entity\RevisionableStorageInterface $associated_entity_storage */ $associated_entity_storage = $this->entityTypeManager->getStorage($entity_type_id); // Sort the associated revisions in reverse ID order, so we can delete the diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 79b7404a57b6..c0f306c2c17b 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -532,15 +532,6 @@ parameters: count: 2 path: lib/Drupal/Core/Entity/EntityDisplayBase.php - - - message: """ - #^Call to deprecated method deleteRevision\\(\\) of class Drupal\\\\Core\\\\Entity\\\\EntityStorageInterface\\: - in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - \\\\Drupal\\\\Core\\\\Entity\\\\RevisionableStorageInterface\\:\\:deleteRevision instead\\.$# - """ - count: 1 - path: lib/Drupal/Core/Entity/Form/RevisionDeleteForm.php - - message: "#^Method Drupal\\\\Core\\\\Entity\\\\KeyValueStore\\\\KeyValueContentEntityStorage\\:\\:createTranslation\\(\\) should return Drupal\\\\Core\\\\Entity\\\\ContentEntityInterface but return statement is missing\\.$#" count: 1 @@ -1191,15 +1182,6 @@ parameters: count: 1 path: modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php - - - message: """ - #^Call to deprecated method deleteRevision\\(\\) of class Drupal\\\\Core\\\\Entity\\\\EntityStorageInterface\\: - in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - \\\\Drupal\\\\Core\\\\Entity\\\\RevisionableStorageInterface\\:\\:deleteRevision instead\\.$# - """ - count: 3 - path: modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php - - message: """ #^Call to deprecated method loadRevision\\(\\) of class Drupal\\\\Core\\\\Entity\\\\EntityStorageInterface\\: @@ -2067,15 +2049,6 @@ parameters: count: 1 path: modules/node/src/ConfigTranslation/NodeTypeMapper.php - - - message: """ - #^Call to deprecated method deleteRevision\\(\\) of class Drupal\\\\Core\\\\Entity\\\\EntityStorageInterface\\: - in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - \\\\Drupal\\\\Core\\\\Entity\\\\RevisionableStorageInterface\\:\\:deleteRevision instead\\.$# - """ - count: 1 - path: modules/node/src/Form/NodeRevisionDeleteForm.php - - message: "#^Method Drupal\\\\node\\\\NodeForm\\:\\:save\\(\\) should return int but return statement is missing\\.$#" count: 1 @@ -3147,15 +3120,6 @@ parameters: count: 1 path: modules/workspaces/src/WorkspaceAssociation.php - - - message: """ - #^Call to deprecated method deleteRevision\\(\\) of class Drupal\\\\Core\\\\Entity\\\\EntityStorageInterface\\: - in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - \\\\Drupal\\\\Core\\\\Entity\\\\RevisionableStorageInterface\\:\\:deleteRevision instead\\.$# - """ - count: 1 - path: modules/workspaces/src/WorkspaceManager.php - - message: "#^Method Drupal\\\\workspaces\\\\WorkspaceMerger\\:\\:checkConflictsOnTarget\\(\\) should return array but return statement is missing\\.$#" count: 1 -- GitLab