Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove unused code #44

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions src/Test/BaseMakefileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@
use Safe\Exceptions\ExecException;
use function array_filter;
use function dirname;
use function error_clear_last;
use function explode;
use function function_exists;
use function getenv;
use function implode;
use function Safe\chdir;
use function Safe\file_get_contents;
use function Safe\getcwd;
use function Safe\shell_exec;
use function Safe\sprintf;
use function shell_exec as unsafe_shell_exec;
use function sprintf;

abstract class BaseMakefileTestCase extends TestCase
{
Expand Down Expand Up @@ -130,7 +127,9 @@ final protected static function executeMakeCommand(string $commandName): string
);
}

// TODO: remove this as we remove support for PHP 7.4 and Safe v1
/**
* @throws ExecException
*/
final protected static function executeCommand(string $command): string
{
$command = sprintf(
Expand All @@ -139,19 +138,7 @@ final protected static function executeCommand(string $command): string
$command,
);

if (function_exists('Safe\shell_exec')) {
return shell_exec($command);
}

error_clear_last();

$safeResult = unsafe_shell_exec($command);

if (null === $safeResult || false === $safeResult) {
throw ExecException::createFromPhpError();
}

return $safeResult;
return shell_exec($command);
}

final protected static function getNonDebugMakeFlags(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Constraint/NoDuplicateTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use function array_key_exists;
use function get_debug_type;
use function is_array;
use function Safe\sprintf;
use function sprintf;

final class NoDuplicateTarget extends BaseConstraint
{
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Constraint/SinglePrerequisitePhony.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use Fidry\Makefile\Rule;
use function count;
use function get_debug_type;
use function Safe\sprintf;
use function sprintf;

final class SinglePrerequisitePhony extends BaseConstraint
{
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Constraint/ValidCommandDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
use function count;
use function get_debug_type;
use function is_array;
use function Safe\sprintf;
use function sprintf;

final class ValidCommandDeclaration extends BaseConstraint
{
Expand Down