Mercurial > hg > cmmr2012-drupal-site
comparison vendor/nikic/php-parser/test/bootstrap.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace PhpParser; | |
4 | |
5 require __DIR__ . '/../vendor/autoload.php'; | |
6 | |
7 function canonicalize($str) { | |
8 // normalize EOL style | |
9 $str = str_replace("\r\n", "\n", $str); | |
10 | |
11 // trim newlines at end | |
12 $str = rtrim($str, "\n"); | |
13 | |
14 // remove trailing whitespace on all lines | |
15 $lines = explode("\n", $str); | |
16 $lines = array_map(function($line) { | |
17 return rtrim($line, " \t"); | |
18 }, $lines); | |
19 return implode("\n", $lines); | |
20 } | |
21 | |
22 function filesInDir($directory, $fileExtension) { | |
23 $directory = realpath($directory); | |
24 $it = new \RecursiveDirectoryIterator($directory); | |
25 $it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::LEAVES_ONLY); | |
26 $it = new \RegexIterator($it, '(\.' . preg_quote($fileExtension) . '$)'); | |
27 foreach ($it as $file) { | |
28 $fileName = $file->getPathname(); | |
29 yield $fileName => file_get_contents($fileName); | |
30 } | |
31 } |