Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/PhpParser/NodeVisitor/NameResolverTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
5 use PhpParser; | 5 use PhpParser; |
6 use PhpParser\Node; | 6 use PhpParser\Node; |
7 use PhpParser\Node\Expr; | 7 use PhpParser\Node\Expr; |
8 use PhpParser\Node\Name; | 8 use PhpParser\Node\Name; |
9 use PhpParser\Node\Stmt; | 9 use PhpParser\Node\Stmt; |
10 use PHPUnit\Framework\TestCase; | 10 |
11 | 11 class NameResolverTest extends \PHPUnit\Framework\TestCase |
12 class NameResolverTest extends TestCase | |
13 { | 12 { |
14 private function canonicalize($string) { | 13 private function canonicalize($string) { |
15 return str_replace("\r\n", "\n", $string); | 14 return str_replace("\r\n", "\n", $string); |
16 } | 15 } |
17 | 16 |
18 /** | 17 /** |
19 * @covers PhpParser\NodeVisitor\NameResolver | 18 * @covers \PhpParser\NodeVisitor\NameResolver |
20 */ | 19 */ |
21 public function testResolveNames() { | 20 public function testResolveNames() { |
22 $code = <<<'EOC' | 21 $code = <<<'EOC' |
23 <?php | 22 <?php |
24 | 23 |
93 e(); | 92 e(); |
94 f(); | 93 f(); |
95 C; | 94 C; |
96 E; | 95 E; |
97 K; | 96 K; |
97 | |
98 class ClassWithTypeProperties | |
99 { | |
100 public float $php = 7.4; | |
101 public ?Foo $person; | |
102 protected static ?bool $probability; | |
103 } | |
98 } | 104 } |
99 EOC; | 105 EOC; |
100 $expectedCode = <<<'EOC' | 106 $expectedCode = <<<'EOC' |
101 namespace Foo { | 107 namespace Foo { |
102 use Hallo as Hi; | 108 use Hallo as Hi; |
161 \X\T\d\e(); | 167 \X\T\d\e(); |
162 \Z\T\f(); | 168 \Z\T\f(); |
163 \Y\T\B\C; | 169 \Y\T\B\C; |
164 \Y\T\D\E; | 170 \Y\T\D\E; |
165 \Z\T\K; | 171 \Z\T\K; |
172 class ClassWithTypeProperties | |
173 { | |
174 public float $php = 7.4; | |
175 public ?\Baz\Foo $person; | |
176 protected static ?bool $probability; | |
177 } | |
166 } | 178 } |
167 EOC; | 179 EOC; |
168 | 180 |
169 $parser = new PhpParser\Parser\Php7(new PhpParser\Lexer\Emulative); | 181 $parser = new PhpParser\Parser\Php7(new PhpParser\Lexer\Emulative); |
170 $prettyPrinter = new PhpParser\PrettyPrinter\Standard; | 182 $prettyPrinter = new PhpParser\PrettyPrinter\Standard; |
179 $prettyPrinter->prettyPrint($stmts) | 191 $prettyPrinter->prettyPrint($stmts) |
180 ); | 192 ); |
181 } | 193 } |
182 | 194 |
183 /** | 195 /** |
184 * @covers PhpParser\NodeVisitor\NameResolver | 196 * @covers \PhpParser\NodeVisitor\NameResolver |
185 */ | 197 */ |
186 public function testResolveLocations() { | 198 public function testResolveLocations() { |
187 $code = <<<'EOC' | 199 $code = <<<'EOC' |
188 <?php | 200 <?php |
189 namespace NS; | 201 namespace NS; |