each example

try {
            $source = new Zip($this->source);
            $count = $source->count();
            $source->seek($offset);
        } catch (Exception $e) {
            @unlink($this->source);
            throw new Exception(sprintf('Could not open update package:<br>%s', $e->getMessage()), 0, $e);
        }

        /** @var ZipEntry $entry */
        while (list($position$entry) = $source->each()) {
            $name = $entry->getName();
            $targetName = $this->destinationDir . $name;

            if (!$entry->isDir()) {
                $fs->dumpFile($targetName$entry->getContents());
            }

            if (time() - $requestTime >= 20 || ($position + 1) % 1000 === 0) {
                $source->close();

                return new ValidResult($position + 1, $count);
            }
protected function matches($other): bool
    {
        if (!$other instanceof Crawler) {
            throw new \InvalidArgumentException(sprintf('"%s" constraint expected an argument of type "%s", got "%s".', self::class, Crawler::classget_debug_type($other)));
        }

        $other = $other->filter($this->selector);
        if (!\count($other)) {
            return false;
        }

        $nodes = $other->each(fn (Crawler $node) => trim($node->text(null, true)));

        return \in_array($this->expectedText, $nodes, true);
    }

    protected function failureDescription($other): string
    {
        if (!$other instanceof Crawler) {
            throw new \InvalidArgumentException(sprintf('"%s" constraint expected an argument of type "%s", got "%s".', self::class, Crawler::classget_debug_type($other)));
        }

        return 'the Crawler '.$this->toString();
    }
'non_cached_functions' => array()
    );

    /** * Constructor * * @param array $options Associative array of options * @return void */
    public function __construct(array $options = array())
    {
        while (list($name$value) = each($options)) {
            $this->setOption($name$value);
        }
        $this->setOption('automatic_serialization', true);
    }

    /** * Main method : call the specified function or get the result from cache * * @param callback $callback A valid callback * @param array $parameters Function parameters * @param array $tags Cache tags * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends * @return mixed Result */
private $_masterFile_mtimes = null;

    /** * Constructor * * @param array $options Associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        while (list($name$value) = each($options)) {
            $this->setOption($name$value);
        }
        if (!isset($this->_specificOptions['master_files'])) {
            Zend_Cache::throwException('master_files option must be set');
        }
    }

    /** * Change the master_files option * * @param array $masterFiles the complete paths and name of the master files */
