Skip to content

Commit

Permalink
Move checking if proc_open function exists to the executor (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Dec 16, 2022
1 parent fcd320c commit a29d68f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/Executor/ProcOpen.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Fidry\CpuCoreCounter\Executor;

use function fclose;
use function function_exists;
use function is_resource;
use function proc_close;
use function proc_open;
Expand All @@ -22,10 +23,14 @@
final class ProcOpen
{
/**
* @return array{string, string} STDOUT & STDERR tuple
* @return array{string, string}|null STDOUT & STDERR tuple
*/
public static function execute(string $command): ?array
{
if (!function_exists('proc_open')) {
return null;
}

$pipes = [];

$process = @proc_open(
Expand Down
4 changes: 0 additions & 4 deletions src/Finder/ProcOpenBasedFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ public function diagnose(): string
*/
public function find(): ?int
{
if (!function_exists('proc_open')) {
return null;
}

$output = ProcOpen::execute($this->getCommand());

if (null === $output) {
Expand Down

0 comments on commit a29d68f

Please sign in to comment.