You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/SourceSyntaxTest.php

23 lines
908 B
PHP

<?php
// Native PHP parser pass; never require the application or configuration.
$root = dirname(__DIR__);
$iterator = new RecursiveIteratorIterator(new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS),
static fn ($entry) => !$entry->isDir() || !in_array($entry->getFilename(), ['vendor', '.git', 'node_modules', 'storage'], true)
));
$count = 0;
foreach ($iterator as $file) {
$name = $file->getFilename();
if (!str_ends_with($name, '.php') && !str_ends_with($name, '.php.example')) {
continue;
}
try {
token_get_all(file_get_contents($file->getPathname()), TOKEN_PARSE);
$count++;
} catch (ParseError $exception) {
throw new RuntimeException($file->getPathname() . ': ' . $exception->getMessage());
}
}
echo 'PHP ' . PHP_VERSION . ' native source syntax passed: ' . $count . " files.\n";