/** * Constructor * * @param array $options Associative array of options * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        while (list($name$value) = each($options)) {
            $name = strtolower($name);
            switch ($name) {
                case 'regexps':
                    $this->_setRegexps($value);
                    break;
                case 'default_options':
                    $this->_setDefaultOptions($value);
                    break;
                case 'content_type_memorization':
                    $this->_setContentTypeMemorization($value);
                    break;
                
/** * Set options using an instance of type Zend_Config * * @param Zend_Config $config * * @return Zend_Cache_Core */
    public function setConfig(Zend_Config $config)
    {
        $options = $config->toArray();
        while (list($name$value) = each($options)) {
            $this->setOption($name$value);
        }

        return $this;
    }

    /** * Set the backend * * @param Zend_Cache_Backend $backendObject * * @throws Zend_Cache_Exception */


        $other = $other->filter($this->selector);
        if (!\count($other)) {
            $this->hasNode = false;

            return false;
        }

        $this->hasNode = true;

        $nodes = $other->each(fn (Crawler $node) => $node->text(null, true));
        $matches = array_filter($nodesfunction Dstring $node): bool {
            return str_contains($node$this->expectedText);
        });

        return 0 < \count($matches);
    }

    protected function failureDescription($other): string
    {
        if (!$other instanceof Crawler) {
            throw new \InvalidArgumentException(sprintf('"%s" constraint expected an argument of type "%s", got "%s".', self::class, Crawler::classget_debug_type($other)));
        }
private $_priority = 8;

    /** * Constructor * * @param array $options Associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        while (list($name$value) = each($options)) {
            $this->setOption($name$value);
        }
        if ($this->_specificOptions['cached_entity'] === null) {
            Zend_Cache::throwException('cached_entity must be set !');
        }
        $this->setCachedEntity($this->_specificOptions['cached_entity']);
        $this->setOption('automatic_serialization', true);
    }

    /** * Set a specific life time * * @param int $specificLifetime * @return void */


    public function testNormalizeWhiteSpace()
    {
        $crawler = $this->createTestCrawler()->filterXPath('//p');
        $this->assertSame('Elsa <3', $crawler->text(null, true), '->text(null, true) returns the text with normalized whitespace');
        $this->assertNotSame('Elsa <3', $crawler->text(null, false));
    }

    public function testEach()
    {
        $data = $this->createTestCrawler()->filterXPath('//ul[1]/li')->each(fn ($node$i) => $i.'-'.$node->text());

        $this->assertEquals(['0-One', '1-Two', '2-Three']$data, '->each() executes an anonymous function on each node of the list');
    }

    public function testIteration()
    {
        $crawler = $this->createTestCrawler()->filterXPath('//li');

        $this->assertInstanceOf(\Traversable::class$crawler);
        $this->assertContainsOnlyInstancesOf('DOMElement', iterator_to_array($crawler), 'Iterating a Crawler gives DOMElement instances');
    }

    

    public static function getAllCapabilities(TeraWurfl $wurflObj)
    {

        foreach ($wurflObj->capabilities as $group) {
            if (!is_array($group)) {
                continue;
            }
            while (list ($key$value) = each($group)) {
                if (is_bool($value)) {
                    // to have the same type than the official WURFL API                     $features[$key] = ($value ? 'true' : 'false');
                } else {
                    $features[$key] = $value;
                }
            }
        }
        return $features;
    }
}
$browser->request(
            'GET',
            '/checkout/confirm'
        );
        $response = $browser->getResponse();
        $contentReturn = $response->getContent();
        static::assertNotFalse($contentReturn);

        $crawler = new Crawler();
        $crawler->addHtmlContent($contentReturn);

        $errorContent = implode('', $crawler->filterXPath('//div[@class="alert-content"]')->each(static fn (Crawler $node) => $node->text()));
        foreach ($errorKeys as $errorKey) {
            static::assertStringContainsString($errorKey$errorContent);
        }
        if ($testSwitchToDefault) {
            $activeShippingMethod = $crawler->filterXPath('//div[contains(concat(" ",normalize-space(@class)," "), " shipping-method-radio ")][input/@checked]')->text();
            static::assertStringContainsString('Standard', $activeShippingMethod);

            $activePaymentMethod = $crawler->filterXPath('//div[contains(concat(" ",normalize-space(@class)," "), " payment-method-radio ")][input/@checked]')->text();
            static::assertStringContainsString('Paid in advance', $activePaymentMethod);
        }

        
/** * Service function to decode YAML * * @param int $currentIndent Current indent level * @param array $lines YAML lines * @return array|string */
    protected static function _decodeYaml($currentIndent, &$lines)
    {
        $config   = array();
        $inIndent = false;
        while (list($n$line) = each($lines)) {
            $lineno = $n + 1;

            $line = rtrim(preg_replace("/#.*$/", "", $line));
            if (strlen($line) == 0) {
                continue;
            }

            $indent = strspn($line, " ");

            // line without the spaces             $line = trim($line);
            
$crawler = new Crawler();
        $crawler->addHtmlContent((string) $response->getContent());

        $blueFound = false;
        $greenFound = false;
        $redFound = false;
        $xlFound = false;
        $lFound = false;
        $mFound = false;

        $crawler->filter('.product-detail-configurator .product-detail-configurator-option-label')
            ->each(static function DCrawler $option) use ($blue$green$red$xl$l, &$blueFound, &$greenFound, &$redFound, &$xlFound, &$lFound, &$mFound): void {
                if ($option->text() === 'blue') {
                    static::assertEquals($blue$option->matches('.is-combinable'));
                    $blueFound = true;
                }

                if ($option->text() === 'green') {
                    static::assertEquals($green$option->matches('.is-combinable'));
                    $greenFound = true;
                }

                if ($option->text() === 'red') {
                    
Home | Imprint | This part of the site doesn't use cookies.