Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks Greg and Dave for the feedback. Wasn't quite what I was looking for, but I decided to put a bit of time into researching it and came up with this quick and dirty solution:</p> <pre><code>&lt;?php $functions = array(); $path = "/path/to/my/php/project"; define_dir($path, $functions); reference_dir($path, $functions); echo "&lt;table&gt;" . "&lt;tr&gt;" . "&lt;th&gt;Name&lt;/th&gt;" . "&lt;th&gt;Defined&lt;/th&gt;" . "&lt;th&gt;Referenced&lt;/th&gt;" . "&lt;/tr&gt;"; foreach ($functions as $name =&gt; $value) { echo "&lt;tr&gt;" . "&lt;td&gt;" . htmlentities($name) . "&lt;/td&gt;" . "&lt;td&gt;" . (isset($value[0]) ? count($value[0]) : "-") . "&lt;/td&gt;" . "&lt;td&gt;" . (isset($value[1]) ? count($value[1]) : "-") . "&lt;/td&gt;" . "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; function define_dir($path, &amp;$functions) { if ($dir = opendir($path)) { while (($file = readdir($dir)) !== false) { if (substr($file, 0, 1) == ".") continue; if (is_dir($path . "/" . $file)) { define_dir($path . "/" . $file, $functions); } else { if (substr($file, - 4, 4) != ".php") continue; define_file($path . "/" . $file, $functions); } } } } function define_file($path, &amp;$functions) { $tokens = token_get_all(file_get_contents($path)); for ($i = 0; $i &lt; count($tokens); $i++) { $token = $tokens[$i]; if (is_array($token)) { if ($token[0] != T_FUNCTION) continue; $i++; $token = $tokens[$i]; if ($token[0] != T_WHITESPACE) die("T_WHITESPACE"); $i++; $token = $tokens[$i]; if ($token[0] != T_STRING) die("T_STRING"); $functions[$token[1]][0][] = array($path, $token[2]); } } } function reference_dir($path, &amp;$functions) { if ($dir = opendir($path)) { while (($file = readdir($dir)) !== false) { if (substr($file, 0, 1) == ".") continue; if (is_dir($path . "/" . $file)) { reference_dir($path . "/" . $file, $functions); } else { if (substr($file, - 4, 4) != ".php") continue; reference_file($path . "/" . $file, $functions); } } } } function reference_file($path, &amp;$functions) { $tokens = token_get_all(file_get_contents($path)); for ($i = 0; $i &lt; count($tokens); $i++) { $token = $tokens[$i]; if (is_array($token)) { if ($token[0] != T_STRING) continue; if ($tokens[$i + 1] != "(") continue; $functions[$token[1]][1][] = array($path, $token[2]); } } } ?&gt; </code></pre> <p>I'll probably spend some more time on it so I can quickly find the files and line numbers of the function definitions and references; this information is being gathered, just not displayed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload