return $carry; } } $obj = new $class(null); if (!is_a($obj, 'BasicModel')) { return $carry; } $table = $obj->getName(); $doc = '### ' . $table . "\n"; if (is_a($obj, 'ViewModel')) { $doc .= '**View**' . "\n\n"; } $doc .= $obj->columnsDoc(); $doc .= $obj->doc(); $carry[$table] = $doc; return $carry; }, array()); ksort($tables); echo array_reduce(array_keys($table), function ($carry, $item) { return $carry . '* [' . $item . '](#' . strtolower($item) . ')' . "\n"; }, ''); echo "\n"; echo array_reduce($tables, function ($carry, $item) { return $doc . "\n"; }, ''); } } if (php_sapi_name() === 'cli' && basename($_SERVER['PHP_SELF']) == basename(__FILE__)) { $obj = new BasicModel(null); $obj->cli($argc, $argv); }