PhpMigration\Utils\FunctionListExporter::parseAll PHP Method

parseAll() public method

public parseAll ( $wholehtml )
    public function parseAll($wholehtml)
    {
        $list = [];
        preg_match_all('/<div class="methodsynopsis dc-description">.+?<\\/div>/s', $wholehtml, $matches);
        if (!$matches[0]) {
            throw new \Exception('Invalid single document html');
        }
        foreach ($matches[0] as $desc) {
            try {
                $method = $this->parse($desc);
                $list[] = $method;
            } catch (\Exception $e) {
                continue;
            }
        }
        return $list;
    }

Usage Example

Example #1
0
 protected function commandExportPosbit()
 {
     $docfile = current($this->args['<file>']);
     if (!file_exists($docfile)) {
         Logging::error('Unable load docfile {name}', ['name' => $docfile]);
         exit(1);
     }
     $html = file_get_contents($docfile);
     $exporter = new FunctionListExporter();
     $methodlist = $exporter->parseAll($html);
     foreach ($methodlist as $method) {
         // Skip class method
         if ($method['modifier'] || strpos($method['name'], '::') !== false) {
             continue;
         }
         // Find by-reference param
         $posbit = 0;
         foreach ($method['params'] as $key => $param) {
             if ($param['reference']) {
                 $posbit |= 1 << $key;
             }
         }
         if (!$posbit) {
             continue;
         }
         printf("%-40s => %4u, // %s\n", "'" . $method['name'] . "'", $posbit, strrev(decbin($posbit)));
     }
 }