@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @param Context $context |
| 37 | - * @return iterable |
|
| 37 | + * @return \Generator |
|
| 38 | 38 | */ |
| 39 | 39 | public function getOpcodes(Context $context): iterable |
| 40 | 40 | { |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @param Context $context |
| 54 | - * @return iterable |
|
| 54 | + * @return \Generator |
|
| 55 | 55 | */ |
| 56 | 56 | public function getOpcodes(Context $context): iterable |
| 57 | 57 | { |
@@ -20,8 +20,6 @@ |
||
| 20 | 20 | use Railt\SDL\Frontend\Context; |
| 21 | 21 | use Railt\SDL\Frontend\IR\Opcode; |
| 22 | 22 | use Railt\SDL\Frontend\IR\Opcode\DefineOpcode; |
| 23 | -use Railt\SDL\Frontend\IR\OpcodeHeap; |
|
| 24 | -use Railt\SDL\Frontend\IR\OpcodeInterface; |
|
| 25 | 23 | |
| 26 | 24 | /** |
| 27 | 25 | * Class DependentTypeDefinitionNode |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * @param Context $context |
| 33 | - * @return iterable |
|
| 33 | + * @return \Generator |
|
| 34 | 34 | */ |
| 35 | 35 | public function getOpcodes(Context $context): iterable |
| 36 | 36 | { |
@@ -19,7 +19,6 @@ |
||
| 19 | 19 | use Railt\SDL\Frontend\IR\Opcode\CompareOpcode; |
| 20 | 20 | use Railt\SDL\Frontend\IR\Opcode\CallOpcode; |
| 21 | 21 | use Railt\SDL\Frontend\IR\Opcode\FetchOpcode; |
| 22 | -use Railt\SDL\Frontend\IR\Opcode\DefineOpcode; |
|
| 23 | 22 | |
| 24 | 23 | /** |
| 25 | 24 | * Class ArgumentInvocationNode |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @param Context $context |
| 34 | - * @return iterable |
|
| 34 | + * @return \Generator |
|
| 35 | 35 | */ |
| 36 | 36 | public function getOpcodes(Context $context): iterable |
| 37 | 37 | { |
@@ -17,7 +17,6 @@ |
||
| 17 | 17 | use Railt\SDL\Frontend\AST\ProvidesType; |
| 18 | 18 | use Railt\SDL\Frontend\AST\Support\TypeNameProvider; |
| 19 | 19 | use Railt\SDL\Frontend\Context; |
| 20 | -use Railt\SDL\Frontend\IR\Opcode; |
|
| 21 | 20 | use Railt\SDL\Frontend\IR\Opcode\CallOpcode; |
| 22 | 21 | use Railt\SDL\Frontend\IR\Opcode\CompareOpcode; |
| 23 | 22 | use Railt\SDL\Frontend\IR\Opcode\FetchOpcode; |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * @return iterable|array[] |
|
| 51 | + * @return \Generator |
|
| 52 | 52 | */ |
| 53 | 53 | public function getValues(): iterable |
| 54 | 54 | { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | * @var ValueInterface $value |
| 42 | 42 | */ |
| 43 | 43 | foreach ($this->getValues() as [$name, $value]) { |
| 44 | - $result[] = $name . ': ' . $value->toString(); |
|
| 44 | + $result[] = $name.': '.$value->toString(); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return \sprintf('{%s}', \implode(', ', $result)); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @param Readable $file |
| 60 | - * @return iterable|OpcodeInterface[] |
|
| 60 | + * @return \Generator |
|
| 61 | 61 | * @throws SyntaxException |
| 62 | 62 | */ |
| 63 | 63 | public function load(Readable $file): iterable |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * @param NodeInterface $node |
| 88 | - * @return iterable|Opcode[]|\Generator |
|
| 88 | + * @return \Generator |
|
| 89 | 89 | */ |
| 90 | 90 | private function bypass(NodeInterface $node): \Generator |
| 91 | 91 | { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * @param ProvidesOpcode $provider |
| 111 | - * @return \Generator|OpcodeInterface[] |
|
| 111 | + * @return \Generator |
|
| 112 | 112 | */ |
| 113 | 113 | private function extract(ProvidesOpcode $provider): \Generator |
| 114 | 114 | { |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Railt\Io\Readable; |
| 15 | 15 | use Railt\Parser\Ast\NodeInterface; |
| 16 | 16 | use Railt\Parser\Ast\RuleInterface; |
| 17 | -use Railt\Parser\Exception\UnexpectedTokenException; |
|
| 18 | 17 | use Railt\Parser\Exception\UnrecognizedTokenException; |
| 19 | 18 | use Railt\SDL\Exception\SyntaxException; |
| 20 | 19 | use Railt\SDL\Frontend\AST\ProvidesOpcode; |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | return $value->toString(); |
| 83 | 83 | |
| 84 | 84 | case $value instanceof TypeInterface: |
| 85 | - return '$' . $value->getName(); |
|
| 85 | + return '$'.$value->getName(); |
|
| 86 | 86 | |
| 87 | 87 | case $value instanceof JoinableOpcode: |
| 88 | - return '!' . $value->getId(); |
|
| 88 | + return '!'.$value->getId(); |
|
| 89 | 89 | |
| 90 | 90 | case $value instanceof OpcodeInterface: |
| 91 | 91 | return $value->getName(); |
| 92 | 92 | |
| 93 | 93 | case $value instanceof Readable: |
| 94 | - return 'file:' . $value->getPathname(); |
|
| 94 | + return 'file:'.$value->getPathname(); |
|
| 95 | 95 | |
| 96 | 96 | case \is_bool($value): |
| 97 | - return '(php:bool)' . ($value ? 'true' : 'false'); |
|
| 97 | + return '(php:bool)'.($value ? 'true' : 'false'); |
|
| 98 | 98 | |
| 99 | 99 | case $value === null: |
| 100 | 100 | return '(php:null)null'; |
| 101 | 101 | |
| 102 | 102 | case \is_scalar($value): |
| 103 | 103 | $type = \gettype($value); |
| 104 | - $minified = \preg_replace('/\s+/', ' ', (string)$value); |
|
| 105 | - return '(php:' . $type . ')"' . \addcslashes($minified, '"') . '"'; |
|
| 104 | + $minified = \preg_replace('/\s+/', ' ', (string) $value); |
|
| 105 | + return '(php:'.$type.')"'.\addcslashes($minified, '"').'"'; |
|
| 106 | 106 | |
| 107 | 107 | case \is_object($value): |
| 108 | - return \get_class($value) . '#' . \spl_object_hash($value); |
|
| 108 | + return \get_class($value).'#'.\spl_object_hash($value); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return ''; |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function __toString(): string |
| 118 | 118 | { |
| 119 | - $operands = \array_map(function ($value): string { |
|
| 119 | + $operands = \array_map(function($value): string { |
|
| 120 | 120 | return $this->operandToString($value); |
| 121 | 121 | }, $this->operands); |
| 122 | 122 | |
| 123 | - return \sprintf('%-20s %-20s', $this->getName(), '{' . \implode(', ', $operands) . '}'); |
|
| 123 | + return \sprintf('%-20s %-20s', $this->getName(), '{'.\implode(', ', $operands).'}'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->file = $file; |
| 53 | 53 | $this->offset = $offset; |
| 54 | 54 | $this->description = function() use ($opcode): string { |
| 55 | - return \trim((string)(new \ReflectionObject($opcode))->getDocComment(), " \t\n\r\0\x0B/*"); |
|
| 55 | + return \trim((string) (new \ReflectionObject($opcode))->getDocComment(), " \t\n\r\0\x0B/*"); |
|
| 56 | 56 | }; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function getDescription(): string |
| 63 | 63 | { |
| 64 | 64 | return \preg_replace_callback('/\$(\d+)/iu', function(array $m): string { |
| 65 | - return $this->operandToString($this->operands[(int)$m[1]] ?? null); |
|
| 65 | + return $this->operandToString($this->operands[(int) $m[1]] ?? null); |
|
| 66 | 66 | }, ($this->description)()); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | public function __toString(): string |
| 113 | 113 | { |
| 114 | 114 | return \vsprintf('%4s %-10s %-3d %-3d %s', [ |
| 115 | - '#' . $this->getId(), |
|
| 115 | + '#'.$this->getId(), |
|
| 116 | 116 | \pathinfo($this->getFile()->getPathname(), \PATHINFO_FILENAME), |
| 117 | 117 | $this->getLine(), |
| 118 | 118 | $this->getColumn(), |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $result |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - return '(string)' . \sprintf('"%s"', $result); |
|
| 42 | + return '(string)'.\sprintf('"%s"', $result); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | private function renderUtfSequences(string $body): string |
| 102 | 102 | { |
| 103 | - $callee = function (array $matches): string { |
|
| 103 | + $callee = function(array $matches): string { |
|
| 104 | 104 | [$char, $code] = [$matches[0], $matches[1]]; |
| 105 | 105 | |
| 106 | 106 | try { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | try { |
| 132 | 132 | if (\function_exists('\\json_decode')) { |
| 133 | - $result = @\json_decode('{"char": "' . $body . '"}')->char; |
|
| 133 | + $result = @\json_decode('{"char": "'.$body.'"}')->char; |
|
| 134 | 134 | |
| 135 | 135 | if (\json_last_error() === \JSON_ERROR_NONE) { |
| 136 | 136 | $body = $result; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | private function renderSpecialCharacters(string $body): string |
| 152 | 152 | { |
| 153 | - $callee = function (array $matches): string { |
|
| 153 | + $callee = function(array $matches): string { |
|
| 154 | 154 | [$char, $code] = [$matches[0], $matches[1]]; |
| 155 | 155 | |
| 156 | 156 | switch ($code) { |