@@ -41,7 +41,7 @@ |
||
41 | 41 | /** |
42 | 42 | * @param Readable $input |
43 | 43 | * @param bool $eoi |
44 | - * @return \Traversable|TokenInterface[] |
|
44 | + * @return \Generator |
|
45 | 45 | */ |
46 | 46 | public function lex(Readable $input, bool $eoi = false): \Traversable |
47 | 47 | { |
@@ -33,9 +33,9 @@ |
||
33 | 33 | { |
34 | 34 | $isSkipped = \in_array($token->name(), $this->skip, true); |
35 | 35 | |
36 | - $allowsEoi = ($token instanceof Eoi && $eoi) || ! ($token instanceof Eoi); |
|
36 | + $allowsEoi = ($token instanceof Eoi && $eoi) || !($token instanceof Eoi); |
|
37 | 37 | |
38 | - return ! $isSkipped && $allowsEoi; |
|
38 | + return !$isSkipped && $allowsEoi; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | - * @return iterable |
|
92 | + * @return \Generator |
|
93 | 93 | */ |
94 | 94 | public function getDefinedTokens(): iterable |
95 | 95 | { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param Readable $input |
103 | - * @return \Traversable|TokenInterface[] |
|
103 | + * @return \Generator |
|
104 | 104 | */ |
105 | 105 | protected function exec(Readable $input): \Traversable |
106 | 106 | { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function __construct() |
54 | 54 | { |
55 | - if (! \class_exists(Parle::class)) { |
|
55 | + if (!\class_exists(Parle::class)) { |
|
56 | 56 | throw new UnsupportedLexerRuntimeException('This runtime required parle extension'); |
57 | 57 | } |
58 | 58 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $this->map[$this->id] = $name; |
75 | 75 | $this->tokens[$this->id] = $pcre; |
76 | 76 | } catch (LexerException $e) { |
77 | - $message = \preg_replace('/rule\h+id\h+\d+/iu', 'token ' . $name, $e->getMessage()); |
|
77 | + $message = \preg_replace('/rule\h+id\h+\d+/iu', 'token '.$name, $e->getMessage()); |
|
78 | 78 | |
79 | 79 | throw new BadLexemeException($message); |
80 | 80 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | public function __construct(string $name, $value, int $offset = 0) |
39 | 39 | { |
40 | 40 | $this->name = $name; |
41 | - $this->value = (array)$value; |
|
41 | + $this->value = (array) $value; |
|
42 | 42 | $this->offset = $offset; |
43 | 43 | } |
44 | 44 |
@@ -51,7 +51,7 @@ |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | - * @param int|null $offset |
|
54 | + * @param integer $offset |
|
55 | 55 | * @return string|null |
56 | 56 | */ |
57 | 57 | public function value(int $offset = 0): ?string |
@@ -31,12 +31,12 @@ |
||
31 | 31 | */ |
32 | 32 | public function __toString(): string |
33 | 33 | { |
34 | - $format = function (string $value) { |
|
35 | - $value = (string)(\preg_replace('/\s+/iu', ' ', $value) ?? $value); |
|
34 | + $format = function(string $value) { |
|
35 | + $value = (string) (\preg_replace('/\s+/iu', ' ', $value) ?? $value); |
|
36 | 36 | $value = \addcslashes($value, '"'); |
37 | 37 | |
38 | 38 | if (\mb_strlen($value) > 35) { |
39 | - $value = \mb_substr($value, 0, 30) . |
|
39 | + $value = \mb_substr($value, 0, 30). |
|
40 | 40 | \sprintf('… (%s+)', \mb_strlen($value) - 30); |
41 | 41 | } |
42 | 42 |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function escapeTokenPattern(string $value): string |
98 | 98 | { |
99 | - return \str_replace(static::REGEX_DELIMITER, '\\' . self::REGEX_DELIMITER, $value); |
|
99 | + return \str_replace(static::REGEX_DELIMITER, '\\'.self::REGEX_DELIMITER, $value); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | private function renderFlags(): string |
106 | 106 | { |
107 | - return self::FLAG_UNICODE . self::FLAG_DOT_ALL . self::FLAG_ANALYZED; |
|
107 | + return self::FLAG_UNICODE.self::FLAG_DOT_ALL.self::FLAG_ANALYZED; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $result = new \SplQueue(); |
53 | 53 | |
54 | - $status = @\preg_replace_callback($this->pattern, function (array $matches) use ($result): void { |
|
54 | + $status = @\preg_replace_callback($this->pattern, function(array $matches) use ($result): void { |
|
55 | 55 | $result->push($matches); |
56 | 56 | }, $this->subject); |
57 | 57 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | case \PREG_BAD_UTF8_OFFSET_ERROR: |
100 | 100 | return self::PREG_BAD_UTF8_OFFSET_ERROR; |
101 | 101 | } |
102 | - return 'Unexpected PCRE error (Code ' . $code . ')'; |
|
102 | + return 'Unexpected PCRE error (Code '.$code.')'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $context = []; |
26 | 26 | |
27 | 27 | foreach (\array_reverse($result) as $index => $body) { |
28 | - if (! \is_string($index)) { |
|
28 | + if (!\is_string($index)) { |
|
29 | 29 | $context[] = $body; |
30 | 30 | continue; |
31 | 31 | } |