ArrayIterator example

$this->normalizer = new EntityReferenceFieldItemNormalizer($this->entityRepository->reveal());

    $this->serializer = $this->prophesize(Serializer::class);
    // Set up the serializer to return an entity property.     $this->serializer->normalize(Argument::cetera())
      ->willReturn('test');

    $this->normalizer->setSerializer($this->serializer->reveal());

    $this->fieldItem = $this->prophesize(EntityReferenceItem::class);
    $this->fieldItem->getIterator()
      ->willReturn(new \ArrayIterator(['target_id' => []]));

    $this->fieldDefinition = $this->prophesize(FieldDefinitionInterface::class);
    $this->fieldDefinition->getItemDefinition()
      ->willReturn($this->prophesize(FieldItemDataDefinition::class)->reveal());

  }

  /** * @covers ::supportsNormalization */
  public function testSupportsNormalization() {
    

        $this->blockers = [];
    }

    public function isEmpty(): bool
    {
        return !$this->blockers;
    }

    public function getIterator(): \Traversable
    {
        return new \ArrayIterator($this->blockers);
    }

    public function count(): int
    {
        return \count($this->blockers);
    }
}
if ($input->mustSuggestArgumentValuesFor('name')) {
            $suggestions->suggestValues(array_keys($this->getLoaderPaths()));
        }

        if ($input->mustSuggestOptionValuesFor('format')) {
            $suggestions->suggestValues($this->getAvailableFormatOptions());
        }
    }

    private function displayPathsText(SymfonyStyle $io, string $name): void
    {
        $file = new \ArrayIterator($this->findTemplateFiles($name));
        $paths = $this->getLoaderPaths($name);

        $io->section('Matched File');
        if ($file->valid()) {
            if ($fileLink = $this->getFileLink($file->key())) {
                $io->block($file->current(), 'OK', sprintf('fg=black;bg=green;href=%s', $fileLink), ' ', true);
            } else {
                $io->success($file->current());
            }
            $file->next();

            
return $return;
    }

    /** * Returns an iterator for attributes. * * @return \ArrayIterator<string, mixed> */
    public function getIterator(): \ArrayIterator
    {
        return new \ArrayIterator($this->attributes);
    }

    /** * Returns the number of attributes. */
    public function count(): int
    {
        return \count($this->attributes);
    }
}
// Notify the parent of changes.     if (isset($this->parent)) {
      $this->parent->onChange($this->name);
    }
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function getIterator() {
    return new \ArrayIterator($this->getElements());
  }

  /** * Creates a contained typed configuration object. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition * The data definition object. * @param mixed $value * (optional) The data value. If set, it has to match one of the supported * data type format as documented for the data type classes. * @param string $key * The key of the contained element. * * @return \Drupal\Core\TypedData\TypedDataInterface */
