Skip to content

Commit 10772a6

Browse files
committed
Add return type declarations to closures in docgen for better type safety
1 parent d54d8dd commit 10772a6

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

bin/docgen

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,37 @@ $output = new ConsoleOutput();
2323
$app = new Application('DocGen', '1.0.0');
2424
$app->setDefaultCommand('all');
2525

26-
$api = function () use ($output) {
26+
$api = function () use ($output): int {
2727
$parser = new ApiGen();
2828
$parser->parse(file_get_contents(__DIR__ . '/../src/functions.php'));
2929
$md = $parser->markdown();
3030
file_put_contents(__DIR__ . '/../docs/api.md', $md);
3131
$output->writeln('API Reference documentation updated.');
32+
return 0;
3233
};
3334

34-
$recipes = function () use ($input, $output) {
35+
$recipes = function () use ($input, $output): int {
3536
$docgen = new DocGen(__DIR__ . '/..');
3637
$docgen->parse(__DIR__ . '/../recipe');
3738
$docgen->parse(__DIR__ . '/../contrib');
3839

3940
if ($input->getOption('json')) {
4041
echo json_encode($docgen->recipes, JSON_PRETTY_PRINT);
41-
return;
42+
return 0;
4243
}
4344

4445
$docgen->gen(__DIR__ . '/../docs');
4546
$output->writeln('Recipes documentation updated.');
47+
return 0;
4648
};
4749

4850
$app->register('api')->setCode($api);
4951
$app->register('recipes')->setCode($recipes)->addOption('json');
50-
$app->register('all')->setCode(function () use ($recipes, $api) {
52+
$app->register('all')->setCode(function () use ($recipes, $api): int {
5153
$api();
5254
$recipes();
53-
echo `git status`;
55+
echo shell_exec('git status');
56+
return 0;
5457
})->addOption('json');
5558

5659
$app->run($input, $output);

0 commit comments

Comments
 (0)