protected function doTestPrettyPrintMethod($method, $name, $code, $expected, $modeLine) { $lexer = new Lexer\Emulative(); $parser5 = new Parser\Php5($lexer); $parser7 = new Parser\Php7($lexer); list($version, $options) = $this->parseModeLine($modeLine); $prettyPrinter = new Standard($options); try { $output5 = canonicalize($prettyPrinter->{$method}($parser5->parse($code))); } catch (Error $e) { $output5 = null; $this->assertEquals('php7', $version); } try { $output7 = canonicalize($prettyPrinter->{$method}($parser7->parse($code))); } catch (Error $e) { $output7 = null; $this->assertEquals('php5', $version); } if ('php5' === $version) { $this->assertSame($expected, $output5, $name); $this->assertNotSame($expected, $output7, $name); } else { if ('php7' === $version) { $this->assertSame($expected, $output7, $name); $this->assertNotSame($expected, $output5, $name); } else { $this->assertSame($expected, $output5, $name); $this->assertSame($expected, $output7, $name); } } }