stub file generation
[mdref/mdref] / bin / ref2stub
1 #!/usr/bin/env php
2 <?php
3
4 namespace mdref;
5
6 require_once __DIR__."/../vendor/autoload.php";
7
8 if ($argc < 2) {
9 fprintf(STDERR, "Usage: %s <ref>[ <ref> ...]\n", $argv[0]);
10 exit(1);
11 }
12
13 $ref = new Reference(array_slice($argv, 1));
14 /** @var $repo Repo */
15 foreach ($ref as $repo) {
16 $fd = fopen($repo->getName().".stub.php", "w");
17 ob_start(function($s) use($fd) {
18 fwrite($fd, $s);
19 return $s;
20 });
21
22 printf("<?php\n");
23 $root = $repo->getRootEntry();
24 $root->getStructure()->format();
25
26 ob_end_flush();
27 fclose($fd);
28 }
29