Skip to content

Commit bc1fc73

Browse files
committed
Develop command
1 parent a9db9af commit bc1fc73

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"php": ">=7.4",
2222
"ext-json": "*",
2323
"guzzlehttp/guzzle": "^7.0",
24-
"composer/composer": "^2.4"
24+
"composer/composer": "^2.4",
25+
"symfony/console": "^5.4"
2526
},
2627
"require-dev": {
2728
"phpunit/phpunit": "^9.5",

composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Command/BinaryCommand.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace PhpDocumentorMarkdown\Command;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
class BinaryCommand extends Command
10+
{
11+
protected function configure()
12+
{
13+
// ...
14+
}
15+
16+
protected function execute(InputInterface $input, OutputInterface $output)
17+
{
18+
// ...
19+
}
20+
}

src/PhpdocBinaryHandler.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ public static function getBinaryPath(): string
2020
return dirname(__FILE__, 2) . '/bin/phpdoc';
2121
}
2222

23+
/**
24+
* Call the binary.
25+
*
26+
* @param string $command
27+
* @return false|string|null
28+
*/
29+
public static function call(string $command)
30+
{
31+
$path = self::getBinaryPath();
32+
return shell_exec("$path $command");
33+
}
34+
2335
/**
2436
* Get PHPDocumentor phar download url.
2537
*
@@ -48,8 +60,7 @@ protected static function binaryExists(): bool
4860
*/
4961
protected static function getBinaryVersion(): ?array
5062
{
51-
$path = self::getBinaryPath();
52-
$version = shell_exec("$path -V");
63+
$version = self::call('-V');
5364

5465
if (empty($version)) {
5566
return null;

0 commit comments

Comments
 (0)