Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/PhpParser/NodeDumperTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 <?php | 1 <?php declare(strict_types=1); |
2 | 2 |
3 namespace PhpParser; | 3 namespace PhpParser; |
4 | 4 |
5 class NodeDumperTest extends \PHPUnit_Framework_TestCase | 5 use PHPUnit\Framework\TestCase; |
6 | |
7 class NodeDumperTest extends TestCase | |
6 { | 8 { |
7 private function canonicalize($string) { | 9 private function canonicalize($string) { |
8 return str_replace("\r\n", "\n", $string); | 10 return str_replace("\r\n", "\n", $string); |
9 } | 11 } |
10 | 12 |
16 | 18 |
17 $this->assertSame($this->canonicalize($dump), $this->canonicalize($dumper->dump($node))); | 19 $this->assertSame($this->canonicalize($dump), $this->canonicalize($dumper->dump($node))); |
18 } | 20 } |
19 | 21 |
20 public function provideTestDump() { | 22 public function provideTestDump() { |
21 return array( | 23 return [ |
22 array( | 24 [ |
23 array(), | 25 [], |
24 'array( | 26 'array( |
25 )' | 27 )' |
26 ), | 28 ], |
27 array( | 29 [ |
28 array('Foo', 'Bar', 'Key' => 'FooBar'), | 30 ['Foo', 'Bar', 'Key' => 'FooBar'], |
29 'array( | 31 'array( |
30 0: Foo | 32 0: Foo |
31 1: Bar | 33 1: Bar |
32 Key: FooBar | 34 Key: FooBar |
33 )' | 35 )' |
34 ), | 36 ], |
35 array( | 37 [ |
36 new Node\Name(array('Hallo', 'World')), | 38 new Node\Name(['Hallo', 'World']), |
37 'Name( | 39 'Name( |
38 parts: array( | 40 parts: array( |
39 0: Hallo | 41 0: Hallo |
40 1: World | 42 1: World |
41 ) | 43 ) |
42 )' | 44 )' |
43 ), | 45 ], |
44 array( | 46 [ |
45 new Node\Expr\Array_(array( | 47 new Node\Expr\Array_([ |
46 new Node\Expr\ArrayItem(new Node\Scalar\String_('Foo')) | 48 new Node\Expr\ArrayItem(new Node\Scalar\String_('Foo')) |
47 )), | 49 ]), |
48 'Expr_Array( | 50 'Expr_Array( |
49 items: array( | 51 items: array( |
50 0: Expr_ArrayItem( | 52 0: Expr_ArrayItem( |
51 key: null | 53 key: null |
52 value: Scalar_String( | 54 value: Scalar_String( |
54 ) | 56 ) |
55 byRef: false | 57 byRef: false |
56 ) | 58 ) |
57 ) | 59 ) |
58 )' | 60 )' |
59 ), | 61 ], |
60 ); | 62 ]; |
61 } | 63 } |
62 | 64 |
63 public function testDumpWithPositions() { | 65 public function testDumpWithPositions() { |
64 $parser = (new ParserFactory)->create( | 66 $parser = (new ParserFactory)->create( |
65 ParserFactory::ONLY_PHP7, | 67 ParserFactory::ONLY_PHP7, |
68 $dumper = new NodeDumper(['dumpPositions' => true]); | 70 $dumper = new NodeDumper(['dumpPositions' => true]); |
69 | 71 |
70 $code = "<?php\n\$a = 1;\necho \$a;"; | 72 $code = "<?php\n\$a = 1;\necho \$a;"; |
71 $expected = <<<'OUT' | 73 $expected = <<<'OUT' |
72 array( | 74 array( |
73 0: Expr_Assign[2:1 - 2:6]( | 75 0: Stmt_Expression[2:1 - 2:7]( |
74 var: Expr_Variable[2:1 - 2:2]( | 76 expr: Expr_Assign[2:1 - 2:6]( |
75 name: a | 77 var: Expr_Variable[2:1 - 2:2]( |
76 ) | 78 name: a |
77 expr: Scalar_LNumber[2:6 - 2:6]( | 79 ) |
78 value: 1 | 80 expr: Scalar_LNumber[2:6 - 2:6]( |
81 value: 1 | |
82 ) | |
79 ) | 83 ) |
80 ) | 84 ) |
81 1: Stmt_Echo[3:1 - 3:8]( | 85 1: Stmt_Echo[3:1 - 3:8]( |
82 exprs: array( | 86 exprs: array( |
83 0: Expr_Variable[3:6 - 3:7]( | 87 0: Expr_Variable[3:6 - 3:7]( |