Skip to content

Commit 3800dd2

Browse files
Update package
- Make it compatible with recent changes in Symfony components - Make tests less fragile - Add git pre-commit hook to make contributing easier - Clean up Travis configuration file
1 parent 7125849 commit 3800dd2

17 files changed

+83
-66
lines changed

.travis.yml

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

3-
php:
4-
- 5.6
5-
- 7.0
6-
73
matrix:
8-
allow_failures:
9-
- php: hhvm
104
include:
115
- php: 5.6
126
env: SYMFONY_VERSION=2.8.*
137
- php: 7.0
148
env: SYMFONY_VERSION=3.0.*
15-
16-
env:
17-
global:
18-
- SYMFONY_VERSION=""
9+
- php: 7.0
10+
env: SYMFONY_VERSION=3.1.*
11+
- php: 7.0
12+
env: SYMFONY_VERSION=3.2.*
1913

2014
before_install:
2115
- >
22-
if [ "$SYMFONY_VERSION" != "" ]; then
23-
composer require --dev --no-update symfony/framework-bundle "$SYMFONY_VERSION" &&
24-
composer require --dev --no-update symfony/console "$SYMFONY_VERSION" &&
25-
composer require --dev --no-update symfony/validator "$SYMFONY_VERSION" &&
26-
composer require --dev --no-update symfony/form "$SYMFONY_VERSION" &&
27-
composer require --dev --no-update symfony/yaml "$SYMFONY_VERSION" &&
28-
composer require --dev --no-update symfony/finder "$SYMFONY_VERSION"
16+
composer require --dev --no-update symfony/framework-bundle "$SYMFONY_VERSION" &&
17+
composer require --dev --no-update symfony/console "$SYMFONY_VERSION" &&
18+
composer require --dev --no-update symfony/validator "$SYMFONY_VERSION" &&
19+
composer require --dev --no-update symfony/form "$SYMFONY_VERSION" &&
20+
composer require --dev --no-update symfony/yaml "$SYMFONY_VERSION" &&
21+
composer require --dev --no-update symfony/finder "$SYMFONY_VERSION"
22+
23+
if [ "$SYMFONY_VERSION" = "3.2.*" ]; then
24+
composer require --dev --no-update symfony/security-csrf "$SYMFONY_VERSION"
2925
fi
3026
3127
install:
@@ -35,7 +31,4 @@ script:
3531
- vendor/bin/php-cs-fixer fix -v --diff --dry-run
3632
- vendor/bin/behat
3733

38-
notifications:
39-
40-
4134
sudo: false

CONTRIBUTING.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
1-
## Running Coding Standards Checks
1+
If you want to contribute to this library, clone this project, then:
22

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.
3+
- Run `composer install` to install dependencies.
4+
- Run `./install-git-hooks.sh` to install the pre-commit hook which fixes coding style problems automatically for you.
65

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.
6+
Take a look at `.travis.yml` to find out which versions of Symfony are currently supported by this library. The easiest way to find out if your code changes are compatible with different versions of Symfony is to register your cloned repository at Travis. Then push your code to GitHub and wait for the Travis build to finish. If the build fails for a particular Symfony version you can reproduce the build locally by exporting the same environment variables as Travis does and running the install and test scripts on your machine.

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@
3030
"require-dev": {
3131
"beberlei/assert": "~2.1",
3232
"behat/behat": "~3.0",
33-
"fabpot/php-cs-fixer": "^1.10",
34-
"symfony/console": "~2.8|~3.0",
33+
"friendsofphp/php-cs-fixer": "^1.10",
3534
"symfony/finder": "~2.8|~3.0",
36-
"symfony/form": "~2.8|~3.0",
3735
"symfony/framework-bundle": "~2.8|~3.0",
3836
"symfony/validator": "~2.8|~3.0",
39-
"symfony/yaml": "~2.8|~3.0"
37+
"symfony/yaml": "~2.8|~3.0",
38+
"phpunit/phpunit": "^4.8"
4039
}
4140
}

