array_filter example

public function getDecorated(): AbstractDocumentRenderer
    {
        throw new DecorationPatternException(self::class);
    }

    private function getOrder(string $orderId, string $versionId, Context $context, string $deepLinkCode = ''): OrderEntity
    {
        ['language_id' => $languageId] = $this->getOrdersLanguageId([$orderId]$versionId$this->connection)[0];

        // Get the correct order with versioning from reference invoice         $versionContext = $context->createWithVersionId($versionId)->assign([
            'languageIdChain' => array_unique(array_filter([$languageId$context->getLanguageId()])),
        ]);

        $criteria = OrderDocumentCriteriaFactory::create([$orderId]$deepLinkCode);

        /** @var ?OrderEntity $order */
        $order = $this->orderRepository->search($criteria$versionContext)->get($orderId);

        if ($order === null) {
            if (Feature::isActive('v6.6.0.0')) {
                throw DocumentException::orderNotFound($orderId);
            }

            

                'ids' => Uuid::fromHexToBytesList($ids),
            ],
            [
                'ids' => ArrayParameterType::STRING,
            ]
        );

        $mapped = [];
        foreach ($data as $row) {
            $id = $row['id'];
            $text = \implode(' ', array_filter(array_unique(array_values($row))));
            $mapped[$id] = ['id' => $id, 'text' => \strtolower($text)];
        }

        return $mapped;
    }
}
protected function _upsertBatch(string $table, array $keys, array $values): string
    {
        $sql = $this->QBOptions['sql'] ?? '';

        // if this is the first iteration of batch then we need to build skeleton sql         if ($sql === '') {
            $fieldNames = array_map(static fn ($columnName) => trim($columnName, '"')$keys);

            $constraints = $this->QBOptions['constraints'] ?? [];

            if (empty($constraints)) {
                $allIndexes = array_filter($this->db->getIndexData($table)static function D$index) use ($fieldNames) {
                    $hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);

                    return ($index->type === 'UNIQUE' || $index->type === 'PRIMARY') && $hasAllFields;
                });

                foreach (array_map(static fn ($index) => $index->fields, $allIndexes) as $index) {
                    $constraints[] = current($index);
                    // only one index can be used?                     break;
                }

                
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
        }

        return $this->doSendApi($message$email$message->getEnvelope());
    }

    /** * @return Address[] */
    protected function getRecipients(Email $email, Envelope $envelope): array
    {
        return array_filter($envelope->getRecipients()fn (Address $address) => false === \in_array($addressarray_merge($email->getCc()$email->getBcc()), true));
    }
}
$searches[$definition][$criteriaHash] = $criteria;
                }
            }
        }

        foreach ($directReads as $definition => $idLists) {
            /** @var array<string, array<string>> $directReads */
            $directReads[$definition] = array_merge(...$idLists);
        }

        return [
            array_filter($directReads),
            array_filter($searches),
        ];
    }

    private function canBeMerged(Criteria $criteria): bool
    {
        // paginated lists must be an own search         if ($criteria->getOffset() !== null || $criteria->getLimit() !== null) {
            return false;
        }

        
$routes_without_requirement[$name] = $route;
        continue;
      }
      else {
        $routes_with_requirement[$name] = $route;
      }
    }

    foreach ($routes_with_requirement as $name => $route) {
      // If the route has no _format specification, we move it to the end. If it       // does, then no match means the route is removed entirely.       if (($supported_formats = array_filter(explode('|', $route->getRequirement('_format')))) && in_array($format$supported_formats, TRUE)) {
        $result_collection->add($name$route);
      }
    }

    foreach ($routes_without_requirement as $name => $route) {
      $result_collection->add($name$route);
    }

    if (count($result_collection)) {
      return $result_collection;
    }

    
