Skip to content

Commit

Permalink
Maintain BC with older Symfony versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pkruithof committed Dec 17, 2015
1 parent 8715458 commit 71a3915
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions src/Adapter/CommandAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author Bernhard Schussek <[email protected]>
*/
class CommandAdapter extends Command
abstract class AbstractCommandAdapter extends Command
{
/**
* @var \Webmozart\Console\Api\Command\Command
Expand Down Expand Up @@ -94,18 +94,6 @@ public function setHelperSet(HelperSet $helperSet)
return $this;
}

/**
* Does nothing.
*
* @param callable $code The code.
*
* @return static The current instance.
*/
public function setCode(callable $code)
{
return $this;
}

/**
* Does nothing.
*
Expand Down Expand Up @@ -247,3 +235,38 @@ public function run(InputInterface $input, OutputInterface $output)
return $this->adaptedCommand->handle($input->getArgs(), $output->getIO());
}
}

if (method_exists('Symfony\Component\Console\Command\Command', 'asText')) {
// Symfony 2.0 compatible definition
class CommandAdapter extends AbstractCommandAdapter
{
/**
* Does nothing.
*
* @param callable $code The code.
*
* @return static The current instance.
*/
public function setCode($code)
{
return $this;
}
}
} else {
// Symfony 3.0 compatible definition
class CommandAdapter extends AbstractCommandAdapter
{
/**
* Does nothing.
*
* @param callable $code The code.
*
* @return static The current instance.
*/
public function setCode(callable $code)
{
return $this;
}
}
}

0 comments on commit 71a3915

Please sign in to comment.