features/bootstrap/FeatureContext.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public function iRunTheCommandAndIProvideAsInputOneLine($name, $input)
6161
*/
6262
public function theOutputShouldBe(PyStringNode $expectedOutput)
6363
{
64-
Assertion::same(StringUtil::trimLines($this->getOutput()), StringUtil::trimLines((string) $expectedOutput));
64+
\PHPUnit_Framework_Assert::assertSame(
65+
StringUtil::trimLines((string) $expectedOutput),
66+
StringUtil::trimLines($this->getOutput())
67+
);
6568
}
6669

6770
private function runCommandWithInteractiveInput($name, $input)

features/interactive.feature

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ Feature: It is possible to interactively fill in a form from the CLI
4444
Then the command has finished successfully
4545
And the output should be
4646
"""
47-
Your date of birth [1879-03-14]: Array
47+
Your date of birth [1987-03-14]: Array
4848
(
49-
[dateOfBirth] => DateTime Object
50-
(
51-
[date] => 2015-03-04 00:00:00.000000
52-
[timezone_type] => 1
53-
[timezone] => +00:00
54-
)
49+
[dateOfBirth] => 2015-03-04T00:00:00+0000
5550
)
5651
"""
5752

git-hooks/pre-commit

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
# Redirect output to stderr.
4+
exec 1>&2
5+
6+
ROOT="$PWD"
7+
PHP_CS_FIXER="${ROOT}/vendor/bin/php-cs-fixer"
8+
PHP_CS_CONFIG="${ROOT}/.php_cs"
9+
10+
if [ ! -f "$PHP_CS_CONFIG" ]; then
11+
echo "Please run 'git commit' from the root directory of the project"
12+
exit 1
13+
fi
14+
15+
if [ ! -x "$PHP_CS_FIXER" ]; then
16+
echo "Please run 'composer install' first"
17+
exit 1
18+
fi
19+
20+
git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
21+
$PHP_CS_FIXER fix --config-file=$PHP_CS_CONFIG --verbose "$line";
22+
git add "$line";
23+
done

install-git-hooks.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
ROOT="$PWD"
4+
5+
if [ ! -d git-hooks ]; then
6+
echo "Run this script from the root directory of the project" >&2
7+
fi
8+
9+
ln -s "$ROOT/git-hooks/pre-commit" "$ROOT/.git/hooks/pre-commit"

src/Bridge/FormFactory/ConsoleFormFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface ConsoleFormFactory
1212
* @param string|FormTypeInterface $formType
1313
* @param InputInterface $input
1414
* @param array $options
15-
*
15+
*
1616
* @return FormInterface
1717
*/
1818
public function create($formType, InputInterface $input, array $options = []);

src/Bridge/Interaction/CollectionInteractor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function __construct(FormInteractor $formInteractor)
3535
* @param InputInterface $input
3636
* @param OutputInterface $output
3737
*
38-
* @throws CanNotInteractWithForm If the input isn't interactive.
39-
* @throws FormNotReadyForInteraction If the "collection" form hasn't the option "allow_add".
38+
* @throws CanNotInteractWithForm If the input isn't interactive
39+
* @throws FormNotReadyForInteraction If the "collection" form hasn't the option "allow_add"
4040
*
4141
* @return array
4242
*/
@@ -74,7 +74,7 @@ public function interactWith(
7474
* @param HelperSet $helperSet
7575
* @param InputInterface $input
7676
* @param OutputInterface $output
77-
*
77+
*
7878
* @return string
7979
*/
8080
private function askIfContinueToAdd(
@@ -94,7 +94,7 @@ private function askIfContinueToAdd(
9494

9595
/**
9696
* @param HelperSet $helperSet
97-
*
97+
*
9898
* @return QuestionHelper
9999
*/
100100
private function questionHelper(HelperSet $helperSet)

src/Bridge/Interaction/CompoundInteractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(FormInteractor $formInteractor)
3131
* @param InputInterface $input
3232
* @param OutputInterface $output
3333
*
34-
* @throws CanNotInteractWithForm If the input isn't interactive or a compound form.
34+
* @throws CanNotInteractWithForm If the input isn't interactive or a compound form
3535
*
3636
* @return array
3737
*/

0 commit comments

Comments
 (0)