Skip to content

Commit 536c2a3

Browse files
Merge branch 'symfony_2_8_compat'
2 parents 2d23378 + dc08ede commit 536c2a3

28 files changed

+137
-229
lines changed

.travis.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
language: php
22

3+
php:
4+
- 5.5
5+
- 5.6
6+
- 7.0
7+
- hhvm
8+
39
matrix:
10+
allow_failures:
11+
- php: hhvm
412
include:
5-
- php: 5.4
6-
env: SYMFONY_VERSION=2.5.*
7-
- php: 5.4
8-
env: SYMFONY_VERSION=2.7.*
13+
- php: 5.5
14+
env: SYMFONY_VERSION=2.8.*
15+
- php: 5.5
16+
env: SYMFONY_VERSION=3.0.*
917

1018
env:
1119
global:
1220
- SYMFONY_VERSION=""
1321

1422
before_install:
1523
- >
16-
if [ "SYMFONY_VERSION" != "" ]; then
24+
if [ "$SYMFONY_VERSION" != "" ]; then
1725
composer require --dev --no-update symfony/framework-bundle "$SYMFONY_VERSION" &&
1826
composer require --dev --no-update symfony/console "$SYMFONY_VERSION" &&
1927
composer require --dev --no-update symfony/validator "$SYMFONY_VERSION" &&
@@ -23,15 +31,11 @@ before_install:
2331
fi
2432
2533
install:
26-
- composer update --prefer-source
34+
- composer update --prefer-dist
2735

2836
script:
2937
- vendor/bin/php-cs-fixer fix -v --diff --dry-run
30-
- vendor/bin/behat --tags=~symfony27
31-
- >
32-
if [ "SYMFONY_VERSION" == "2.7.*" ]; then
33-
vendor/bin/behat --tags=symfony27
34-
fi
38+
- vendor/bin/behat
3539

3640
notifications:
3741

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
}
2424
},
2525
"require": {
26-
"php": ">=5.4",
27-
"symfony/form": "~2.5",
28-
"symfony/console": "~2.5"
26+
"php": ">=5.5",
27+
"symfony/form": "~2.8|~3.0",
28+
"symfony/console": "~2.8|~3.0"
2929
},
3030
"require-dev": {
3131
"beberlei/assert": "~2.1",
3232
"behat/behat": "~3.0",
3333
"fabpot/php-cs-fixer": "^1.10",
34-
"symfony/console": "~2.5",
35-
"symfony/finder": "~2.5",
36-
"symfony/form": "~2.5",
37-
"symfony/framework-bundle": "~2.5",
38-
"symfony/validator": "~2.5",
39-
"symfony/yaml": "~2.5"
34+
"symfony/console": "~2.8|~3.0",
35+
"symfony/finder": "~2.8|~3.0",
36+
"symfony/form": "~2.8|~3.0",
37+
"symfony/framework-bundle": "~2.8|~3.0",
38+
"symfony/validator": "~2.8|~3.0",
39+
"symfony/yaml": "~2.8|~3.0"
4040
}
4141
}

