1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-14 10:17:33 +01:00
psalm/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php
orklah f66d57f19d
add native return types (#4116)
* add native return types

* remove redundant phpdoc
2020-09-04 16:26:33 -04:00

35 lines
714 B
PHP

<?php
namespace Psalm\Internal\ExecutionEnvironment;
use function exec;
use function sprintf;
/**
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class SystemCommandExecutor
{
/**
* Execute command.
*
*
* @throws \RuntimeException
*
* @return string[]
*/
public function execute(string $command) : array
{
exec($command, $result, $returnValue);
if ($returnValue === 0) {
/** @var string[] */
return $result;
}
throw new \RuntimeException(sprintf('Failed to execute command: %s', $command), $returnValue);
}
}