Skip to content

Commit d8ae9e9

Browse files
Merge pull request #9 from EmanueleMinotto/reviews
Reviews
2 parents 5ef54d4 + 8897f5b commit d8ae9e9

File tree

54 files changed

+583
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+583
-61
lines changed

.php_cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
$finder = Symfony\CS\Finder\DefaultFinder::create()
3+
->in('src')
4+
->in('test')
5+
->notPath('temp');
6+
$config = Symfony\CS\Config\Config::create();
7+
$config->fixers(['ordered_use']);
8+
$config->finder($finder);
9+
return $config;

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ install:
2626
- composer update --prefer-source
2727

2828
script:
29+
- vendor/bin/php-cs-fixer fix -v --diff --dry-run
2930
- vendor/bin/behat --tags=~symfony27
3031
- >
3132
if [ "SYMFONY_VERSION" == "2.7.*" ]; then

CONTRIBUTING.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Running Coding Standards Checks
2+
3+
This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding
4+
standards checks, and provides configuration for our selected checks.
5+
`php-cs-fixer` is installed by default via Composer.
6+
7+
To run checks only:
8+
9+
```console
10+
$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs
11+
```
12+
13+
To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run`
14+
flag:
15+
16+
```console
17+
$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
18+
```
19+
20+
If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
21+
they pass, and make sure you add and commit the changes after verification.

composer.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@
2828
"symfony/console": "~2.5"
2929
},
3030
"require-dev": {
31-
"behat/behat": "~3.0",
3231
"beberlei/assert": "~2.1",
32+
"behat/behat": "~3.0",
33+
"fabpot/php-cs-fixer": "^1.10",
34+
"symfony/console": "~2.5",
35+
"symfony/finder": "~2.5",
36+
"symfony/form": "~2.5",
3337
"symfony/framework-bundle": "~2.5",
3438
"symfony/validator": "~2.5",
35-
"symfony/form": "~2.5",
36-
"symfony/yaml": "~2.5",
37-
"symfony/finder": "~2.5",
38-
"symfony/console": "~2.5"
39+
"symfony/yaml": "~2.5"
3940
}
4041
}

features/bootstrap/FeatureContext.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
*/
1515
class FeatureContext implements Context, SnippetAcceptingContext
1616
{
17+
/**
18+
* @var Application
19+
*/
1720
private $application;
1821

1922
/**

src/Bridge/FormFactory/ConsoleFormFactory.php

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
interface ConsoleFormFactory
99
{
1010
/**
11+
* @param string|FormTypeInterface $formType
12+
* @param InputInterface $input
13+
* @param array $options
14+
*
1115
* @return FormInterface
1216
*/
1317
public function create($formType, InputInterface $input, array $options = []);

src/Bridge/FormFactory/ConsoleFormWithDefaultValuesAndOptionsFactory.php

+25-2
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,41 @@
1010

1111
class ConsoleFormWithDefaultValuesAndOptionsFactory implements ConsoleFormFactory
1212
{
13+
/**
14+
* @var FormFactoryInterface
15+
*/
1316
private $formFactory;
17+
18+
/**
19+
* @var FormRegistryInterface
20+
*/
1421
private $formRegistry;
1522

23+
/**
24+
* @param FormFactoryInterface $formFactory
25+
* @param FormRegistryInterface $formRegistry
26+
*/
1627
public function __construct(FormFactoryInterface $formFactory, FormRegistryInterface $formRegistry)
1728
{
1829
$this->formFactory = $formFactory;
1930
$this->formRegistry = $formRegistry;
2031
}
2132

33+
/**
34+
* @param string|FormTypeInterface $formType
35+
* @param InputInterface $input
36+
* @param array $options
37+
*
38+
* @return \Symfony\Component\Form\Form
39+
*/
2240
public function create($formType, InputInterface $input, array $options = [])
2341
{
2442
$options = $this->addDefaultOptions($options);
2543

2644
$formBuilder = $this->formFactory->createBuilder($formType, null, $options);
2745

2846
foreach ($formBuilder as $name => $childBuilder) {
29-
/** @var FormBuilderInterface $childBuilder */
47+
/* @var FormBuilderInterface $childBuilder */
3048
if (!$input->hasOption($name)) {
3149
continue;
3250
}
@@ -42,9 +60,14 @@ public function create($formType, InputInterface $input, array $options = [])
4260
return $formBuilder->getForm();
4361
}
4462

63+
/**
64+
* @param array $options
65+
*
66+
* @return array
67+
*/
4568
private function addDefaultOptions(array $options)
4669
{
47-
$defaultOptions = array();
70+
$defaultOptions = [];
4871

4972
// hack to prevent validation error "The CSRF token is invalid."
5073
foreach ($this->formRegistry->getExtensions() as $extension) {

src/Bridge/Interaction/CollectionInteractor.php

+33-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Matthias\SymfonyConsoleForm\Bridge\Interaction;
44

5-
use Matthias\SymfonyConsoleForm\Console\Formatter\Format;
5+
use Matthias\SymfonyConsoleForm\Bridge\Interaction\Exception\CanNotInteractWithForm;
66
use Matthias\SymfonyConsoleForm\Bridge\Interaction\Exception\FormNotReadyForInteraction;
7+
use Matthias\SymfonyConsoleForm\Console\Formatter\Format;
78
use Matthias\SymfonyConsoleForm\Form\FormUtil;
8-
use Matthias\SymfonyConsoleForm\Bridge\Interaction\Exception\CanNotInteractWithForm;
99
use Symfony\Component\Console\Helper\HelperSet;
1010
use Symfony\Component\Console\Helper\QuestionHelper;
1111
use Symfony\Component\Console\Input\InputInterface;
@@ -15,13 +15,30 @@
1515

1616
class CollectionInteractor implements FormInteractor
1717
{
18+
/**
19+
* @var FormInteractor
20+
*/
1821
private $formInteractor;
1922

23+
/**
24+
* @param FormInteractor $formInteractor
25+
*/
2026
public function __construct(FormInteractor $formInteractor)
2127
{
2228
$this->formInteractor = $formInteractor;
2329
}
2430

31+
/**
32+
* @param FormInterface $form
33+
* @param HelperSet $helperSet
34+
* @param InputInterface $input
35+
* @param OutputInterface $output
36+
*
37+
* @throws CanNotInteractWithForm If the input isn't interactive.
38+
* @throws FormNotReadyForInteraction If the "collection" form hasn't the option "allow_add".
39+
*
40+
* @return array
41+
*/
2542
public function interactWith(
2643
FormInterface $form,
2744
HelperSet $helperSet,
@@ -52,6 +69,13 @@ public function interactWith(
5269
return $submittedData;
5370
}
5471

72+
/**
73+
* @param HelperSet $helperSet
74+
* @param InputInterface $input
75+
* @param OutputInterface $output
76+
*
77+
* @return string
78+
*/
5579
private function askIfContinueToAdd(
5680
HelperSet $helperSet,
5781
InputInterface $input,
@@ -68,20 +92,26 @@ private function askIfContinueToAdd(
6892
}
6993

7094
/**
95+
* @param HelperSet $helperSet
96+
*
7197
* @return QuestionHelper
7298
*/
7399
private function questionHelper(HelperSet $helperSet)
74100
{
75101
return $helperSet->get('question');
76102
}
77103

104+
/**
105+
* @param FormInterface $form
106+
* @param OutputInterface $output
107+
*/
78108
private function printHeader(FormInterface $form, OutputInterface $output)
79109
{
80110
$output->writeln(
81111
strtr(
82112
'<fieldset>{label}</fieldset>',
83113
[
84-
'{label}' => FormUtil::label($form)
114+
'{label}' => FormUtil::label($form),
85115
]
86116
)
87117
);

src/Bridge/Interaction/CompoundInteractor.php

+16
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,29 @@
1212

1313
class CompoundInteractor implements FormInteractor
1414
{
15+
/**
16+
* @var FormInteractor
17+
*/
1518
private $formInteractor;
1619

20+
/**
21+
* @param FormInteractor $formInteractor
22+
*/
1723
public function __construct(FormInteractor $formInteractor)
1824
{
1925
$this->formInteractor = $formInteractor;
2026
}
2127

28+
/**
29+
* @param FormInterface $form
30+
* @param HelperSet $helperSet
31+
* @param InputInterface $input
32+
* @param OutputInterface $output
33+
*
34+
* @throws CanNotInteractWithForm If the input isn't interactive or a compound form.
35+
*
36+
* @return array
37+
*/
2238
public function interactWith(
2339
FormInterface $form,
2440
HelperSet $helperSet,

src/Bridge/Interaction/DelegatingInteractor.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,27 @@
1010

1111
class DelegatingInteractor implements FormInteractor
1212
{
13-
/** @var FormInteractor[] */
13+
/**
14+
* @var FormInteractor[]
15+
*/
1416
private $delegates = [];
1517

18+
/**
19+
* @param FormInteractor $interactor
20+
*/
1621
public function addInteractor(FormInteractor $interactor)
1722
{
1823
$this->delegates[] = $interactor;
1924
}
2025

26+
/**
27+
* @param FormInterface $form
28+
* @param HelperSet $helperSet
29+
* @param InputInterface $input
30+
* @param OutputInterface $output
31+
*
32+
* @throws CanNotInteractWithForm If no delegate was able to interact with this form.
33+
*/
2134
public function interactWith(
2235
FormInterface $form,
2336
HelperSet $helperSet,

src/Bridge/Interaction/FieldInteractor.php

+18
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,29 @@
1212

1313
class FieldInteractor implements FormInteractor
1414
{
15+
/**
16+
* @var TransformerResolver
17+
*/
1518
private $transformerResolver;
1619

20+
/**
21+
* @param TransformerResolver $transformerResolver
22+
*/
1723
public function __construct(TransformerResolver $transformerResolver)
1824
{
1925
$this->transformerResolver = $transformerResolver;
2026
}
2127

28+
/**
29+
* @param FormInterface $form
30+
* @param HelperSet $helperSet
31+
* @param InputInterface $input
32+
* @param OutputInterface $output
33+
*
34+
* @throws CanNotInteractWithForm The input isn't interactive.
35+
*
36+
* @return string
37+
*/
2238
public function interactWith(
2339
FormInterface $form,
2440
HelperSet $helperSet,
@@ -35,6 +51,8 @@ public function interactWith(
3551
}
3652

3753
/**
54+
* @param HelperSet $helperSet
55+
*
3856
* @return QuestionHelper
3957
*/
4058
private function questionHelper(HelperSet $helperSet)

src/Bridge/Interaction/FieldWithNoInteractionInteractor.php

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212

1313
class FieldWithNoInteractionInteractor implements FormInteractor
1414
{
15+
/**
16+
* @param FormInterface $form
17+
* @param HelperSet $helperSet
18+
* @param InputInterface $input
19+
* @param OutputInterface $output
20+
*
21+
* @throws NoNeedToInteractWithForm
22+
* @throws CanNotInteractWithForm
23+
*/
1524
public function interactWith(
1625
FormInterface $form,
1726
HelperSet $helperSet,

src/Bridge/Interaction/FormInteractor.php

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
interface FormInteractor
1111
{
12+
/**
13+
* @param FormInterface $form
14+
* @param HelperSet $helperSet
15+
* @param InputInterface $input
16+
* @param OutputInterface $output
17+
*/
1218
public function interactWith(
1319
FormInterface $form,
1420
HelperSet $helperSet,

src/Bridge/Interaction/NonInteractiveRootInteractor.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111

1212
class NonInteractiveRootInteractor implements FormInteractor
1313
{
14+
/**
15+
* @param FormInterface $form
16+
* @param HelperSet $helperSet
17+
* @param InputInterface $input
18+
* @param OutputInterface $output
19+
*
20+
* @throws CanNotInteractWithForm If isn't a root form or is the input is interactive.
21+
*
22+
* @return InputInterface
23+
*/
1424
public function interactWith(
1525
FormInterface $form,
1626
HelperSet $helperSet,
@@ -40,7 +50,7 @@ public function interactWith(
4050
if ($config->getType()->getInnerType() instanceof RepeatedType && $input->hasOption($name)) {
4151
$input->setOption($name, [
4252
$config->getOption('first_name') => $input->getOption($name),
43-
$config->getOption('second_name') => $input->getOption($name)
53+
$config->getOption('second_name') => $input->getOption($name),
4454
]);
4555
}
4656
}

0 commit comments

Comments
 (0)