features/interactive.feature

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,41 +72,3 @@ Feature: It is possible to interactively fill in a form from the CLI
7272
[color] => blue
7373
)
7474
"""
75-
76-
@symfony27
77-
Scenario: Select a value
78-
When I run the command "form:color_with_choices_as_values" and I provide as input
79-
"""
80-
Blue[enter]
81-
"""
82-
Then the command has finished successfully
83-
And the output should be
84-
"""
85-
Select color [red]:
86-
[0] Red (red)
87-
[1] Blue (blue)
88-
[2] Yellow (yellow)
89-
> Array
90-
(
91-
[color] => blue
92-
)
93-
"""
94-
95-
@symfony27
96-
Scenario: Select a value by its underlying data
97-
When I run the command "form:color_with_choices_as_values" and I provide as input
98-
"""
99-
red[enter]
100-
"""
101-
Then the command has finished successfully
102-
And the output should be
103-
"""
104-
Select color [red]:
105-
[0] Red (red)
106-
[1] Blue (blue)
107-
[2] Yellow (yellow)
108-
> Array
109-
(
110-
[color] => red
111-
)
112-
"""

src/Bridge/FormFactory/ConsoleFormFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Component\Console\Input\InputInterface;
66
use Symfony\Component\Form\FormInterface;
7+
use Symfony\Component\Form\FormTypeInterface;
78

89
interface ConsoleFormFactory
910
{

src/Bridge/FormFactory/ConsoleFormWithDefaultValuesAndOptionsFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Matthias\SymfonyConsoleForm\Bridge\FormFactory;
44

55
use Symfony\Component\Console\Input\InputInterface;
6+
use Symfony\Component\Form\Extension\Core\Type\FormType;
67
use Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension;
78
use Symfony\Component\Form\FormFactoryInterface;
89
use Symfony\Component\Form\FormRegistryInterface;
10+
use Symfony\Component\Form\FormTypeInterface;
911
use Symfony\Component\Form\Test\FormBuilderInterface;
1012

1113
class ConsoleFormWithDefaultValuesAndOptionsFactory implements ConsoleFormFactory
@@ -68,10 +70,9 @@ public function create($formType, InputInterface $input, array $options = [])
6870
private function addDefaultOptions(array $options)
6971
{
7072
$defaultOptions = [];
71-
7273
// hack to prevent validation error "The CSRF token is invalid."
7374
foreach ($this->formRegistry->getExtensions() as $extension) {
74-
foreach ($extension->getTypeExtensions('form') as $typeExtension) {
75+
foreach ($extension->getTypeExtensions(FormType::class) as $typeExtension) {
7576
if ($typeExtension instanceof FormTypeCsrfExtension) {
7677
$defaultOptions['csrf_protection'] = false;
7778
}

src/Bridge/Interaction/CollectionInteractor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Output\OutputInterface;
1313
use Symfony\Component\Console\Question\ConfirmationQuestion;
14+
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
1415
use Symfony\Component\Form\FormInterface;
1516

1617
class CollectionInteractor implements FormInteractor
@@ -49,7 +50,7 @@ public function interactWith(
4950
throw new CanNotInteractWithForm('This interactor only works with interactive input');
5051
}
5152

52-
if (!FormUtil::isTypeInAncestry($form, 'collection')) {
53+
if (!FormUtil::isTypeInAncestry($form, CollectionType::class)) {
5354
throw new CanNotInteractWithForm('Expected a "collection" form');
5455
}
5556

src/Bridge/Interaction/FieldWithNoInteractionInteractor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Console\Helper\HelperSet;
99
use Symfony\Component\Console\Input\InputInterface;
1010
use Symfony\Component\Console\Output\OutputInterface;
11+
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
1112
use Symfony\Component\Form\FormInterface;
1213

1314
class FieldWithNoInteractionInteractor implements FormInteractor
@@ -27,7 +28,7 @@ public function interactWith(
2728
InputInterface $input,
2829
OutputInterface $output
2930
) {
30-
if (FormUtil::isTypeInAncestry($form, 'button')) {
31+
if (FormUtil::isTypeInAncestry($form, ButtonType::class)) {
3132
throw new NoNeedToInteractWithForm();
3233
}
3334

src/Bridge/Transformer/ChoiceTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Matthias\SymfonyConsoleForm\Bridge\Transformer;
44

55
use Matthias\SymfonyConsoleForm\Console\Helper\Question\AlwaysReturnKeyOfChoiceQuestion;
6+
use Symfony\Component\Console\Question\Question;
67
use Symfony\Component\Form\Form;
78

89
class ChoiceTransformer extends AbstractTransformer

src/Bundle/helpers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
class: Matthias\SymfonyConsoleForm\Console\EventListener\RegisterHelpersEventListener
44
public: true
55
arguments:
6-
- @matthias_symfony_console_form.helper_collection
6+
- "@matthias_symfony_console_form.helper_collection"
77
tags:
88
- { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 1000 }
99

src/Bundle/services.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,68 +9,68 @@ services:
99
class: Matthias\SymfonyConsoleForm\Console\Helper\FormHelper
1010
public: false
1111
arguments:
12-
- @matthias_symfony_console_form.console_form_factory
13-
- @matthias_symfony_console_form.delegating_interactor
12+
- "@matthias_symfony_console_form.console_form_factory"
13+
- "@matthias_symfony_console_form.delegating_interactor"
1414
tags:
1515
- { name: console_helper }
1616

1717
matthias_symfony_console_form.input_definition_factory:
1818
class: Matthias\SymfonyConsoleForm\Console\Input\CachedInputDefinitionFactory
1919
public: false
2020
arguments:
21-
- @matthias_symfony_console_form.real_input_definition_factory
21+
- "@matthias_symfony_console_form.real_input_definition_factory"
2222
- %matthias_symfony_console_form.cache_directory%
2323
- %kernel.debug%
2424

2525
matthias_symfony_console_form.real_input_definition_factory:
2626
class: Matthias\SymfonyConsoleForm\Console\Input\FormBasedInputDefinitionFactory
2727
public: false
2828
arguments:
29-
- @form.factory
29+
- "@form.factory"
3030

3131
matthias_symfony_console_form.text_transformer:
3232
class: Matthias\SymfonyConsoleForm\Bridge\Transformer\TextTransformer
3333
public: false
3434
tags:
35-
- { name: form_to_question_transformer, form_type: text }
35+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\TextType }
3636

3737
matthias_symfony_console_form.date_time_transformer:
3838
class: Matthias\SymfonyConsoleForm\Bridge\Transformer\DateTimeTransformer
3939
public: false
4040
tags:
41-
- { name: form_to_question_transformer, form_type: time }
42-
- { name: form_to_question_transformer, form_type: date }
43-
- { name: form_to_question_transformer, form_type: datetime }
41+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\TimeType }
42+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\DateType }
43+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\DateTimeType }
4444

4545
matthias_symfony_console_form.password_transformer:
4646
class: Matthias\SymfonyConsoleForm\Bridge\Transformer\PasswordTransformer
4747
public: false
4848
tags:
49-
- { name: form_to_question_transformer, form_type: password }
49+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\PasswordType }
5050

5151
matthias_symfony_console_form.choice_transformer:
5252
class: Matthias\SymfonyConsoleForm\Bridge\Transformer\ChoiceTransformer
5353
public: false
5454
tags:
55-
- { name: form_to_question_transformer, form_type: choice }
56-
- { name: form_to_question_transformer, form_type: country }
55+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\ChoiceType }
56+
- { name: form_to_question_transformer, form_type: Symfony\Component\Form\Extension\Core\Type\CountryType }
5757

5858
matthias_symfony_console_form.delegating_interactor:
5959
class: Matthias\SymfonyConsoleForm\Bridge\Interaction\DelegatingInteractor
6060
public: false
6161
calls:
6262
# more specific interactors (by form type acenstry) should be higher in this list
63-
- [addInteractor, [@matthias_symfony_console_form.field_with_no_interaction_interactor]]
64-
- [addInteractor, [@matthias_symfony_console_form.non_interactive_root_interactor]]
65-
- [addInteractor, [@matthias_symfony_console_form.collection_interactor]]
66-
- [addInteractor, [@matthias_symfony_console_form.compound_interactor]]
67-
- [addInteractor, [@matthias_symfony_console_form.field_interactor]]
63+
- [addInteractor, ["@matthias_symfony_console_form.field_with_no_interaction_interactor"]]
64+
- [addInteractor, ["@matthias_symfony_console_form.non_interactive_root_interactor"]]
65+
- [addInteractor, ["@matthias_symfony_console_form.collection_interactor"]]
66+
- [addInteractor, ["@matthias_symfony_console_form.compound_interactor"]]
67+
- [addInteractor, ["@matthias_symfony_console_form.field_interactor"]]
6868

6969
matthias_symfony_console_form.compound_interactor:
7070
class: Matthias\SymfonyConsoleForm\Bridge\Interaction\CompoundInteractor
7171
public: false
7272
arguments:
73-
- @matthias_symfony_console_form.delegating_interactor
73+
- "@matthias_symfony_console_form.delegating_interactor"
7474

7575
matthias_symfony_console_form.field_with_no_interaction_interactor:
7676
class: Matthias\SymfonyConsoleForm\Bridge\Interaction\FieldWithNoInteractionInteractor
@@ -80,19 +80,19 @@ services:
8080
class: Matthias\SymfonyConsoleForm\Bridge\Interaction\NonInteractiveRootInteractor
8181
public: false
8282
arguments:
83-
- @matthias_symfony_console_form.delegating_interactor
83+
- "@matthias_symfony_console_form.delegating_interactor"
8484

8585
matthias_symfony_console_form.collection_interactor:
8686
class: Matthias\SymfonyConsoleForm\Bridge\Interaction\CollectionInteractor
8787
public: false
8888
arguments:
89-
- @matthias_symfony_console_form.delegating_interactor
89+
- "@matthias_symfony_console_form.delegating_interactor"
9090

9191
matthias_symfony_console_form.field_interactor:
9292
class: Matthias\SymfonyConsoleForm\Bridge\Interaction\FieldInteractor
9393
public: false
9494
arguments:
95-
- @matthias_symfony_console.transformer_resolver
95+
- "@matthias_symfony_console.transformer_resolver"
9696

9797
matthias_symfony_console.transformer_resolver:
9898
class: Matthias\SymfonyConsoleForm\Bridge\Transformer\TypeAncestryBasedTransformerResolver
@@ -102,27 +102,27 @@ services:
102102
class: Matthias\SymfonyConsoleForm\Console\EventListener\HandleFormBasedCommandEventListener
103103
public: true
104104
arguments:
105-
- @matthias_symfony_console_form.form_helper
105+
- "@matthias_symfony_console_form.form_helper"
106106
tags:
107107
- { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 200 }
108108

109109
matthias_symfony_console_form.set_input_definition_of_form_based_command_event_listener:
110110
class: Matthias\SymfonyConsoleForm\Console\EventListener\SetInputDefinitionOfFormBasedCommandEventListener
111111
public: true
112112
arguments:
113-
- @matthias_symfony_console_form.input_definition_factory
113+
- "@matthias_symfony_console_form.input_definition_factory"
114114
tags:
115115
- { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 2000 }
116116

117117
matthias_symfony_console_form.console_form_type_extension:
118118
class: Matthias\SymfonyConsoleForm\Form\ConsoleFormTypeExtension
119119
public: true
120120
tags:
121-
- { name: form.type_extension, alias: form }
121+
- { name: form.type_extension, alias: form, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType }
122122

123123
matthias_symfony_console_form.console_form_factory:
124124
class: Matthias\SymfonyConsoleForm\Bridge\FormFactory\ConsoleFormWithDefaultValuesAndOptionsFactory
125125
public: false
126126
arguments:
127-
- @form.factory
128-
- @form.registry
127+
- "@form.factory"
128+
- "@form.registry"

0 commit comments

Comments
 (0)