@@ -91,6 +91,9 @@ discard block |
||
| 91 | 91 | return $connector; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | + /** |
|
| 95 | + * @param string $name |
|
| 96 | + */ |
|
| 94 | 97 | protected function getHandlerDefaultOption($name) |
| 95 | 98 | { |
| 96 | 99 | $handler = new PHPConsoleHandler(array(), $this->connector); |
@@ -137,6 +140,9 @@ discard block |
||
| 137 | 140 | $this->initLogger()->addDebug($message, $context); |
| 138 | 141 | } |
| 139 | 142 | |
| 143 | + /** |
|
| 144 | + * @param string[] $tagsContextKeys |
|
| 145 | + */ |
|
| 140 | 146 | public function testDebugTags($tagsContextKeys = null) |
| 141 | 147 | { |
| 142 | 148 | $expectedTags = mt_rand(); |
@@ -155,6 +161,9 @@ discard block |
||
| 155 | 161 | } |
| 156 | 162 | } |
| 157 | 163 | |
| 164 | + /** |
|
| 165 | + * @param string[] $classesPartialsTraceIgnore |
|
| 166 | + */ |
|
| 158 | 167 | public function testError($classesPartialsTraceIgnore = null) |
| 159 | 168 | { |
| 160 | 169 | $code = E_USER_NOTICE; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $message = 'test'; |
| 130 | 130 | $tag = 'tag'; |
| 131 | 131 | $context = array($tag, 'custom' => mt_rand()); |
| 132 | - $expectedMessage = $message . ' ' . json_encode(array_slice($context, 1)); |
|
| 132 | + $expectedMessage = $message.' '.json_encode(array_slice($context, 1)); |
|
| 133 | 133 | $this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with( |
| 134 | 134 | $this->equalTo($expectedMessage), |
| 135 | 135 | $this->equalTo($tag) |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | public function testOptionUseOwnErrorsAndExceptionsHandler() |
| 215 | 215 | { |
| 216 | 216 | $this->initLogger(array('useOwnErrorsHandler' => true, 'useOwnExceptionsHandler' => true)); |
| 217 | - $this->assertEquals(array(Handler::getInstance(), 'handleError'), set_error_handler(function () { |
|
| 217 | + $this->assertEquals(array(Handler::getInstance(), 'handleError'), set_error_handler(function() { |
|
| 218 | 218 | })); |
| 219 | - $this->assertEquals(array(Handler::getInstance(), 'handleException'), set_exception_handler(function () { |
|
| 219 | + $this->assertEquals(array(Handler::getInstance(), 'handleException'), set_exception_handler(function() { |
|
| 220 | 220 | })); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -35,6 +35,9 @@ |
||
| 35 | 35 | $this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | + /** |
|
| 39 | + * @param MockRavenClient $ravenClient |
|
| 40 | + */ |
|
| 38 | 41 | protected function getHandler($ravenClient) |
| 39 | 42 | { |
| 40 | 43 | $handler = new RavenHandler($ravenClient); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $this->markTestSkipped('raven/raven not installed'); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - require_once __DIR__ . '/MockRavenClient.php'; |
|
| 26 | + require_once __DIR__.'/MockRavenClient.php'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $logFormatter->expects($this->once())->method('formatBatch'); |
| 172 | 172 | |
| 173 | 173 | $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); |
| 174 | - $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) { |
|
| 174 | + $formatter->expects($this->once())->method('format')->with($this->callback(function($record) { |
|
| 175 | 175 | return $record['level'] == 400; |
| 176 | 176 | })); |
| 177 | 177 | |
@@ -262,12 +262,18 @@ |
||
| 262 | 262 | $this->writeRecord('Hello world'); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | + /** |
|
| 266 | + * @param string $connectionString |
|
| 267 | + */ |
|
| 265 | 268 | private function createHandler($connectionString) |
| 266 | 269 | { |
| 267 | 270 | $this->handler = new SocketHandler($connectionString); |
| 268 | 271 | $this->handler->setFormatter($this->getIdentityFormatter()); |
| 269 | 272 | } |
| 270 | 273 | |
| 274 | + /** |
|
| 275 | + * @param string $string |
|
| 276 | + */ |
|
| 271 | 277 | private function writeRecord($string) |
| 272 | 278 | { |
| 273 | 279 | $this->handler->handle($this->getRecord(Logger::WARNING, $string)); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $this->setMockHandler(array('fwrite')); |
| 129 | 129 | |
| 130 | - $callback = function ($arg) { |
|
| 130 | + $callback = function($arg) { |
|
| 131 | 131 | $map = array( |
| 132 | 132 | 'Hello world' => 6, |
| 133 | 133 | 'world' => false, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | $this->setMockHandler(array('fwrite', 'streamGetMetadata')); |
| 152 | 152 | |
| 153 | - $callback = function ($arg) { |
|
| 153 | + $callback = function($arg) { |
|
| 154 | 154 | $map = array( |
| 155 | 155 | 'Hello world' => 6, |
| 156 | 156 | 'world' => 5, |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $this->setMockHandler(array('fwrite', 'streamGetMetadata')); |
| 178 | 178 | |
| 179 | 179 | $res = $this->res; |
| 180 | - $callback = function ($string) use ($res) { |
|
| 180 | + $callback = function($string) use ($res) { |
|
| 181 | 181 | fclose($res); |
| 182 | 182 | |
| 183 | 183 | return strlen('Hello'); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | $this->setMockHandler(array('fwrite')); |
| 209 | 209 | |
| 210 | - $callback = function ($arg) { |
|
| 210 | + $callback = function($arg) { |
|
| 211 | 211 | $map = array( |
| 212 | 212 | 'Hello world' => 6, |
| 213 | 213 | 'world' => 5, |
@@ -42,6 +42,9 @@ |
||
| 42 | 42 | $handler->handle($this->getRecordWithMessage("hej\nlol")); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | + /** |
|
| 46 | + * @param string $msg |
|
| 47 | + */ |
|
| 45 | 48 | protected function getRecordWithMessage($msg) |
| 46 | 49 | { |
| 47 | 50 | return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol'); |
@@ -210,7 +210,7 @@ |
||
| 210 | 210 | * Get multiple run dates starting at the current date or a specific date |
| 211 | 211 | * |
| 212 | 212 | * @param int $total Set the total number of dates to calculate |
| 213 | - * @param string|\DateTime $currentTime Relative calculation date |
|
| 213 | + * @param string $currentTime Relative calculation date |
|
| 214 | 214 | * @param bool $invert Set to TRUE to retrieve previous dates |
| 215 | 215 | * @param bool $allowCurrentDate Set to TRUE to return the |
| 216 | 216 | * current date if it matches the cron expression |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $this->cronParts = preg_split('/\s/', $value, -1, PREG_SPLIT_NO_EMPTY); |
| 122 | 122 | if (count($this->cronParts) < 5) { |
| 123 | 123 | throw new \InvalidArgumentException( |
| 124 | - $value . ' is not a valid CRON expression' |
|
| 124 | + $value.' is not a valid CRON expression' |
|
| 125 | 125 | ); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | if (!$this->fieldFactory->getField($position)->validate($value)) { |
| 147 | 147 | throw new \InvalidArgumentException( |
| 148 | - 'Invalid CRON field value ' . $value . ' at position ' . $position |
|
| 148 | + 'Invalid CRON field value '.$value.' at position '.$position |
|
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | /** |
| 277 | 277 | * Create a Carbon instance for tomorrow |
| 278 | 278 | * |
| 279 | - * @param DateTimeZone|string|null $tz |
|
| 279 | + * @param DateTimeZone $tz |
|
| 280 | 280 | * |
| 281 | 281 | * @return static |
| 282 | 282 | */ |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | /** |
| 289 | 289 | * Create a Carbon instance for yesterday |
| 290 | 290 | * |
| 291 | - * @param DateTimeZone|string|null $tz |
|
| 291 | + * @param DateTimeZone $tz |
|
| 292 | 292 | * |
| 293 | 293 | * @return static |
| 294 | 294 | */ |
@@ -2053,7 +2053,7 @@ discard block |
||
| 2053 | 2053 | } |
| 2054 | 2054 | |
| 2055 | 2055 | $period = new DatePeriod($start, $ci, $end); |
| 2056 | - $vals = array_filter(iterator_to_array($period), function (DateTime $date) use ($callback) { |
|
| 2056 | + $vals = array_filter(iterator_to_array($period), function(DateTime $date) use ($callback) { |
|
| 2057 | 2057 | return call_user_func($callback, Carbon::instance($date)); |
| 2058 | 2058 | }); |
| 2059 | 2059 | |
@@ -2072,7 +2072,7 @@ discard block |
||
| 2072 | 2072 | */ |
| 2073 | 2073 | public function diffInWeekdays(Carbon $dt = null, $abs = true) |
| 2074 | 2074 | { |
| 2075 | - return $this->diffInDaysFiltered(function (Carbon $date) { |
|
| 2075 | + return $this->diffInDaysFiltered(function(Carbon $date) { |
|
| 2076 | 2076 | return $date->isWeekday(); |
| 2077 | 2077 | }, $dt, $abs); |
| 2078 | 2078 | } |
@@ -2087,7 +2087,7 @@ discard block |
||
| 2087 | 2087 | */ |
| 2088 | 2088 | public function diffInWeekendDays(Carbon $dt = null, $abs = true) |
| 2089 | 2089 | { |
| 2090 | - return $this->diffInDaysFiltered(function (Carbon $date) { |
|
| 2090 | + return $this->diffInDaysFiltered(function(Carbon $date) { |
|
| 2091 | 2091 | return $date->isWeekend(); |
| 2092 | 2092 | }, $dt, $abs); |
| 2093 | 2093 | } |
@@ -20,10 +20,16 @@ |
||
| 20 | 20 | 'case_separator', 'optional_comma' |
| 21 | 21 | )); |
| 22 | 22 | |
| 23 | +/** |
|
| 24 | + * @param string $regex |
|
| 25 | + */ |
|
| 23 | 26 | function regex($regex) { |
| 24 | 27 | return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; |
| 25 | 28 | } |
| 26 | 29 | |
| 30 | +/** |
|
| 31 | + * @param string $regex |
|
| 32 | + */ |
|
| 27 | 33 | function magicSplit($regex, $string) { |
| 28 | 34 | $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); |
| 29 | 35 | |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | )); |
| 22 | 22 | |
| 23 | 23 | function regex($regex) { |
| 24 | - return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; |
|
| 24 | + return '~'.LIB.'(?:'.str_replace('~', '\~', $regex).')~'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function magicSplit($regex, $string) { |
| 28 | - $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); |
|
| 28 | + $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|'.$regex), $string); |
|
| 29 | 29 | |
| 30 | 30 | foreach ($pieces as &$piece) { |
| 31 | 31 | $piece = trim($piece); |
@@ -75,15 +75,15 @@ discard block |
||
| 75 | 75 | || (ctype_upper($part[0]) && !isset($usedTerminals[$part])) |
| 76 | 76 | || (ctype_lower($part[0]) && isset($unusedNonterminals[$part])) |
| 77 | 77 | ) { |
| 78 | - $part = '<span style="background-color: red; color: white;">' . $part . '</span>'; |
|
| 78 | + $part = '<span style="background-color: red; color: white;">'.$part.'</span>'; |
|
| 79 | 79 | } else { |
| 80 | - $part = '<strong><em>' . $part . '</em></strong>'; |
|
| 80 | + $part = '<strong><em>'.$part.'</em></strong>'; |
|
| 81 | 81 | } |
| 82 | 82 | } elseif ((ctype_upper($part[0]) && isset($usedTerminals[$part])) |
| 83 | 83 | || (ctype_lower($part[0]) && !isset($unusedNonterminals[$part])) |
| 84 | 84 | |
| 85 | 85 | ) { |
| 86 | - $part = '<span style="background-color: blue; color: white;">' . $part . '</span>'; |
|
| 86 | + $part = '<span style="background-color: blue; color: white;">'.$part.'</span>'; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | ++$i; |
@@ -92,5 +92,5 @@ discard block |
||
| 92 | 92 | $rule = implode(' ', $parts); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - echo $ruleBlockName, ':', "\n", ' ', implode("\n" . ' | ', $rules), "\n", ';', "\n\n"; |
|
| 95 | + echo $ruleBlockName, ':', "\n", ' ', implode("\n".' | ', $rules), "\n", ';', "\n\n"; |
|
| 96 | 96 | } |
@@ -175,6 +175,9 @@ discard block |
||
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | +/** |
|
| 179 | + * @param integer $num |
|
| 180 | + */ |
|
| 178 | 181 | function assertArgs($num, $args, $name) { |
| 179 | 182 | if ($num != count($args)) { |
| 180 | 183 | die('Wrong argument count for ' . $name . '().'); |
@@ -203,10 +206,16 @@ discard block |
||
| 203 | 206 | /// Regex helper functions /// |
| 204 | 207 | ////////////////////////////// |
| 205 | 208 | |
| 209 | +/** |
|
| 210 | + * @param string $regex |
|
| 211 | + */ |
|
| 206 | 212 | function regex($regex) { |
| 207 | 213 | return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; |
| 208 | 214 | } |
| 209 | 215 | |
| 216 | +/** |
|
| 217 | + * @param string $regex |
|
| 218 | + */ |
|
| 210 | 219 | function magicSplit($regex, $string) { |
| 211 | 220 | $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); |
| 212 | 221 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | assertArgs(2, $args, $name); |
| 139 | 139 | |
| 140 | 140 | return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); }' |
| 141 | - . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; |
|
| 141 | + . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ('toArray' == $name) { |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | assertArgs(3, $args, $name); |
| 158 | 158 | |
| 159 | 159 | return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
| 160 | - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; |
|
| 160 | + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if ('parseEncapsedDoc' == $name) { |
| 164 | 164 | assertArgs(2, $args, $name); |
| 165 | 165 | |
| 166 | 166 | return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
| 167 | - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, ' . $args[1] . '); } }' |
|
| 168 | - . ' $s->value = preg_replace(\'~(\r\n|\n|\r)\z~\', \'\', $s->value);' |
|
| 169 | - . ' if (\'\' === $s->value) array_pop(' . $args[0] . ');'; |
|
| 167 | + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, ' . $args[1] . '); } }' |
|
| 168 | + . ' $s->value = preg_replace(\'~(\r\n|\n|\r)\z~\', \'\', $s->value);' |
|
| 169 | + . ' if (\'\' === $s->value) array_pop(' . $args[0] . ');'; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | return $matches[0]; |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $grammarFileToName = [ |
| 4 | - __DIR__ . '/php5.y' => 'Php5', |
|
| 5 | - __DIR__ . '/php7.y' => 'Php7', |
|
| 4 | + __DIR__.'/php5.y' => 'Php5', |
|
| 5 | + __DIR__.'/php7.y' => 'Php7', |
|
| 6 | 6 | ]; |
| 7 | 7 | |
| 8 | -$tokensFile = __DIR__ . '/tokens.y'; |
|
| 9 | -$tokensTemplate = __DIR__ . '/tokens.template'; |
|
| 10 | -$skeletonFile = __DIR__ . '/parser.template'; |
|
| 11 | -$tmpGrammarFile = __DIR__ . '/tmp_parser.phpy'; |
|
| 12 | -$tmpResultFile = __DIR__ . '/tmp_parser.php'; |
|
| 13 | -$resultDir = __DIR__ . '/../lib/PhpParser/Parser'; |
|
| 14 | -$tokensResultsFile = $resultDir . '/Tokens.php'; |
|
| 8 | +$tokensFile = __DIR__.'/tokens.y'; |
|
| 9 | +$tokensTemplate = __DIR__.'/tokens.template'; |
|
| 10 | +$skeletonFile = __DIR__.'/parser.template'; |
|
| 11 | +$tmpGrammarFile = __DIR__.'/tmp_parser.phpy'; |
|
| 12 | +$tmpResultFile = __DIR__.'/tmp_parser.php'; |
|
| 13 | +$resultDir = __DIR__.'/../lib/PhpParser/Parser'; |
|
| 14 | +$tokensResultsFile = $resultDir.'/Tokens.php'; |
|
| 15 | 15 | |
| 16 | 16 | // check for kmyacc.exe binary in this directory, otherwise fall back to global name |
| 17 | -$kmyacc = __DIR__ . '/kmyacc.exe'; |
|
| 17 | +$kmyacc = __DIR__.'/kmyacc.exe'; |
|
| 18 | 18 | if (!file_exists($kmyacc)) { |
| 19 | 19 | $kmyacc = 'kmyacc'; |
| 20 | 20 | } |
@@ -85,22 +85,22 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | function resolveNodes($code) { |
| 87 | 87 | return preg_replace_callback( |
| 88 | - '~(?<name>[A-Z][a-zA-Z_\\\\]++)\s*' . PARAMS . '~', |
|
| 88 | + '~(?<name>[A-Z][a-zA-Z_\\\\]++)\s*'.PARAMS.'~', |
|
| 89 | 89 | function($matches) { |
| 90 | 90 | // recurse |
| 91 | 91 | $matches['params'] = resolveNodes($matches['params']); |
| 92 | 92 | |
| 93 | 93 | $params = magicSplit( |
| 94 | - '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,', |
|
| 94 | + '(?:'.PARAMS.'|'.ARGS.')(*SKIP)(*FAIL)|,', |
|
| 95 | 95 | $matches['params'] |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | $paramCode = ''; |
| 99 | 99 | foreach ($params as $param) { |
| 100 | - $paramCode .= $param . ', '; |
|
| 100 | + $paramCode .= $param.', '; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - return 'new ' . $matches['name'] . '(' . $paramCode . 'attributes())'; |
|
| 103 | + return 'new '.$matches['name'].'('.$paramCode.'attributes())'; |
|
| 104 | 104 | }, |
| 105 | 105 | $code |
| 106 | 106 | ); |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | function resolveMacros($code) { |
| 110 | 110 | return preg_replace_callback( |
| 111 | - '~\b(?<!::|->)(?!array\()(?<name>[a-z][A-Za-z]++)' . ARGS . '~', |
|
| 111 | + '~\b(?<!::|->)(?!array\()(?<name>[a-z][A-Za-z]++)'.ARGS.'~', |
|
| 112 | 112 | function($matches) { |
| 113 | 113 | // recurse |
| 114 | 114 | $matches['args'] = resolveMacros($matches['args']); |
| 115 | 115 | |
| 116 | 116 | $name = $matches['name']; |
| 117 | 117 | $args = magicSplit( |
| 118 | - '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,', |
|
| 118 | + '(?:'.PARAMS.'|'.ARGS.')(*SKIP)(*FAIL)|,', |
|
| 119 | 119 | $matches['args'] |
| 120 | 120 | ); |
| 121 | 121 | |
@@ -125,48 +125,48 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if ('init' == $name) { |
| 128 | - return '$$ = array(' . implode(', ', $args) . ')'; |
|
| 128 | + return '$$ = array('.implode(', ', $args).')'; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if ('push' == $name) { |
| 132 | 132 | assertArgs(2, $args, $name); |
| 133 | 133 | |
| 134 | - return $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0]; |
|
| 134 | + return $args[0].'[] = '.$args[1].'; $$ = '.$args[0]; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | if ('pushNormalizing' == $name) { |
| 138 | 138 | assertArgs(2, $args, $name); |
| 139 | 139 | |
| 140 | - return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); }' |
|
| 141 | - . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; |
|
| 140 | + return 'if (is_array('.$args[1].')) { $$ = array_merge('.$args[0].', '.$args[1].'); }' |
|
| 141 | + . ' else { '.$args[0].'[] = '.$args[1].'; $$ = '.$args[0].'; }'; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ('toArray' == $name) { |
| 145 | 145 | assertArgs(1, $args, $name); |
| 146 | 146 | |
| 147 | - return 'is_array(' . $args[0] . ') ? ' . $args[0] . ' : array(' . $args[0] . ')'; |
|
| 147 | + return 'is_array('.$args[0].') ? '.$args[0].' : array('.$args[0].')'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | if ('parseVar' == $name) { |
| 151 | 151 | assertArgs(1, $args, $name); |
| 152 | 152 | |
| 153 | - return 'substr(' . $args[0] . ', 1)'; |
|
| 153 | + return 'substr('.$args[0].', 1)'; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | if ('parseEncapsed' == $name) { |
| 157 | 157 | assertArgs(3, $args, $name); |
| 158 | 158 | |
| 159 | - return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
|
| 160 | - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; |
|
| 159 | + return 'foreach ('.$args[0].' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
|
| 160 | + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, '.$args[1].', '.$args[2].'); } }'; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if ('parseEncapsedDoc' == $name) { |
| 164 | 164 | assertArgs(2, $args, $name); |
| 165 | 165 | |
| 166 | - return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
|
| 167 | - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, ' . $args[1] . '); } }' |
|
| 166 | + return 'foreach ('.$args[0].' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
|
| 167 | + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, '.$args[1].'); } }' |
|
| 168 | 168 | . ' $s->value = preg_replace(\'~(\r\n|\n|\r)\z~\', \'\', $s->value);' |
| 169 | - . ' if (\'\' === $s->value) array_pop(' . $args[0] . ');'; |
|
| 169 | + . ' if (\'\' === $s->value) array_pop('.$args[0].');'; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | return $matches[0]; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | function assertArgs($num, $args, $name) { |
| 179 | 179 | if ($num != count($args)) { |
| 180 | - die('Wrong argument count for ' . $name . '().'); |
|
| 180 | + die('Wrong argument count for '.$name.'().'); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -204,11 +204,11 @@ discard block |
||
| 204 | 204 | ////////////////////////////// |
| 205 | 205 | |
| 206 | 206 | function regex($regex) { |
| 207 | - return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; |
|
| 207 | + return '~'.LIB.'(?:'.str_replace('~', '\~', $regex).')~'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | function magicSplit($regex, $string) { |
| 211 | - $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); |
|
| 211 | + $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|'.$regex), $string); |
|
| 212 | 212 | |
| 213 | 213 | foreach ($pieces as &$piece) { |
| 214 | 214 | $piece = trim($piece); |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | /** |
| 96 | 96 | * Adds a statement. |
| 97 | 97 | * |
| 98 | - * @param Node|PhpParser\Builder $stmt The statement to add |
|
| 98 | + * @param Node\Expr\Print_ $stmt The statement to add |
|
| 99 | 99 | * |
| 100 | 100 | * @return $this The builder instance (for fluid interface) |
| 101 | 101 | */ |