Skip to content

Commit c9522d5

Browse files
authored
Merge pull request #60 from winzou/sf5
Add Symfony5 support
2 parents 70a2e91 + 81bd972 commit c9522d5

8 files changed

Lines changed: 37 additions & 40 deletions

File tree

.travis.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,21 @@ dist: xenial
66
language: php
77

88
php:
9-
- 5.6
10-
- hhvm
11-
- 7.0
129
- 7.1
1310
- 7.2
1411

1512
env:
16-
- SYMFONY_VERSION=~2.1
17-
- SYMFONY_VERSION=~3.0
1813
- SYMFONY_VERSION=~4.0
14+
- SYMFONY_VERSION=~5.0
1915

2016
matrix:
21-
fast_finish: true
2217
allow_failures:
23-
- php: 5.6
24-
env: 'SYMFONY_VERSION=~4.0'
25-
- php: 7.0
26-
env: 'SYMFONY_VERSION=~4.0'
27-
- php: hhvm
28-
env: 'SYMFONY_VERSION=~4.0'
29-
- php: hhvm
30-
dist: xenial
18+
- php: 7.1
19+
env: 'SYMFONY_VERSION=~5.0'
20+
21+
before_install:
22+
- phpenv config-rm xdebug.ini || true
23+
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
3124

3225
before_script:
3326
- composer self-update

Callback/ContainerAwareCallbackFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use SM\SMException;
1515
use SM\Callback\CallbackFactory;
16+
use SM\Callback\CallbackInterface;
1617
use Symfony\Component\DependencyInjection\ContainerInterface;
1718

1819
class ContainerAwareCallbackFactory extends CallbackFactory
@@ -32,7 +33,7 @@ public function __construct($class, ContainerInterface $container)
3233
/**
3334
* {@inheritDoc}
3435
*/
35-
public function get(array $specs)
36+
public function get(array $specs): CallbackInterface
3637
{
3738
if (!isset($specs['do'])) {
3839
throw new SMException(sprintf(

Command/winzouStateMachineDebugCommand.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,35 @@
22

33
namespace winzou\Bundle\StateMachineBundle\Command;
44

5-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
5+
use Symfony\Component\Console\Command\Command;
66
use Symfony\Component\Console\Helper\TableSeparator;
77
use Symfony\Component\Console\Input\InputArgument;
88
use Symfony\Component\Console\Input\InputInterface;
99
use Symfony\Component\Console\Output\OutputInterface;
1010
use Symfony\Component\Console\Helper\Table;
1111
use Symfony\Component\Console\Question\ChoiceQuestion;
1212

13-
class winzouStateMachineDebugCommand extends ContainerAwareCommand
13+
class winzouStateMachineDebugCommand extends Command
1414
{
1515
protected static $defaultName = 'debug:winzou:state-machine';
1616

17-
/**
18-
* @var array
19-
*/
17+
/** @var array */
2018
protected $config;
2119

20+
public function __construct(array $config)
21+
{
22+
parent::__construct();
23+
24+
$this->config = $config;
25+
}
26+
2227
/**
2328
* {@inheritdoc}
2429
*/
2530
public function configure()
2631
{
2732
$this
28-
->setName(self::$defaultName) // BC with 2.7
33+
->setDescription('Shows information about state machine states, transitions and callbacks.')
2934
->addArgument('key', InputArgument::REQUIRED, 'A state machine key')
3035
;
3136
}
@@ -35,8 +40,6 @@ public function configure()
3540
*/
3641
protected function initialize(InputInterface $input, OutputInterface $output)
3742
{
38-
$this->config = $this->getContainer()->getParameter('sm.configs');
39-
4043
if (empty($this->config)) {
4144
throw new \RuntimeException('There is no state machine configured.');
4245
}
@@ -89,6 +92,8 @@ public function execute(InputInterface $input, OutputInterface $output)
8992
if (isset($config['callbacks'])) {
9093
$this->printCallbacks($config['callbacks'], $output);
9194
}
95+
96+
return 0;
9297
}
9398

9499
/**

DependencyInjection/winzouStateMachineExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Component\Config\FileLocator;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Extension\Extension;
1617
use Symfony\Component\DependencyInjection\Loader;
17-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1818

1919
class winzouStateMachineExtension extends Extension
2020
{

Resources/config/services.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ services:
2626
arguments:
2727
$class: "%sm.callback.class%"
2828

29-
winzou\Bundle\StateMachineBundle\Command\:
30-
resource: "../../Command/*"
31-
tags: ["console.command"]
29+
winzou\Bundle\StateMachineBundle\Command\winzouStateMachineDebugCommand:
30+
arguments:
31+
$config: "%sm.configs%"

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">5.3.0",
15-
"winzou/state-machine": "~0.3",
16-
"symfony/framework-bundle": "~2.1|~3.0|^4.0"
14+
"php": "^7.1.3",
15+
"winzou/state-machine": "~0.4",
16+
"symfony/framework-bundle": "^4.3|^5.0"
1717
},
1818
"require-dev": {
19-
"phpspec/phpspec": "~2.0"
19+
"phpspec/phpspec": "^5.0|^6.0"
2020
},
2121
"autoload": {
2222
"psr-4": { "winzou\\Bundle\\StateMachineBundle\\": "" }

spec/winzou/Bundle/StateMachineBundle/Callback/ContainerAwareCallbackSpec.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace spec\winzou\Bundle\StateMachineBundle\Callback;
44

55
use PhpSpec\ObjectBehavior;
6-
use Prophecy\Argument;
76
use SM\Event\TransitionEvent;
87
use Symfony\Component\DependencyInjection\ContainerInterface;
98
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
9+
use winzou\Bundle\StateMachineBundle\Callback\ContainerAwareCallback;
1010

1111
class ContainerAwareCallbackSpec extends ObjectBehavior
1212
{
@@ -17,7 +17,7 @@ function let(ContainerInterface $container)
1717

1818
function it_is_initializable()
1919
{
20-
$this->shouldHaveType('winzou\Bundle\StateMachineBundle\Callback\ContainerAwareCallback');
20+
$this->shouldHaveType(ContainerAwareCallback::class);
2121
}
2222

2323
function it_converts_servicename_to_class($container, TransitionEvent $event, ContainerAwareCallbackSpec $service)
@@ -46,9 +46,9 @@ function it_converts_classname_to_class($container, TransitionEvent $event, Cont
4646

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

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

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

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

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

6666
function dummy()

spec/winzou/Bundle/StateMachineBundle/DependencyInjection/winzouStateMachineExtensionSpec.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
namespace spec\winzou\Bundle\StateMachineBundle\DependencyInjection;
44

55
use PhpSpec\ObjectBehavior;
6-
use Prophecy\Argument;
76
use Symfony\Component\Config\Definition\Processor;
8-
use Symfony\Component\DependencyInjection\ContainerBuilder;
97
use winzou\Bundle\StateMachineBundle\DependencyInjection\Configuration;
108
use winzou\Bundle\StateMachineBundle\DependencyInjection\winzouStateMachineExtension;
119

@@ -110,7 +108,7 @@ class winzouStateMachineExtensionSpec extends ObjectBehavior
110108

111109
function it_is_initializable()
112110
{
113-
$this->shouldHaveType('winzou\Bundle\StateMachineBundle\DependencyInjection\winzouStateMachineExtension');
111+
$this->shouldHaveType(winzouStateMachineExtension::class);
114112
}
115113

116114
function it_parse_configs()

0 commit comments

Comments
 (0)