annotate vendor/nikic/php-parser/test/updateTests.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 |
|
children |
129ea1e6d783 |
rev |
line source |
Chris@13
|
1 <?php
|
Chris@13
|
2
|
Chris@13
|
3 namespace PhpParser;
|
Chris@13
|
4
|
Chris@13
|
5 require __DIR__ . '/bootstrap.php';
|
Chris@13
|
6 require __DIR__ . '/PhpParser/CodeTestParser.php';
|
Chris@13
|
7 require __DIR__ . '/PhpParser/CodeParsingTest.php';
|
Chris@13
|
8
|
Chris@13
|
9 $dir = __DIR__ . '/code/parser';
|
Chris@13
|
10
|
Chris@13
|
11 $testParser = new CodeTestParser;
|
Chris@13
|
12 $codeParsingTest = new CodeParsingTest;
|
Chris@13
|
13 foreach (filesInDir($dir, 'test') as $fileName => $code) {
|
Chris@13
|
14 if (false !== strpos($code, '@@{')) {
|
Chris@13
|
15 // Skip tests with evaluate segments
|
Chris@13
|
16 continue;
|
Chris@13
|
17 }
|
Chris@13
|
18
|
Chris@13
|
19 list($name, $tests) = $testParser->parseTest($code, 2);
|
Chris@13
|
20 $newTests = [];
|
Chris@13
|
21 foreach ($tests as list($modeLine, list($input, $expected))) {
|
Chris@13
|
22 $modes = null !== $modeLine ? array_fill_keys(explode(',', $modeLine), true) : [];
|
Chris@13
|
23 list($parser5, $parser7) = $codeParsingTest->createParsers($modes);
|
Chris@13
|
24 $output = isset($modes['php5'])
|
Chris@13
|
25 ? $codeParsingTest->getParseOutput($parser5, $input, $modes)
|
Chris@13
|
26 : $codeParsingTest->getParseOutput($parser7, $input, $modes);
|
Chris@13
|
27 $newTests[] = [$modeLine, [$input, $output]];
|
Chris@13
|
28 }
|
Chris@13
|
29
|
Chris@13
|
30 $newCode = $testParser->reconstructTest($name, $newTests);
|
Chris@13
|
31 file_put_contents($fileName, $newCode);
|
Chris@13
|
32 }
|