webmozart / console

A usable, beautiful and easily testable console toolkit written in PHP.
MIT License
214 stars 58 forks source link

Added support for Symfony 3.* components #13

Closed pkruithof closed 8 years ago

webmozart commented 8 years ago

There seem to be a few problems with Travis/Style CI. Can you check?

pkruithof commented 8 years ago

This is because of Symfony\Component\Console\Command\Command::setCode(), which changed from

public function setCode($code)

to (

public function setCode(callable $code)

in this commit: https://github.com/symfony/symfony/commit/4e0c6e1b554ac74fee526868b86d028a7c38c10e

This is an example where the SF3 support and PHP 5.3 support don't go together (the callable type hint was introduced in PHP 5.4)

webmozart commented 8 years ago

Ok. Let's define the class conditionally then:

// CommandAdapter.php

abstract class AbstractCommandAdapter extends Command
{
    // current code except setCode()
}

if (method_exists('Symfony\Component\Console\Command\Command', 'asText')) {

    // Symfony 3.0 compatible definition
    class CommandAdapter extends AbstractCommandAdapter
    {
        public function setCode(callable $code) { ... }
    }

} else {

    // Symfony 2.0 compatible definition
    class CommandAdapter extends AbstractCommandAdapter
    {
        public function setCode($code) { ... }
    }

}
pkruithof commented 8 years ago

Done, all tests pass. Only Scrutinizer has something going on that seems having to do with their infrastructure. Does not seem like a problem here.

webmozart commented 8 years ago

Perfect, thanks! :)