@param PyStringNode $expectedText

@return string
346893
private function getExpectedOutput(PyStringNode $expectedText)
    {
        $text = strtr($expectedText, ['\'\'\'' => '"""']);

        // windows path fix
        if ('/' !== DIRECTORY_SEPARATOR) {
            $text = preg_replace_callback(
                '/ features\/[^\n ]+/',
                function ($matches) {
                    return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
                },
                $text
            );
            $text = preg_replace_callback(
                '/\<span class\="path"\>features\/[^\<]+/',
                function ($matches) {
                    return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
                },
                $text
            );
            $text = preg_replace_callback(
                '/\+[fd] [^ ]+/',
                function ($matches) {
                    return str_replace('/', DIRECTORY_SEPARATOR, $matches[0]);
                },
                $text
            );
        }

        return $text;
    }
377087
public function assertCommandOutputMatches(PyStringNode $content) {
        Assertion::contains(
            $this->getOutput(),
            str_replace("'''", '"""', (string) $content),
            sprintf('Command output does not match. Actual output: %s', $this->getOutput())
        );
    }
859450
public function assertResponseBodyIsNot(PyStringNode $content) {
        $this->requireResponse();
        $content = (string) $content;

        try {
            Assertion::notSame((string) $this->response->getBody(), $content, sprintf(
                'Did not expect response body to be "%s".',
                $content
            ));
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
957508
private function _convertTagsToEscapeSequences ( $text ) {
        list($patterns, $replacements) = $this->_getConvertingDictionary();
        $convertedText = preg_replace($patterns, $replacements, $text);
        return $convertedText;
    }
97366
protected function getLocale(?string $expectedLocale)
    {
        return $expectedLocale ?? (null === $this->request ? $this->defaultLocale : $this->request->getLocale());
    }
706708
public function PathExpression($expectedTypes)
    {
        $identVariable = $this->IdentificationVariable();
        $field = null;

        if ($this->lexer->isNextToken(Lexer::T_DOT)) {
            $this->match(Lexer::T_DOT);
            $this->match(Lexer::T_IDENTIFIER);

            $field = $this->lexer->token['value'];

            while ($this->lexer->isNextToken(Lexer::T_DOT)) {
                $this->match(Lexer::T_DOT);
                $this->match(Lexer::T_IDENTIFIER);
                $field .= '.'.$this->lexer->token['value'];
            }
        }

        // Creating AST node
        $pathExpr = new AST\PathExpression($expectedTypes, $identVariable, $field);

        // Defer PathExpression validation if requested to be deferred
        $this->deferredPathExpressions[] = array(
            'expression'   => $pathExpr,
            'nestingLevel' => $this->nestingLevel,
            'token'        => $this->lexer->token,
        );

        return $pathExpr;
    }
1320510
public function getMetaBox(string $title): NodeElement
    {
        $metaboxes = $this->findAll('css', '.postbox');
        if ($metaboxes) {
            foreach ($metaboxes as $metabox) {
                if ($metabox->find('css', 'h2')->getText() === $title) {
                    return $metabox;
                }
            }
        }

        throw new ExpectationException(
            sprintf(
                '[W400] Metabox "%s" not found on the screen.',
                $title
            ),
            $this->getDriver()
        );
    }
875498
public function assertContent(PyStringNode $string) {
    $values = $this->getYamlParser()->parse($string);
    $message = __METHOD__ . ": Required fields 'type', 'title' and 'langcode' not found.";
    Assert::keyExists($values, 'type', $message);
    Assert::keyExists($values, 'title', $message);
    Assert::keyExists($values, 'langcode', $message);
    $node = $this->getCore()->entityCreate('node', $values);
    $this->nodes[] = $node;
  }
876424
protected function unmarkedText($text)
    {
        $newText = "";

        if ($this->breaksEnabled)
        {
            $parts = mb_split('[ ]*\n', $text);
        }
        else
        {
            $parts = mb_split('(?:[ ][ ]+|[ ]*\\\\)\n', $text);
        }

        foreach ($parts as $index => &$part)
        {
            if ($index > 0)
            {
                $newText .= "<br />\n";
            }

            // Remove trailing spaces.
            $part = mb_ereg_replace('/[ ]*\n/', "\n", $part);

            // Determine directon
            $ltr = $this->getLtrStrLen($part);
            $rtl = $this->getRtlStrLen($part);
            $dir = null;

            if ($this->isLtr() && $rtl > 0 && $rtl > $ltr)
            {
                $dir = "rtl";
            }
            else if ($this->isRtl() && $ltr > 0 && $ltr > $rtl)
            {
                $dir = "ltr";
            }

            if (!is_null($dir))
            {
                $newText .= "<div dir=\"{$dir}\">{$part}</div>";
            }
            else
            {
                $newText .= $part;
            }
        }

        return $newText;
    }
337334
static function getExcerpt(String $text, int $needlePosition, int $needleLength, int $contextLength) : string
    {
        $left = max($needlePosition - $contextLength, 0);
        $bufferLength = $needleLength + (2 * $contextLength);

        if($needleLength + $contextLength + $needlePosition > strlen($text)) {
            $text = substr($text, $left);
        } else {
            $text = substr($text, $left, $bufferLength);
        }

        return $text;
    }
1326969
function convertText( $text, $isHeader = false )
    {

        $charset = $this->contentCharset();
        if ( $this->isAllowedCharset( $charset ) )
            return $text;
        $outputCharset = $this->outputCharset();
        if ( !$this->TextCodec )
        {
            $this->TextCodec = eZTextCodec::instance( $charset, $outputCharset );
        }
        $newText = $this->TextCodec->convertString( $text );
        return $newText;
    }
790810
private static function parseExpectedKeyword($parser, $token, $expected_keywords)
    {
        if ($token->type === Token::TYPE_KEYWORD) {
            if (in_array($token->keyword, $expected_keywords)) {
                return $token->keyword;
            } else {
                $parser->error('Unexpected keyword', $token);
            }
        } else {
            $parser->error('Unexpected token.', $token);
        }
        return null;
    }
1089876
public function expectImplicit($expectedTag = null): ImplicitTagging
    {
        $el = $this;
        if (!$el instanceof ImplicitTagging) {
            throw new \UnexpectedValueException(
                "Element doesn't implement implicit tagging.");
        }
        if (isset($expectedTag)) {
            $el->expectTagged($expectedTag);
        }
        return $el;
    }
779851
protected function __isValueMatchAsExpected($value, $expectedString)
    {
        $match = false;

        if ($expectedString === null)
            ## undefined expected values must not be NULL
            ## except when it write down on docblock "@return void"
            return $value === null;

        $valueType = strtolower(gettype($value));

        /**
         * @return string|null|object|\Stdclass|void
         */
        $expectedString = explode('|', $expectedString);
        foreach($expectedString as $ext) {
            $ext = strtolower(trim($ext));
            if ($ext == '') continue;

            if ($value === VOID && $ext == 'void')
                $match = true;
            elseif ($valueType === $ext && $value != null)
                $match = true;
            elseif ($valueType === 'object') {
                if (is_a($value, $ext))
                    $match = true;
            }

            if ($match) break;
        }

        return $match;
    }
1067343
protected function syntaxError($expectedDesc, $actualToken = null)
    {
        if (null === $actualToken) {
            $actualToken = $this->lexer->next;
        }
        if (null === $actualToken) {
            $actualDesc = 'end of input';
        } else if ($actualToken[1] === 0) {
            $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
        } else {
            $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
        }

        $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
        if (null !== $actualToken) {
            $ex->setActualToken($actualToken);
        }
        if (null !== $this->context) {
            $ex->setContext($this->context);
        }

        throw $ex;
    }
323676
public static function unexpectedCharacter(Input $definition, array $expected = []): self
    {
        $pointer = self::createPointerString($definition->getInput(), $definition->getIndex());

        if (empty($expected)) {
            return new self("Unexpected character:\n$pointer");
        }

        $expected = $expected ?? $definition->getLatestExpectations();

        $expected = array_map(function (string $e) {
            return "'$e'";
        }, $expected);

        $expected = implode(", ", $expected);

        return new self("Unexpected character (expected $expected):\n$pointer");
    }
578893
public function readValue($token = null, $expectedType = null)
    {
        if ($token === null) {
            $token = $this->tokenizer->getNextToken();
        }

        if ($token === false) {
            if ($expectedType !== null) {
                throw new Type\PdfTypeException('Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE);
            }
            return false;
        }

        switch ($token) {
            case '(':
                $this->ensureExpectedType($token, $expectedType);
                return PdfString::parse($this->streamReader);

            case '<':
                if ($this->streamReader->getByte() === '<') {
                    $this->ensureExpectedType('<<', $expectedType);
                    $this->streamReader->addOffset(1);
                    return PdfDictionary::parse($this->tokenizer, $this->streamReader, $this);
                }

                $this->ensureExpectedType($token, $expectedType);
                return PdfHexString::parse($this->streamReader);

            case '/':
                $this->ensureExpectedType($token, $expectedType);
                return PdfName::parse($this->tokenizer, $this->streamReader);

            case '[':
                $this->ensureExpectedType($token, $expectedType);
                return PdfArray::parse($this->tokenizer, $this);

            default:
                if (\is_numeric($token)) {
                    if (($token2 = $this->tokenizer->getNextToken()) !== false) {
                        if (\is_numeric($token2)) {
                            if (($token3 = $this->tokenizer->getNextToken()) !== false) {
                                switch ($token3) {
                                    case 'obj':
                                        if ($expectedType !== null && $expectedType !== PdfIndirectObject::class) {
                                            throw new Type\PdfTypeException(
                                                'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                                            );
                                        }

                                        return PdfIndirectObject::parse(
                                            $token,
                                            $token2,
                                            $this,
                                            $this->tokenizer,
                                            $this->streamReader
                                        );
                                    case 'R':
                                        if ($expectedType !== null &&
                                            $expectedType !== PdfIndirectObjectReference::class
                                        ) {
                                            throw new Type\PdfTypeException(
                                                'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                                            );
                                        }

                                        return PdfIndirectObjectReference::create($token, $token2);
                                }

                                $this->tokenizer->pushStack($token3);
                            }
                        }

                        $this->tokenizer->pushStack($token2);
                    }

                    if ($expectedType !== null && $expectedType !== PdfNumeric::class) {
                        throw new Type\PdfTypeException(
                            'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                        );
                    }
                    return PdfNumeric::create($token);
                }

                if ($token === 'true' || $token === 'false') {
                    $this->ensureExpectedType($token, $expectedType);
                    return PdfBoolean::create($token === 'true');
                }

                if ($token === 'null') {
                    $this->ensureExpectedType($token, $expectedType);
                    return new PdfNull();
                }

                if ($expectedType !== null && $expectedType !== PdfToken::class) {
                    throw new Type\PdfTypeException(
                        'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                    );
                }

                $v = new PdfToken();
                $v->value = $token;

                return $v;
        }
    }