php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
generate_parser_corpus.php
Go to the documentation of this file.
1<?php
2
3$testsDir = __DIR__ . '/../../Zend/tests/';
7);
8
9$corpusDir = __DIR__ . '/corpus/parser';
11
12$maxLen = 6 * 1024;
13foreach ($it as $file) {
14 if (!preg_match('/\.phpt$/', $file)) continue;
15 $code = file_get_contents($file);
16 if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $code, $matches)) continue;
17 $code = $matches[1];
18 if (strlen($code) > $maxLen) continue;
19
20 $outFile = str_replace($testsDir, '', $file);
21 $outFile = str_replace('/', '_', $outFile);
22 $outFile = $corpusDir . '/' . $outFile;
23 file_put_contents($outFile, $code);
24}
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
preg_match(string $pattern, string $subject, &$matches=null, int $flags=0, int $offset=0)
strlen(string $string)