Verified Commit 8b702713 authored by Dave Long's avatar Dave Long
Browse files

docs: #3563727 Fix PHPStan missingType.generics for \ArrayIterator not specifying its types

By: mondrake
By: dcam
(cherry picked from commit b419ec85)
parent 1983827c
Loading
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@
/**
 * Collection of scaffold files.
 *
 * @implements \IteratorAggregate<string, array<string, \Drupal\Composer\Plugin\Scaffold\ScaffoldFileInfo>>
 *
 * @internal
 */
class ScaffoldFileCollection implements \IteratorAggregate {
@@ -22,7 +24,7 @@ class ScaffoldFileCollection implements \IteratorAggregate {
   * scaffold files provided by that package. Each collection of scaffold files
   * is keyed by destination path.
   *
   * @var \Drupal\Composer\Plugin\Scaffold\ScaffoldFileInfo[][]
   * @var array<string, array<string, \Drupal\Composer\Plugin\Scaffold\ScaffoldFileInfo>>
   */
  protected $scaffoldFilesByProject = [];

@@ -113,7 +115,10 @@ protected function checkListHasItemWithContent(array $scaffold_files) {
  }

  /**
   * {@inheritdoc}
   * Retrieves the iterator for the object.
   *
   * @return \ArrayIterator<string, array<string, \Drupal\Composer\Plugin\Scaffold\ScaffoldFileInfo>>
   *   The iterator.
   */
  public function getIterator(): \ArrayIterator {
    return new \ArrayIterator($this->scaffoldFilesByProject);
+0 −78
Original line number Diff line number Diff line
@@ -73,12 +73,6 @@
	'count' => 1,
	'path' => __DIR__ . '/../composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Composer\\\\Plugin\\\\Scaffold\\\\Operations\\\\ScaffoldFileCollection\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/../composer/Plugin/Scaffold/Operations/ScaffoldFileCollection.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Composer\\\\Plugin\\\\Scaffold\\\\Plugin\\:\\:handler\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -3320,12 +3314,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Config/Plugin/Validation/Constraint/RequiredConfigDependenciesConstraintValidator.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Config\\\\Schema\\\\ArrayElement\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Config/Schema/ArrayElement.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Config\\\\Schema\\\\ArrayElement\\:\\:onChange\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -4160,12 +4148,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/ContentEntityBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\ContentEntityBase\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/ContentEntityBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\ContentEntityBase\\:\\:getLanguages\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -5480,24 +5462,12 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Plugin\\\\DataType\\\\ConfigEntityAdapter\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Plugin\\\\DataType\\\\ConfigEntityAdapter\\:\\:onChange\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/Plugin/DataType/ConfigEntityAdapter.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Plugin\\\\DataType\\\\EntityAdapter\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\Plugin\\\\DataType\\\\EntityAdapter\\:\\:onChange\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -10385,24 +10355,12 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/TempStore/SharedTempStore.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Template\\\\Attribute\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Template/Attribute.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Template\\\\Attribute\\:\\:storage\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Template/Attribute.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Template\\\\AttributeArray\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Template/AttributeArray.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Template\\\\AttributeValueBase\\:\\:value\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -10649,12 +10607,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\TypedData\\\\Plugin\\\\DataType\\\\Map\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\TypedData\\\\Plugin\\\\DataType\\\\Map\\:\\:onChange\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -18858,12 +18810,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/Exception/UnprocessableHttpEntityException.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\Data\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/Data.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\Data\\:\\:getTotalCount\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -18882,24 +18828,12 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/Data.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\ErrorCollection\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/ErrorCollection.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\LabelOnlyResourceObject\\:\\:setEntity\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/LabelOnlyResourceObject.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\JsonApiResource\\\\LinkCollection\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/JsonApiResource/LinkCollection.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\JsonapiServiceProvider\\:\\:alter\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -19032,12 +18966,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\Normalizer\\\\Value\\\\TemporaryArrayObjectThrowingExceptions\\:\\:getIteratorClass\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi\\\\ParamConverter\\\\EntityUuidConverter\\:\\:setLanguageManager\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -19158,12 +19086,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/tests/modules/jsonapi_test_data_type/src/Normalizer/TraversableObjectNormalizer.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi_test_data_type\\\\TraversableObject\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
	'count' => 1,
	'path' => __DIR__ . '/modules/jsonapi/tests/modules/jsonapi_test_data_type/src/TraversableObject.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\jsonapi_test_field_type\\\\Normalizer\\\\StringNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#',
	'identifier' => 'missingType.generics',
+7 −2
Original line number Diff line number Diff line
@@ -6,13 +6,15 @@

/**
 * Defines a generic configuration element that contains multiple properties.
 *
 * @implements \IteratorAggregate<string, \Drupal\Core\TypedData\TypedDataInterface>
 */
abstract class ArrayElement extends Element implements \IteratorAggregate, TypedConfigInterface, ComplexDataInterface {

  /**
   * Parsed elements.
   *
   * @var array
   * @var array<string, \Drupal\Core\TypedData\TypedDataInterface>
   */
  protected $elements;

@@ -134,7 +136,10 @@ public function onChange($name) {
  }

  /**
   * {@inheritdoc}
   * Retrieves the iterator for the object.
   *
   * @return \ArrayIterator<string, \Drupal\Core\TypedData\TypedDataInterface>
   *   The iterator.
   */
  public function getIterator(): \ArrayIterator {
    return new \ArrayIterator($this->getElements());
+6 −1
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
/**
 * Implements Entity Field API specific enhancements to the Entity class.
 *
 * @implements \IteratorAggregate<string, \Drupal\Core\Field\FieldItemListInterface>
 *
 * @ingroup entity_api
 */
abstract class ContentEntityBase extends EntityBase implements \IteratorAggregate, ContentEntityInterface, TranslationStatusInterface {
@@ -697,7 +699,10 @@ public function getTranslatableFields($include_computed = TRUE) {
  }

  /**
   * {@inheritdoc}
   * Retrieves the iterator for the object.
   *
   * @return \ArrayIterator<string, \Drupal\Core\Field\FieldItemListInterface<\Drupal\Core\Field\FieldItemInterface>>
   *   The iterator.
   */
  public function getIterator(): \ArrayIterator {
    return new \ArrayIterator($this->getFields());
+4 −1
Original line number Diff line number Diff line
@@ -67,7 +67,10 @@ public function onChange($property_name) {
  }

  /**
   * {@inheritdoc}
   * Retrieves the iterator for the object.
   *
   * @return \ArrayIterator<string, mixed>
   *   The iterator.
   */
  public function getIterator(): \ArrayIterator {
    if (isset($this->entity)) {
Loading