#!/usr/bin/php -q | | Gina Peter Banyard | +----------------------------------------------------------------------+ $Id$ */ if ($argc > 3 || (isset($argv[1]) && in_array($argv[1], array('--help', '-help', '-h', '-?')))) { ?> Find entity usage in phpdoc xml files and list used and unused entities. Usage: [] [] must be a file name (with relative path from the phpdoc root) to a file containing definitions. Defaults to 'base/entities/global.ent', 'en/language-defs.ent, and 'en/language-snippets.ent'. must be a valid language code used in the repository, or 'all' for all languages. Defaults to 'all'. The script will generate an entity_usage.txt file, containing the entities defined in the . = 2) { $files = [$argv[1]]; } /*********************************************************************/ /* Here starts the functions part */ /*********************************************************************/ // Extract the entity names from the file function extract_entity_definitions ($filename, &$entities) { global $debug; // Read in the file, or die $file_array = file ($filename); if (!$file_array) { die ("Cannot open entity file ($filename)."); } // The whole file in a string $file_string = preg_replace("/[\r\n]/", "", join ("", $file_array)); // Find entity names preg_match_all("/ $files) { $num = count($files); if ($num == 0) { $prep = "++ "; } else { $prep = " "; } fwrite($fp, $prep . sprintf("%-30s %d", $entity_name, count($files)). "\n"); } fclose($fp); if ($debug !== []) { echo 'Several issues are present:', \PHP_EOL; print_r($debug); exit(1); } echo "Done!\n";