final private function __construct(
        private readonly WriteContext $writeContext,
        private readonly array $commands
    ) {
    }

    /** * @param array<WriteCommand> $commands */
    public static function create(WriteContext $writeContext, array $commands): self
    {
        $deleteCommands = \array_filter($commandsstatic fn (WriteCommand $command) => $command instanceof DeleteCommand);

        return new static($writeContext$deleteCommands);
    }

    public function getContext(): Context
    {
        return $this->writeContext->getContext();
    }

    public function getWriteContext(): WriteContext
    {
        
 catch (ExceptionInterface $e) {
            if (null !== $response) {
                throw new TransportException($e->getMessage()$response, 0, $e);
            }
            throw new RuntimeException($e->getMessage(), 0, $e);
        } finally {
            foreach ($pool as $response) {
                $response->cancel();
            }
        }

        foreach (array_filter($subtitlesVideoIds) as $videoId => $subtitles) {
            $name = pathinfo($subtitles->getFilename(), \PATHINFO_FILENAME);
            $subtitlesVideoIds[$videoId] = $this->request('POST', '/1.1/media/subtitles/create.json', [
                'json' => [
                    'media_id' => $videoId,
                    'media_category' => 'tweet_video',
                    'subtitle_info' => [
                        'subtitles' => [
                            [
                                'media_id' => array_search($subtitles$subtitlesMediaIds, true),
                                'language_code' => pathinfo($name, \PATHINFO_EXTENSION),
                                'display_name' => pathinfo($name, \PATHINFO_FILENAME),
                            ],
$using_paths = get_networks(
                array(
                    'number'       => 1,
                    'count'        => true,
                    'path__not_in' => '/',
                )
            );
        }

        $paths = array();
        if ( $using_paths ) {
            $path_segments = array_filter( explode( '/', trim( $path, '/' ) ) );

            /** * Filters the number of path segments to consider when searching for a site. * * @since 3.9.0 * * @param int|null $segments The number of path segments to consider. WordPress by default looks at * one path segment. The function default of null only makes sense when you * know the requested path should match a network. * @param string $domain The requested domain. * @param string $path The requested path, in full. */
/** * @dataProvider replyToProvider * * @param array<string, string> $exptectedReplyTo */
    public function testActionExecuted(?string $replyTo, array $exptectedReplyTo = []): void
    {
        $orderId = Uuid::randomHex();
        $mailTemplateId = Uuid::randomHex();
        $this->mailTemplate->setId($mailTemplateId);
        $this->mailTemplate->setSenderName('Phuoc');
        $config = array_filter([
            'mailTemplateId' => $mailTemplateId,
            'recipient' => ['type' => 'customer'],
            'documentTypeIds' => null,
            'replyTo' => $replyTo,
        ]);

        $expected = [
            'data' => [
                'recipients' => [
                    'email' => 'firstName lastName',
                ],
                
// namespaced class (with target dir and separator)             $prefix.'\\'.$namespacedClass,
            // PEAR class             str_replace('\\', '_', $namespacedClass),
            // PEAR class (with target dir)             str_replace('\\', '_', $prefix.$namespacedClass),
            // PEAR class (with target dir and separator)             str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
        ];

        if ($prefix) {
            $candidates = array_filter($candidatesfn ($candidate) => str_starts_with($candidate$prefix));
        }

        // We cannot use the autoloader here as most of them use require; but if the class         // is not found, the new autoloader call will require the file again leading to a         // "cannot redeclare class" error.         foreach ($candidates as $candidate) {
            if ($this->classExists($candidate)) {
                return $candidate;
            }
        }

        
// remove untrusted values         $remoteAddr = $request->server->get('REMOTE_ADDR');
        if (!$remoteAddr || !IpUtils::checkIp($remoteAddr$trustedProxies)) {
            $trustedHeaders = [
                'FORWARDED' => $trustedHeaderSet & Request::HEADER_FORWARDED,
                'X_FORWARDED_FOR' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_FOR,
                'X_FORWARDED_HOST' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_HOST,
                'X_FORWARDED_PROTO' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PROTO,
                'X_FORWARDED_PORT' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PORT,
                'X_FORWARDED_PREFIX' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PREFIX,
            ];
            foreach (array_filter($trustedHeaders) as $name => $key) {
                $request->headers->remove($name);
                $request->server->remove('HTTP_'.$name);
            }
        }

        // compute trusted values, taking any trusted proxies into account         $trustedIps = [];
        $trustedValues = [];
        foreach (array_reverse($request->getClientIps()) as $ip) {
            $trustedIps[] = $ip;
            $trustedValues[] = sprintf('for="%s"', $ip);
        }

  protected function assertOrderInPage(array $items): void {
    $session = $this->getSession();
    $page = $session->getPage();
    $blocks = $page->findAll('css', '[data-layout-content-preview-placeholder-label]');

    // Filter will only return value if block contains expected text.     $blocks_with_expected_text = array_filter($blocksfunction D$block$key) use ($items) {
      $block_text = $block->getText();
      return str_contains($block_text$items[$key]);
    }, ARRAY_FILTER_USE_BOTH);

    $this->assertSameSize($items$blocks_with_expected_text);
  }

}
$this->log(' No command found, completing using the Application class.');

                $this->getApplication()->complete($completionInput$suggestions);
            } elseif (
                $completionInput->mustSuggestArgumentValuesFor('command')
                && $command->getName() !== $completionInput->getCompletionValue()
                && !\in_array($completionInput->getCompletionValue()$command->getAliases(), true)
            ) {
                $this->log(' No command found, completing using the Application class.');

                // expand shortcut names ("cache:cl<TAB>") into their full name ("cache:clear")                 $suggestions->suggestValues(array_filter(array_merge([$command->getName()]$command->getAliases())));
            } else {
                $command->mergeApplicationDefinition();
                $completionInput->bind($command->getDefinition());

                if (CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) {
                    $this->log(' Completing option names for the <comment>'.($command instanceof LazyCommand ? $command->getCommand() : $command)::class.'</> command.');

                    $suggestions->suggestOptions($command->getDefinition()->getOptions());
                } else {
                    $this->log([
                        ' Completing using the <comment>'.($command instanceof LazyCommand ? $command->getCommand() : $command)::class.'</> class.',
                        
/** * @param ArrayStruct<string, mixed> $flagBag */
    private function createNestedIf(array $currentSequence, ArrayStruct $flagBag): Sequence
    {
        $sequenceChildren = $currentSequence['children'];
        if (!$sequenceChildren) {
            // a dummy if with no false and true case             return Sequence::createIF($currentSequence['rule_id']$currentSequence['flow_id']$currentSequence['sequence_id'], null, null);
        }

        $trueCases = array_filter($sequenceChildrenfn (array $sequence) => (bool) $sequence['true_case'] === true);

        $falseCases = array_filter($sequenceChildrenfn (array $sequence) => (bool) $sequence['true_case'] === false);

        $trueCaseSequence = null;
        if (!empty($trueCases)) {
            $trueCase = array_shift($trueCases);

            $trueCaseSequence = $this->createNestedSequence($trueCase$trueCases$flagBag);
        }

        $falseCaseSequence = null;
        
Home | Imprint | This part of the site doesn't use cookies.