Skip to content

Commit

Permalink
Add PHP-CS-Fixer support
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs committed Jan 27, 2017
1 parent ae606ef commit 42b0463
Show file tree
Hide file tree
Showing 30 changed files with 232 additions and 311 deletions.
1 change: 1 addition & 0 deletions .gitattributes
@@ -1,6 +1,7 @@
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
CONTRIBUTING.md export-ignore
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -2,6 +2,9 @@
/composer.lock
/vendor

# PHP CS Fixer
/.php_cs.cache

# PHPUnit
/phpunit.xml
/build
29 changes: 29 additions & 0 deletions .php_cs
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Ivory Ordered Form package.
*
* (c) Eric GELOEN <geloen.eric@gmail.com>
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in([
__DIR__.'/src',
__DIR__.'/tests',
])
->exclude('tests/Fixture/Resource/config');

return Config::create()
->setUsingCache(true)
->setRules([
'@Symfony' => true,
'binary_operator_spaces' => ['align_double_arrow' => true],
'ordered_imports' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -24,6 +24,7 @@ install:
- if [[ "$TRAVIS_PHP_VERSION" == "5.3.3" ]]; then composer config -g disable-tls true; fi
- composer self-update
- composer require --no-update symfony/form:${SYMFONY_VERSION}
- composer remove --no-update --dev friendsofphp/php-cs-fixer
- if [[ "$SYMFONY_VERSION" = *dev* ]]; then sed -i "s/\"MIT\"/\"MIT\",\"minimum-stability\":\"dev\"/g" composer.json; fi
- composer update --prefer-source `if [[ $COMPOSER_PREFER_LOWEST = true ]]; then echo "--prefer-lowest --prefer-stable"; fi`

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -10,10 +10,11 @@
}
],
"require": {
"php": ">=5.3.3",
"php": "^5.3|^7.0",
"symfony/form": "^2.3|^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"phpunit/phpunit": "^4.0|^5.0",
"symfony/phpunit-bridge": "^2.7|^3.0"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Builder/OrderedButtonBuilder.php
Expand Up @@ -17,13 +17,13 @@
use Symfony\Component\Form\Exception\BadMethodCallException;

/**
* Ordered button builder.
*
* @author GeLo <geloen.eric@gmail.com>
*/
class OrderedButtonBuilder extends ButtonBuilder implements OrderedFormConfigBuilderInterface, OrderedFormConfigInterface
{
/** @var null|string|array */
/**
* @var string|array|null
*/
private $position;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Builder/OrderedFormBuilder.php
Expand Up @@ -13,17 +13,17 @@

use Ivory\OrderedForm\Exception\OrderedConfigurationException;
use Ivory\OrderedForm\OrderedFormConfigInterface;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\FormBuilder;

/**
* Ordered form builder.
*
* @author GeLo <geloen.eric@gmail.com>
*/
class OrderedFormBuilder extends FormBuilder implements OrderedFormConfigBuilderInterface, OrderedFormConfigInterface
{
/** @var null|string|array */
/**
* @var string|array|null
*/
private $position;

/**
Expand Down
32 changes: 4 additions & 28 deletions src/Builder/OrderedFormConfigBuilderInterface.php
Expand Up @@ -11,6 +11,7 @@

namespace Ivory\OrderedForm\Builder;

use Symfony\Component\Form\Exception\InvalidConfigurationException;
use Symfony\Component\Form\FormConfigBuilderInterface;

/**
Expand All @@ -21,36 +22,11 @@
interface OrderedFormConfigBuilderInterface extends FormConfigBuilderInterface
{
/**
* Sets the form position.
* @param string|array|null $position
*
* * The position can be `null` to reflect the original forms order.
* @throws InvalidConfigurationException
*
* * The position can be `first` to place this form at the first position.
* If many forms are defined as `first`, the original order between these forms is maintained.
* Warning, `first` does not mean "very first" if there are many forms which are defined as `first`
* or if you set up an other form `before` this form.
*
* * The position can be `last` to place this form at the last position.
* If many forms are defined as `last`, the original order between these forms is maintained.
* Warning, `last` does not mean "very last" if there are many forms which are defined as `last`
* or if you set up an other form `after` this form.
*
* * The position can be `array('before' => 'form_name')` to place this form before the `form_name` form.
* If many forms defines the same `before` form, the original order between these forms is maintained.
* Warning, `before` does not mean "just before" if there are many forms which defined the same `before` form.
*
* * The position can be `array('after' => 'form_name')` to place this form after the `form_name` form.
* If many forms defines the same after form, the original order between these forms is maintained.
* Warning, `after` does not mean "just after" if there are many forms which defined the same `after` form.
*
* You can combine the `after` & `before` options together or with `first` and/or `last` to achieve
* more complex use cases.
*
* @param null|string|array $position The form position.
*
* @throws \Symfony\Component\Form\Exception\InvalidConfigurationException If the position is not valid.
*
* @return \Ivory\OrderedForm\OrderedFormConfigBuilderInterface The ordered form configuration builder.
* @return OrderedFormConfigBuilderInterface
*/
public function setPosition($position);
}
8 changes: 4 additions & 4 deletions src/Builder/OrderedSubmitButtonBuilder.php
Expand Up @@ -13,17 +13,17 @@

use Ivory\OrderedForm\Exception\OrderedConfigurationException;
use Ivory\OrderedForm\OrderedFormConfigInterface;
use Symfony\Component\Form\SubmitButtonBuilder;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\SubmitButtonBuilder;

/**
* Ordered submit button builder.
*
* @author GeLo <geloen.eric@gmail.com>
*/
class OrderedSubmitButtonBuilder extends SubmitButtonBuilder implements OrderedFormConfigBuilderInterface, OrderedFormConfigInterface
{
/** @var null|string|array */
/**
* @var string|array|null
*/
private $position;

/**
Expand Down
61 changes: 22 additions & 39 deletions src/Exception/OrderedConfigurationException.php
Expand Up @@ -14,19 +14,15 @@
use Symfony\Component\Form\Exception\InvalidConfigurationException;

/**
* Ordered configuration exception.
*
* @author GeLo <geloen.eric@gmail.com>
*/
class OrderedConfigurationException extends InvalidConfigurationException
{
/**
* Creates a "CIRCULAR DIFFERED" exception.
*
* @param array $stack The circular stack.
* @param string $position The position (before|after).
* @param array $stack
* @param string $position
*
* @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "CIRCULAR DIFFERED" exception.
* @return OrderedConfigurationException
*/
public static function createCircularDiffered(array $stack, $position)
{
Expand All @@ -40,13 +36,11 @@ public static function createCircularDiffered(array $stack, $position)
}

/**
* Creates an "INVALID DIFFERED" exception.
*
* @param string $name The form name.
* @param string $position The position (before|after).
* @param string $differed The differed form name.
* @param string $name
* @param string $position
* @param string $differed
*
* @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "INVALID DIFFERED" exception.
* @return OrderedConfigurationException
*/
public static function createInvalidDiffered($name, $position, $differed)
{
Expand All @@ -62,13 +56,10 @@ public static function createInvalidDiffered($name, $position, $differed)
}

/**
* Creates an "INVALID STRING POSITION" exception.
*
* @param string $name The form name.
* @param string $position The invalid string position.
*
* @param string $name
* @param string $position
*
* @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "INVALID STRING POSITION" exception.
* @return OrderedConfigurationException
*/
public static function createInvalidStringPosition($name, $position)
{
Expand All @@ -80,12 +71,10 @@ public static function createInvalidStringPosition($name, $position)
}

/**
* Creates an "INVALID ARRAY CONFIGURATION" exception.
* @param string $name
* @param array $position
*
* @param string $name The form name.
* @param array $position The invalid array position.
*
* @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "INVALID ARRAY CONFIGURATION" exception.
* @return OrderedConfigurationException
*/
public static function createInvalidArrayPosition($name, array $position)
{
Expand All @@ -97,12 +86,10 @@ public static function createInvalidArrayPosition($name, array $position)
}

/**
* Creates a "SYMETRIC DIFFERED" exception.
*
* @param string $name The form name.
* @param string $symetric The symectric form name.
* @param string $name
* @param string $symetric
*
* @return \Ivory\OrderedForm\Exception\OrderedConfigurationException The "SYMETRIC DIFFERED" exception.
* @return OrderedConfigurationException
*/
public static function createSymetricDiffered($name, $symetric)
{
Expand All @@ -114,12 +101,10 @@ public static function createSymetricDiffered($name, $symetric)
}

/**
* Decorates values with the decorator.
* @param array $values
* @param string $decorator
*
* @param array $values The values.
* @param string $decorator The decorator.
*
* @return array The decorated values.
* @return array
*/
private static function decorateValues(array $values, $decorator = '"')
{
Expand All @@ -133,12 +118,10 @@ private static function decorateValues(array $values, $decorator = '"')
}

/**
* Decorates a value with the decorator.
*
* @param string $value The value.
* @param string $decorator The decorator.
* @param string $value
* @param string $decorator
*
* @return string The decorated value.
* @return string
*/
private static function decorateValue($value, $decorator = '"')
{
Expand Down
4 changes: 1 addition & 3 deletions src/Extension/AbstractOrderedExtension.php
Expand Up @@ -17,8 +17,6 @@
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
* Abstract ordered extension.
*
* @author GeLo <geloen.eric@gmail.com>
*/
abstract class AbstractOrderedExtension extends AbstractTypeExtension
Expand All @@ -32,7 +30,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

/**
* @param OptionsResolver $resolver
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
Expand Down
8 changes: 3 additions & 5 deletions src/Extension/OrderedButtonExtension.php
Expand Up @@ -12,16 +12,14 @@
namespace Ivory\OrderedForm\Extension;

/**
* Ordered form button extension.
*
* @author tweini <tweini@gmail.com>
* @author GeLo <geloen.eric@gmail.com>
* @author tweini <tweini@gmail.com>
*/
class OrderedButtonExtension extends AbstractOrderedExtension
{
/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function getExtendedType()
{
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
Expand Down
2 changes: 0 additions & 2 deletions src/Extension/OrderedExtension.php
Expand Up @@ -14,8 +14,6 @@
use Symfony\Component\Form\AbstractExtension;

/**
* Ordered extension.
*
* @author GeLo <geloen.eric@gmail.com>
*/
class OrderedExtension extends AbstractExtension
Expand Down
2 changes: 0 additions & 2 deletions src/Extension/OrderedFormExtension.php
Expand Up @@ -12,8 +12,6 @@
namespace Ivory\OrderedForm\Extension;

/**
* Ordered form extension.
*
* @author GeLo <geloen.eric@gmail.com>
*/
class OrderedFormExtension extends AbstractOrderedExtension
Expand Down
8 changes: 1 addition & 7 deletions src/OrderedFormConfigInterface.php
Expand Up @@ -14,18 +14,12 @@
use Symfony\Component\Form\FormConfigInterface;

/**
* Ordered form configuration.
*
* @author GeLo <geloen.eric@gmail.com>
*/
interface OrderedFormConfigInterface extends FormConfigInterface
{
/**
* Gets the form position.
*
* @see \Ivory\OrderedForm\OrderedFormConfigBuilderInterface::setPosition
*
* @return null|string|array The form position.
* @return string|array|null
*/
public function getPosition();
}

0 comments on commit 42b0463

Please sign in to comment.