php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
generate_corpus_util.php
Go to the documentation of this file.
1<?php
2
3function generate_corpus_from_phpt(string $corpusDir, array $testDirs, int $maxLen = 8 * 1024) {
5 foreach ($testDirs as $testDir) {
7 new RecursiveDirectoryIterator($testDir),
9 );
10
11 foreach ($it as $file) {
12 if (!preg_match('/\.phpt$/', $file)) continue;
13 $fullCode = file_get_contents($file);
14 if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $fullCode, $matches)) continue;
15 $code = $matches[1];
16 if (strlen($code) > $maxLen) continue;
17
18 $outFile = str_replace($testDir, '', $file);
19 $outFile = str_replace('/', '_', $outFile);
20 if (!preg_match('/SKIP_SLOW_TESTS|SKIP_PERF_SENSITIVE|USE_ZEND_ALLOC/', $fullCode)) {
21 file_put_contents($corpusDir . '/' . $outFile, $code);
22 }
23 }
24 }
25}
file_get_contents(string $filename, bool $use_include_path=false, $context=null, int $offset=0, ?int $length=null)
str_replace(array|string $search, array|string $replace, string|array $subject, &$count=null)
file_put_contents(string $filename, mixed $data, int $flags=0, $context=null)
mkdir(string $directory, int $permissions=0777, bool $recursive=false, $context=null)
$file
Definition encryption.php:9
generate_corpus_from_phpt(string $corpusDir, array $testDirs, int $maxLen=8 *1024)
preg_match(string $pattern, string $subject, &$matches=null, int $flags=0, int $offset=0)
strlen(string $string)