getIterator example


  }

  /** * Data provider for all the composer.json provided by Drupal core. * * @return array */
  public function providerTestComposerJson() {
    $data = [];
    $composer_json_finder = $this->getComposerJsonFinder(realpath(__DIR__ . '/../../../../'));
    foreach ($composer_json_finder->getIterator() as $composer_json) {
      $data[$composer_json->getPathname()] = [$composer_json->getPathname()];
    }
    return $data;
  }

  /** * Tests core's composer.json replace section. * * Verify that all core components are also listed in the 'replace' section of * core's composer.json. */
  

    public static function validateInput(string $caller, mixed $input): mixed
    {
        if (null !== $input) {
            if (\is_resource($input)) {
                return $input;
            }
            if (\is_scalar($input)) {
                return (string) $input;
            }
            if ($input instanceof Process) {
                return $input->getIterator($input::ITER_SKIP_ERR);
            }
            if ($input instanceof \Iterator) {
                return $input;
            }
            if ($input instanceof \Traversable) {
                return new \IteratorIterator($input);
            }

            throw new InvalidArgumentException(sprintf('"%s" only accepts strings, Traversable objects or stream resources.', $caller));
        }

        
fn (ShippingMethodEntity $shippingMethod) => \in_array($shippingMethod->getAvailabilityRuleId()$salesChannelContext->getRuleIds(), true)
        );
    }

    /** * @return list<string> */
    public function getPriceIds(): array
    {
        $ids = [[]];

        foreach ($this->getIterator() as $element) {
            $ids[] = $element->getPrices()->getIds();
        }

        return array_merge(...$ids);
    }

    public function getPrices(): ShippingMethodPriceCollection
    {
        $prices = [[]];

        foreach ($this->getIterator() as $element) {
            
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $finder = new Finder();

        $phpCoveragePerArea = [];
        $jsCoveragePerArea = [];

        foreach ($finder->in($this->projectDir . '/coverage/php')->depth(0)->directories() as $dir) {
            // We need to create a new Instance of Finder every time, because Symfony Finder doesn't reset it's internal state             $finder = new Finder();
            $xmlFiles = $finder->in($dir->getRealPath())->files()->name('cobertura.xml')->getIterator();
            $xmlFiles->rewind();
            $xml = new Crawler(file_get_contents($xmlFiles->current()->getRealPath()) ?: '');
            $phpCoveragePerArea[$dir->getFilename()] = $xml;
        }

        $finder = new Finder();
        $jsAreas = $finder->in($this->projectDir . '/coverage/js')->depth(0)->directories();

        foreach ($finder->in($this->projectDir . '/coverage/js')->depth(0)->directories() as $moduleDirectory) {
            $finder = new Finder();
            foreach ($finder->in($moduleDirectory->getRealPath())->depth(0)->directories() as $areaDirectory) {
                
  public function offsetUnset($offset) {
    @trigger_error($this->message, E_USER_DEPRECATED);
    parent::offsetUnset($offset);
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function getIterator() {
    @trigger_error($this->message, E_USER_DEPRECATED);
    return parent::getIterator();
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function unserialize($serialized) {
    @trigger_error($this->message, E_USER_DEPRECATED);
    parent::unserialize($serialized);
  }

  
protected function getExpectedClass(): string
    {
        return CmsSlotEntity::class;
    }

    private function createSlotHashMap(): void
    {
        if ($this->slotCache !== null) {
            return;
        }

        foreach ($this->getIterator() as $element) {
            $this->slotCache[$element->getSlot()] = $element;
        }
    }
}
private readonly AbstractStoreAppLifecycleService $appLifecycle
    ) {
    }

    public function updateApps(Context $context): void
    {
        $extensions = $this->extensionDataProvider->getInstalledExtensions($context, true);
        $extensions = $extensions->filterByType(ExtensionStruct::EXTENSION_TYPE_APP);

        $outdatedApps = [];

        foreach ($extensions->getIterator() as $extension) {
            $id = $extension->getLocalId();
            if (!$id) {
                continue;
            }
            /** @var AppEntity $localApp */
            $localApp = $this->appRepo->search(new Criteria([$id])$context)->first();
            $nextVersion = $extension->getLatestVersion();
            if (!$nextVersion) {
                continue;
            }

            
/** * @extends EntityCollection<CountryEntity> */
#[Package('core')] class CountryCollection extends EntityCollection
{
    public function sortCountryAndStates(): void
    {
        $this->sortByPositionAndName();

        foreach ($this->getIterator() as $country) {
            if ($country->getStates()) {
                $country->getStates()->sortByPositionAndName();
            }
        }
    }

    public function sortByPositionAndName(): void
    {
        uasort($this->elements, static function DCountryEntity $a, CountryEntity $b) {
            $aPosition = $a->getPosition();
            $bPosition = $b->getPosition();

            

  protected function validateSlots(Component $component, Node $node): void {
    $metadata = $component->metadata;
    if (!$metadata->mandatorySchemas) {
      return;
    }
    $slot_definitions = $metadata->slots;
    $ids_available = array_keys($slot_definitions);
    $undocumented_ids = [];
    try {
      $it = $node->getIterator();
    }
    catch (\Exception $e) {
      return;
    }
    if ($it instanceof \SeekableIterator) {
      while ($it->valid()) {
        $provided_id = $it->key();
        if (!in_array($provided_id$ids_available, TRUE)) {
          $undocumented_ids[] = $provided_id;
        }
        $it->next();
      }
$authors = $this->connection->fetchAllKeyValue(' SELECT `base_class` AS `baseClass`, `author` FROM `plugin` ');
        } catch (Exception) {
            // to get it working in setup without a database connection             $authors = [];
        }

        $snippetFiles = [];

        foreach ($finder->getIterator() as $fileInfo) {
            $nameParts = explode('.', $fileInfo->getFilenameWithoutExtension());

            $snippetFile = null;
            switch (\count($nameParts)) {
                case 2:
                    $snippetFile = new GenericSnippetFile(
                        implode('.', $nameParts),
                        $fileInfo->getPathname(),
                        $nameParts[1],
                        $this->getAuthorFromBundle($bundle$authors),
                        false,
                        

  protected function getAll($prefix = '') {
    return $this->getIterator('/^' . preg_quote($this->getApcuKey($prefix), '/') . '/');
  }

  /** * Prepares a cached item. * * Checks that the item is either permanent or did not expire. * * @param object $cache * An item loaded from self::get() or self::getMultiple(). * @param bool $allow_invalid * If TRUE, a cache item may be returned even if it is expired or has been * invalidated. See ::get(). * * @return mixed * The cache item or FALSE if the item expired. */

  protected function normalizeErrorDocument(JsonApiDocumentTopLevel $document$format, array $context = []) {
    $normalized_values = array_map(function DHttpExceptionInterface $exception) use ($format$context) {
      return $this->serializer->normalize($exception$format$context);
    }(array) $document->getData()->getIterator());
    $cacheability = new CacheableMetadata();
    $errors = [];
    foreach ($normalized_values as $normalized_error) {
      $cacheability->addCacheableDependency($normalized_error);
      $errors = array_merge($errors$normalized_error->getNormalization());
    }
    return new CacheableNormalization($cacheability$errors);
  }

  /** * Normalizes omitted data into a set of omission links. * * @param \Drupal\jsonapi\JsonApiResource\OmittedData $omissions * The omitted response data. * @param string $format * The normalization format. * @param array $context * The normalization context. * * @return \Drupal\jsonapi\Normalizer\Value\CacheableNormalization|\Drupal\jsonapi\Normalizer\Value\CacheableOmission * The normalized omissions. * * @todo: refactor this to use link collections in https://www.drupal.org/project/drupal/issues/3036279. */
$this->fmap(fn (ProductEntity $product) => $product->getUnit())
        );
    }

    /** * @return list<string> */
    public function getPriceIds(): array
    {
        $ids = [[]];

        foreach ($this->getIterator() as $element) {
            if ($element->getPrices() !== null) {
                $ids[] = $element->getPrices()->getIds();
            }
        }

        return array_merge(...$ids);
    }

    public function getPrices(): ProductPriceCollection
    {
        $rules = [[]];

        
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
use Shopware\Core\Framework\Log\Package;

/** * @extends EntityCollection<TaxRuleTypeEntity> */
#[Package('checkout')] class TaxRuleTypeCollection extends EntityCollection
{
    public function getByTechnicalName(string $technicalName): ?TaxRuleTypeEntity
    {
        foreach ($this->getIterator() as $ruleTypeEntity) {
            if ($ruleTypeEntity->getTechnicalName() === $technicalName) {
                return $ruleTypeEntity;
            }
        }

        return null;
    }

    public function getApiAlias(): string
    {
        return 'tax_rule_type_collection';
    }
$finder = new Finder();
        $finder->in($this->rootDirs)
            ->files()
            ->name('*.php')
            ->contains($regex);

        foreach ($this->blacklist as $path) {
            $finder->notPath($path);
        }

        foreach ($finder->getIterator() as $file) {
            $filePath = $file->getRealPath();
            $content = file_get_contents($filePath);

            foreach ($regexParts as $key => $regexPart) {
                if (preg_match('/' . $regexPart . '/s', $content)) {
                    unset($regexParts[$key]);
                }
            }
        }

        if (!empty($regexParts)) {
            
Home | Imprint | This part of the site doesn't use cookies.