new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']),
        ]);

        $result = $this->executeSearchQuery(1);
        $newNewEntry = $result[0];

        $this->assertCount(2, $newNewEntry->getAttribute('mail'));
    }

    public function testUpdateOperationsWithIterator()
    {
        $iteratorAdd = new \ArrayIterator([
            new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot@example.org', 'fabpot2@example.org']),
            new UpdateOperation(\LDAP_MODIFY_BATCH_ADD, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']),
        ]);

        $iteratorRemove = new \ArrayIterator([
            new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot@example.org', 'fabpot2@example.org']),
            new UpdateOperation(\LDAP_MODIFY_BATCH_REMOVE, 'mail', ['fabpot3@example.org', 'fabpot4@example.org']),
        ]);

        $entryManager = $this->adapter->getEntryManager();

        
public function __clone() {
    foreach ($this->storage as $name => $value) {
      $this->storage[$name] = clone $value;
    }
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function getIterator() {
    return new \ArrayIterator($this->storage);
  }

  /** * Returns the whole array. */
  public function storage() {
    return $this->storage;
  }

  /** * Returns a representation of the object for use in JSON serialization. * * @return string * The safe string content. */
$output->title('First title');

    $output->writeln('Lorem ipsum dolor sit amet');
    $output->title('Second title');

    $output->write('Lorem ipsum dolor sit amet');
    $output->write('');
    $output->title('Third title');

    //Ensure edge case by appending empty strings to history:     $output->write('Lorem ipsum dolor sit amet');
    $output->write(new \ArrayIterator(['', '', '']));
    $output->title('Fourth title');

    //Ensure have manual control over number of blank lines:     $output->writeln('Lorem ipsum dolor sit amet');
    $output->writeln(new \ArrayIterator(['', ''])); //Should append an extra blank line     $output->title('Fifth title');

    $output->writeln('Lorem ipsum dolor sit amet');
    $output->newLine(2); //Should append an extra blank line     $output->title('Fifth title');
};

    protected function setUp(): void
    {
        ResettableService::$counter = 0;
        ClearableService::$counter = 0;
        MultiResettableService::$resetFirstCounter = 0;
        MultiResettableService::$resetSecondCounter = 0;
    }

    public function testResetServices()
    {
        $resetter = new ServicesResetter(new \ArrayIterator([
            'id1' => new ResettableService(),
            'id2' => new ClearableService(),
            'id3' => new MultiResettableService(),
        ])[
            'id1' => ['reset'],
            'id2' => ['clear'],
            'id3' => ['resetFirst', 'resetSecond'],
        ]);

        $resetter->reset();

        
/** * Constructs a LazyRouteCollection. */
  public function __construct(RouteProviderInterface $provider) {
    $this->provider = $provider;
  }

  /** * {@inheritdoc} */
  public function getIterator(): \ArrayIterator {
    return new \ArrayIterator($this->all());
  }

  /** * Gets the number of Routes in this collection. * * @return int * The number of routes */
  public function count(): int {
    return count($this->all());
  }

  
return $this->iterator;
        }

        $array = iterator_to_array($this->iterator, true);

        if (-1 === $this->sort) {
            $array = array_reverse($array);
        } else {
            uasort($array$this->sort);
        }

        return new \ArrayIterator($array);
    }
}
$this->array[$offset] = $value;
        }
    }

    public function offsetUnset($offset): void
    {
        unset($this->array[$offset]);
    }

    public function getIterator(): \Traversable
    {
        return new \ArrayIterator($this->array);
    }

    public function count(): int
    {
        return \count($this->array);
    }

    public function __serialize(): array
    {
        return $this->array;
    }

    
public function __toString() {
    // Filter out any empty values before printing.     $this->value = array_unique(array_filter($this->value));
    return Html::escape(implode(' ', $this->value));
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function getIterator() {
    return new \ArrayIterator($this->value);
  }

  /** * Exchange the array for another one. * * @see ArrayObject::exchangeArray * * @param array $input * The array input to replace the internal value. * * @return array * The old array value. */
$content = new EntityType(['id' => 'test_content']);
    $config = new EntityType(['id' => 'test_config']);

    // Entities without bundles.     $data['content entity, matching type, no value'] = [
      TRUE,
      EntityContextDefinition::fromEntityType($content),
      EntityContextDefinition::fromEntityType($content),
    ];
    $entity = (new Prophet())->prophesize(ContentEntityInterface::class)->willImplement(\IteratorAggregate::class);
    $entity->getIterator()->willReturn(new \ArrayIterator([]));
    $entity->getCacheContexts()->willReturn([]);
    $entity->getCacheTags()->willReturn([]);
    $entity->getCacheMaxAge()->willReturn(0);
    $entity->getEntityTypeId()->willReturn('test_content');
    $data['content entity, matching type, correct value'] = [
      TRUE,
      EntityContextDefinition::fromEntityType($content),
      EntityContextDefinition::fromEntityType($content),
      $entity->reveal(),
    ];
    $data['content entity, incorrect manual constraint'] = [
      
$rows[$index]['field_name'] = $field_name;
          $rows[$index]['type'] = $field_row['type'];
          $rows[$index]['module'] = $field_row['module'];
          $rows[$index]['weight'] = $field_row['weight'];
          $rows[$index]['label'] = $field_row['display_settings']['label']['format'];
          $rows[$index]['display_settings'] = $field_row['display_settings'][$view_mode];
          $rows[$index]['widget_settings'] = $field_row['widget_settings'];
        }
      }
    }

    return new \ArrayIterator($rows);
  }

  /** * {@inheritdoc} */
  public function query() {
    $query = $this->select('content_node_field_instance', 'cnfi')
      ->fields('cnfi', [
        'field_name',
        'type_name',
        'weight',
        
Home | Imprint | This part of the site doesn't use cookies.