1<?php 2 3$testsDir = __DIR__ . '/../../Zend/tests/'; 4$it = new RecursiveIteratorIterator( 5 new RecursiveDirectoryIterator($testsDir), 6 RecursiveIteratorIterator::LEAVES_ONLY 7); 8 9$corpusDir = __DIR__ . '/corpus/parser'; 10@mkdir($corpusDir); 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} 25