Skip to content

Commit

Permalink
Merge pull request #60 from winzou/sf5
Browse files Browse the repository at this point in the history
Add Symfony5 support
  • Loading branch information
winzou authored Jul 26, 2020
2 parents 70a2e91 + 81bd972 commit c9522d5
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 40 deletions.
21 changes: 7 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,21 @@ dist: xenial
language: php

php:
- 5.6
- hhvm
- 7.0
- 7.1
- 7.2

env:
- SYMFONY_VERSION=~2.1
- SYMFONY_VERSION=~3.0
- SYMFONY_VERSION=~4.0
- SYMFONY_VERSION=~5.0

matrix:
fast_finish: true
allow_failures:
- php: 5.6
env: 'SYMFONY_VERSION=~4.0'
- php: 7.0
env: 'SYMFONY_VERSION=~4.0'
- php: hhvm
env: 'SYMFONY_VERSION=~4.0'
- php: hhvm
dist: xenial
- php: 7.1
env: 'SYMFONY_VERSION=~5.0'

before_install:
- phpenv config-rm xdebug.ini || true
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

before_script:
- composer self-update
Expand Down
3 changes: 2 additions & 1 deletion Callback/ContainerAwareCallbackFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use SM\SMException;
use SM\Callback\CallbackFactory;
use SM\Callback\CallbackInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class ContainerAwareCallbackFactory extends CallbackFactory
Expand All @@ -32,7 +33,7 @@ public function __construct($class, ContainerInterface $container)
/**
* {@inheritDoc}
*/
public function get(array $specs)
public function get(array $specs): CallbackInterface
{
if (!isset($specs['do'])) {
throw new SMException(sprintf(
Expand Down
21 changes: 13 additions & 8 deletions Command/winzouStateMachineDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@

namespace winzou\Bundle\StateMachineBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Question\ChoiceQuestion;

class winzouStateMachineDebugCommand extends ContainerAwareCommand
class winzouStateMachineDebugCommand extends Command
{
protected static $defaultName = 'debug:winzou:state-machine';

/**
* @var array
*/
/** @var array */
protected $config;

public function __construct(array $config)
{
parent::__construct();

$this->config = $config;
}

/**
* {@inheritdoc}
*/
public function configure()
{
$this
->setName(self::$defaultName) // BC with 2.7
->setDescription('Shows information about state machine states, transitions and callbacks.')
->addArgument('key', InputArgument::REQUIRED, 'A state machine key')
;
}
Expand All @@ -35,8 +40,6 @@ public function configure()
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->config = $this->getContainer()->getParameter('sm.configs');

if (empty($this->config)) {
throw new \RuntimeException('There is no state machine configured.');
}
Expand Down Expand Up @@ -89,6 +92,8 @@ public function execute(InputInterface $input, OutputInterface $output)
if (isset($config['callbacks'])) {
$this->printCallbacks($config['callbacks'], $output);
}

return 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/winzouStateMachineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class winzouStateMachineExtension extends Extension
{
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ services:
arguments:
$class: "%sm.callback.class%"

winzou\Bundle\StateMachineBundle\Command\:
resource: "../../Command/*"
tags: ["console.command"]
winzou\Bundle\StateMachineBundle\Command\winzouStateMachineDebugCommand:
arguments:
$config: "%sm.configs%"
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
}
],
"require": {
"php": ">5.3.0",
"winzou/state-machine": "~0.3",
"symfony/framework-bundle": "~2.1|~3.0|^4.0"
"php": "^7.1.3",
"winzou/state-machine": "~0.4",
"symfony/framework-bundle": "^4.3|^5.0"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
"phpspec/phpspec": "^5.0|^6.0"
},
"autoload": {
"psr-4": { "winzou\\Bundle\\StateMachineBundle\\": "" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace spec\winzou\Bundle\StateMachineBundle\Callback;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SM\Event\TransitionEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use winzou\Bundle\StateMachineBundle\Callback\ContainerAwareCallback;

class ContainerAwareCallbackSpec extends ObjectBehavior
{
Expand All @@ -17,7 +17,7 @@ function let(ContainerInterface $container)

function it_is_initializable()
{
$this->shouldHaveType('winzou\Bundle\StateMachineBundle\Callback\ContainerAwareCallback');
$this->shouldHaveType(ContainerAwareCallback::class);
}

function it_converts_servicename_to_class($container, TransitionEvent $event, ContainerAwareCallbackSpec $service)
Expand Down Expand Up @@ -46,9 +46,9 @@ function it_converts_classname_to_class($container, TransitionEvent $event, Cont

function it_allows_static_calls($container, TransitionEvent $event)
{
$this->beConstructedWith(array(), array('spec\\winzou\\Bundle\\StateMachineBundle\\Callback\\ContainerAwareCallbackSpec', 'dummyStatic'), $container);
$this->beConstructedWith(array(), array(ContainerAwareCallbackSpec::class, 'dummyStatic'), $container);

$container->has('spec\\winzou\\Bundle\\StateMachineBundle\\Callback\\ContainerAwareCallbackSpec')->willReturn(false);
$container->has(ContainerAwareCallbackSpec::class)->willReturn(false);

$this->call($event)->shouldReturn(2);
}
Expand All @@ -58,9 +58,9 @@ function it_throws_an_exception_when_relevant($container, TransitionEvent $event
$this->beConstructedWith(array(), array('@my_service', 'dummy'), $container);

$container->has('my_service')->willReturn(false);
$container->get('my_service')->willThrow('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException');
$container->get('my_service')->willThrow(ServiceNotFoundException::class);

$this->shouldThrow('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException')->during('call', array($event));
$this->shouldThrow(ServiceNotFoundException::class)->during('call', array($event));
}

function dummy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace spec\winzou\Bundle\StateMachineBundle\DependencyInjection;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use winzou\Bundle\StateMachineBundle\DependencyInjection\Configuration;
use winzou\Bundle\StateMachineBundle\DependencyInjection\winzouStateMachineExtension;

Expand Down Expand Up @@ -110,7 +108,7 @@ class winzouStateMachineExtensionSpec extends ObjectBehavior

function it_is_initializable()
{
$this->shouldHaveType('winzou\Bundle\StateMachineBundle\DependencyInjection\winzouStateMachineExtension');
$this->shouldHaveType(winzouStateMachineExtension::class);
}

function it_parse_configs()
Expand Down

0 comments on commit c9522d5

Please sign in to comment.