diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index aa2be3f4acca63b1f9489c9b157eae27c0973733..0d897d1821573dbad3b85ff8ca888db9c6ccb812 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -22465,12 +22465,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\jsonapi\\\\Kernel\\\\Normalizer\\\\JsonApiTopLevelResourceNormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\jsonapi\\\\Kernel\\\\Normalizer\\\\LinkCollectionNormalizerTest\\:\\:getNormalizer\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -28255,12 +28249,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/migrate/tests/src/Unit/Exception/RequirementsExceptionTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\migrate\\\\Unit\\\\MigrateExecutableTest\\:\\:getTestRollbackIdMap\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/migrate/tests/src/Unit/MigrateExecutableTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\migrate\\\\Unit\\\\MigrateLookupTest\\:\\:providerExceptionOnMigrationNotFound\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -31243,12 +31231,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/options/tests/src/Kernel/Views/OptionsTestBase.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\package_manager\\\\Kernel\\\\ComposerInspectorTest\\:\\:mockComposerRunner\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/package_manager/tests/src/Kernel/ComposerInspectorTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\page_cache\\\\Hook\\\\PageCacheHooks\\:\\:help\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -33637,72 +33619,30 @@ 'count' => 1, 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\DateTimeIso8601NormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\DateTimeIso8601NormalizerTestDrupalDateTime\\:\\:setTimezone\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\DateTimeNormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\DateTimeNormalizerTestDrupalDateTime\\:\\:setTimezone\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\MarkupNormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/MarkupNormalizerTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\TestNormalizerBase\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#', 'identifier' => 'missingType.generics', 'count' => 1, 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\NullNormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/NullNormalizerTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\PrimitiveDataNormalizerTest\\:\\:dataProviderPrimitiveData\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/PrimitiveDataNormalizerTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\PrimitiveDataNormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/PrimitiveDataNormalizerTest.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\TimestampItemNormalizerTest\\:\\:createTimestampItemProphecy\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\TimestampNormalizerTest\\:\\:doProphesize\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\serialization\\\\Unit\\\\Normalizer\\\\TimestampNormalizerTestDrupalDateTime\\:\\:setTimezone\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -52131,12 +52071,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\views\\\\Unit\\\\Plugin\\\\query\\\\SqlTest\\:\\:setupEntityTypes\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/modules/views/tests/src/Unit/Plugin/query/SqlTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\views\\\\Unit\\\\Plugin\\\\views\\\\query\\\\MysqlDateSqlTest\\:\\:providerTestGetDateFormat\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -59338,12 +59272,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Cache/Context/HeadersCacheContextTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Cache\\\\Context\\\\IsFrontPathCacheContextTest\\:\\:createPathMatcher\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Cache\\\\Context\\\\PathParentCacheContextTest\\:\\:providerTestGetContext\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -59746,12 +59674,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/EntityFormTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Entity\\\\EntityFormTest\\:\\:setUpStorage\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/EntityFormTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Entity\\\\EntityLinkTest\\:\\:providerTestLink\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', @@ -59932,12 +59854,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Entity\\\\Routing\\\\DefaultHtmlRouteProviderTest\\:\\:getEntityType\\(\\) return type with generic class Prophecy\\\\Prophecy\\\\ObjectProphecy does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Entity\\\\Routing\\\\DefaultHtmlRouteProviderTest\\:\\:providerTestGetAddFormRoute\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php index b924f4325347c848be6460b963f44ae05cb069d0..edb40aa52b23115670d05b7e20db826dc1310c48 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -12,6 +12,7 @@ use Drupal\migrate\MigrateException; use Drupal\migrate\Row; use Prophecy\Argument; +use Prophecy\Prophecy\ObjectProphecy; /** * @coversDefaultClass \Drupal\migrate\MigrateExecutable @@ -557,10 +558,10 @@ public static function providerTestRollback() { /** * Returns an ID map object prophecy used in ::testRollback. * - * @return \Prophecy\Prophecy\ObjectProphecy + * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\migrate\Plugin\MigrateIdMapInterface> * An ID map object prophecy. */ - public function getTestRollbackIdMap(array $items, array $source_id_keys, array $destination_id_keys) { + public function getTestRollbackIdMap(array $items, array $source_id_keys, array $destination_id_keys): ObjectProphecy { static::$idMapRecords = array_map(function (array $item) { return $item + [ 'source_row_status' => '0', diff --git a/core/modules/package_manager/tests/src/Kernel/ComposerInspectorTest.php b/core/modules/package_manager/tests/src/Kernel/ComposerInspectorTest.php index aa3e4943278fdfa390c709da10f9782163eafd6a..0411978a175c240ab357873999f3acffae6b8809 100644 --- a/core/modules/package_manager/tests/src/Kernel/ComposerInspectorTest.php +++ b/core/modules/package_manager/tests/src/Kernel/ComposerInspectorTest.php @@ -528,7 +528,7 @@ public function testAllowedPlugins(array $config, bool|array $expected_value): v * @param string|null $reported_version * The version number that `composer --format=json` should return. * - * @return \Prophecy\Prophecy\ObjectProphecy + * @return \Prophecy\Prophecy\ObjectProphecy<\PhpTuf\ComposerStager\API\Process\Service\ComposerProcessRunnerInterface> * The configurator for the mocked Composer runner. */ private function mockComposerRunner(?string $reported_version): ObjectProphecy { diff --git a/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php b/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php index a9c5020025b67ecef3ec321c743466a52e3b1c58..2a08c3214cca133bf0ed7e7fb7b9388f077c3851 100644 --- a/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php +++ b/core/modules/serialization/tests/src/Traits/JsonSchemaTestTrait.php @@ -34,6 +34,8 @@ abstract public static function jsonSchemaDataProvider(): array; /** * Method to make prophecy public for use in data provider closures. + * + * @return \Prophecy\Prophecy\ObjectProphecy<object> */ public function doProphesize(?string $classOrInterface = NULL): ObjectProphecy { return $this->prophesize($classOrInterface); diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php index 931fbe1aa012e556a40e4a81b145daa8be59d75a..c0cd1374ff6ad547d206c6304af61eb43c4137bf 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampItemNormalizerTest.php @@ -14,6 +14,7 @@ use Drupal\Core\TypedData\Plugin\DataType\Timestamp; use Drupal\serialization\Normalizer\TimestampItemNormalizer; use Drupal\Tests\UnitTestCase; +use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\Serializer\Serializer; /** @@ -171,9 +172,9 @@ public function testDenormalize(): void { /** * Creates a TimestampItem prophecy. * - * @return \Prophecy\Prophecy\ObjectProphecy|\Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem + * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Field\Plugin\Field\FieldType\TimestampItem> */ - protected function createTimestampItemProphecy() { + protected function createTimestampItemProphecy(): ObjectProphecy { $timestamp_item = $this->prophesize(TimestampItem::class); $timestamp_item->getParent() ->willReturn(TRUE); diff --git a/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php b/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php index 868bfda31c4ec33ce13e555dac6719a17540b4c0..031ac4e6365738405af3e2f52e35ee79dd9ffb5f 100644 --- a/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php @@ -17,6 +17,7 @@ use Drupal\views\ViewEntityInterface; use Drupal\views\ViewExecutable; use Drupal\views\ViewsData; +use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\DependencyInjection\ContainerBuilder; /** @@ -149,9 +150,9 @@ protected function setupEntityTypeManager(EntityTypeManagerInterface $entity_typ * @param \Drupal\Core\Entity\EntityInterface[][] $entity_revisions_by_type * Test entities keyed by entity type and revision ID. * - * @return \Prophecy\Prophecy\ObjectProphecy + * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Entity\EntityTypeManagerInterface> */ - protected function setupEntityTypes($entities_by_type = [], $entity_revisions_by_type = []) { + protected function setupEntityTypes($entities_by_type = [], $entity_revisions_by_type = []): ObjectProphecy { $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class); $entity_type0 = new EntityType([ 'label' => 'First', diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php index b54554dae0f5b0afd0d92f3ba558513bcec33dad..5d4084b5b605cf53a7fb4ba624aa40a77d6e9c5e 100644 --- a/core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Cache\Context\IsFrontPathCacheContext; use Drupal\Core\Path\PathMatcherInterface; use Drupal\Tests\UnitTestCase; +use Prophecy\Prophecy\ObjectProphecy; /** * @coversDefaultClass \Drupal\Core\Cache\Context\IsFrontPathCacheContext @@ -36,9 +37,9 @@ public function testGetContextNotFront(): void { * @param bool $is_front * Whether the page is the front page. * - * @return \Prophecy\Prophecy\ObjectProphecy + * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Path\PathMatcherInterface> */ - protected function createPathMatcher($is_front) { + protected function createPathMatcher($is_front): ObjectProphecy { $path_matcher = $this->prophesize(PathMatcherInterface::class); $path_matcher->isFrontPage() ->willReturn($is_front); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php index d91d633415072cd664024f601fb8e80b3d1ce679..e08b8702ce107fb250d42300b369fecf90bfc4c7 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php @@ -12,6 +12,7 @@ use Drupal\Core\Form\FormState; use Drupal\Core\Routing\RouteMatch; use Drupal\Tests\UnitTestCase; +use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\Routing\Route; /** @@ -244,10 +245,10 @@ public function testGetEntityFromRouteMatchAddEntity(): void { /** * Sets up the storage accessed via the entity type manager in the form. * - * @return \Prophecy\Prophecy\ObjectProphecy + * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Entity\EntityStorageInterface> * The storage prophecy. */ - protected function setUpStorage() { + protected function setUpStorage(): ObjectProphecy { $storage = $this->prophesize(EntityStorageInterface::class); $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class); diff --git a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php index 053c05ebd97e2e9612e7987320b6ad1df2eda6fd..82593d4aa6b26a32efba91dfe0347098629e9f8c 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php @@ -382,9 +382,9 @@ public function testGetEntityTypeIdKeyTypeNotFieldable(): void { * @param \Prophecy\Prophecy\ObjectProphecy|null $base_entity_type * (optional) The prophesize base entity type. * - * @return \Prophecy\Prophecy\ObjectProphecy + * @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Entity\EntityTypeInterface> */ - protected static function getEntityType(?ObjectProphecy $base_entity_type = NULL) { + protected static function getEntityType(?ObjectProphecy $base_entity_type = NULL): ObjectProphecy { $entity_type = (new Prophet())->prophesize(EntityTypeInterface::class); if ($base_entity_type) { foreach ($base_entity_type->getMethodProphecies() as $prophecies) {