Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
DevKit updates for 2.x branch (#488)
Browse files Browse the repository at this point in the history
* DevKit updates

* DevKit updates

* remove styleCI

* Fix cs
  • Loading branch information
SonataCI authored and jordisala1991 committed Dec 6, 2017
1 parent e5ec0df commit 230b8fa
Show file tree
Hide file tree
Showing 80 changed files with 351 additions and 340 deletions.
39 changes: 2 additions & 37 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
<?php

/*
* DO NOT EDIT THIS FILE!
*
* It's auto-generated by sonata-project/dev-kit package.
*
* Package `sllh/php-cs-fixer-styleci-bridge` is required to get it working.
*/
// TO BE REMOVED.

require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';

use SLLH\StyleCIBridge\ConfigBridge;

$header = <<<EOF
This file is part of the Sonata Project package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

// PHP-CS-Fixer 1.x
if (class_exists('Symfony\CS\Fixer\Contrib\HeaderCommentFixer')) {
\Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
}

$config = ConfigBridge::create()
->setUsingCache(true)
;

// PHP-CS-Fixer 2.x
if (method_exists($config, 'setRules')) {
$config->setRules(array_merge($config->getRules(), array(
'header_comment' => array('header' => $header)
)));
}

return $config;
return require_once __DIR__.'/.php_cs.dist';
77 changes: 77 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

/**
* DO NOT EDIT THIS FILE!
*
* It's auto-generated by sonata-project/dev-kit package.
*/

$header = <<<'HEADER'
This file is part of the Sonata Project package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
HEADER;

$rules = [
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => [
'syntax' => 'short',
],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'header_comment' => [
'header' => $header,
],
'no_extra_consecutive_blank_lines' => true,
'no_php4_constructor' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
// To be tested before insertion:
// 'strict_comparison' => true,
// 'strict_param' => true,
// 'php_unit_strict' => true,
];

if (\PHP_VERSION_ID >= 50600) {
$rules = array_merge($rules, [
'@PHP56Migration' => true,
'@PHP56Migration:risky' => true,
'@PHPUnit57Migration:risky' => true,
]);
}
if (\PHP_VERSION_ID >= 70000) {
$rules = array_merge($rules, [
'@PHP70Migration' => true,
'@PHP70Migration:risky' => true,
'@PHPUnit60Migration:risky' => true,
]);
}
if (\PHP_VERSION_ID >= 70100) {
$rules = array_merge($rules, [
'@PHP71Migration' => true,
'@PHP71Migration:risky' => true,
'compact_nullable_typehint' => true,
]);
}

$finder = PhpCsFixer\Finder::create()
->in(preg_match('/dev-kit\/project$/', __DIR__, $matches) ? __DIR__.'/..' : __DIR__)
->exclude('Tests/Fixtures')
->exclude('tests/Fixtures')
->exclude('Resources/skeleton')
->exclude('Resources/public/vendor')
;

return PhpCsFixer\Config::create()
->setFinder($finder)
->setRiskyAllowed(true)
->setRules($rules)
->setUsingCache(true)
;
31 changes: 1 addition & 30 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
# DO NOT EDIT THIS FILE!
#
# It's auto-generated by sonata-project/dev-kit package.
#
# Package `sllh/php-cs-fixer-styleci-bridge` is required to get it working.

preset: symfony

enabled:
- combine_consecutive_unsets
- short_array_syntax
- newline_after_open_tag
- no_php4_constructor
- no_useless_else
- ordered_class_elements
- ordered_use
# Comment strict rules for the moment. Should be uncomment later to see StyleCI PR results
# - strict
# - strict_param
# - php_unit_construct
# - php_unit_strict

finder:
exclude:
- 'Tests/Fixtures'
- 'tests/Fixtures'
# ecommerce special case:
- 'Resources/skeleton'
# ignore vendor assets
- 'Resources/public/vendor'
# TO BE REMOVED
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- nightly

sudo: false
dist: trusty

addons:
apt:
packages:
- libxml2-utils

cache:
pip: true
directories:
Expand All @@ -34,17 +40,17 @@ env:
matrix:
fast_finish: true
include:
- php: '7.1'
- php: '7.2'
env: TARGET=docs
- php: '7.1'
- php: '5.6'
env: TARGET=lint
- php: '5.6'
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '7.1'
- php: '7.2'
env: SYMFONY=2.8.*
- php: '7.1'
- php: '7.2'
env: SYMFONY='dev-master as 2.8.x-dev'
- php: '7.1'
- php: '7.2'
env: SYMFONY_DEPRECATIONS_HELPER=0
allow_failures:
- php: nightly
Expand Down
5 changes: 5 additions & 0 deletions .travis/install_lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env sh
set -ev

mkdir --parents "${HOME}/bin"

wget "http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar" --output-document="${HOME}/bin/php-cs-fixer"
chmod u+x "${HOME}/bin/php-cs-fixer"

composer global require sllh/composer-lint:@stable --prefer-dist --no-interaction

gem install yaml-lint
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ and run this command before committing your modifications:
php-cs-fixer fix --verbose
```

Please note that we try to keep phpdoc to a minimum, so if an `@param` phpdoc
comment brings nothing more than the type hint and variable name already do,
it should be removed. Descriptions are optional if you want to document a type.

```php
/**
* @param Bar|Baz $foo
* @param int $limit a crucial, highly interesting comment
*/
protected function bar($foo, string $name, int $limit)
{
// ...
}
```

Please also note that multiline signatures are allowed when the line is longer than 120 characters.

#### The documentation

The documentation is mostly written with the `rst` format, and can be found in the `docs` directory.
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ lint:
composer validate
find . -name '*.yml' -not -path './vendor/*' -not -path './Resources/public/vendor/*' | xargs yaml-lint
find . \( -name '*.xml' -or -name '*.xliff' \) \
-not -path './vendor/*' -not -path './Resources/public/vendor/*' -type f \
-exec xmllint --encode UTF-8 --output '{}' --format '{}' \;
-not -path './vendor/*' -not -path './Resources/public/vendor/*' \
| xargs -I'{}' xmllint --encode UTF-8 --output '{}' --format '{}'
php-cs-fixer fix --verbose
git diff --exit-code

test:
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"symfony/validator": "^2.8"
},
"require-dev": {
"sllh/php-cs-fixer-styleci-bridge": "^2.1",
"symfony/phpunit-bridge": "^3.3"
},
"conflict": {
Expand Down
36 changes: 18 additions & 18 deletions src/BasketBundle/Controller/Api/BasketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public function getBasketBasketelementsAction($id)
*
* @param Request $request A Symfony request
*
* @return BasketInterface
*
* @throws NotFoundHttpException
*
* @return BasketInterface
*/
public function postBasketAction(Request $request)
{
Expand All @@ -213,9 +213,9 @@ public function postBasketAction(Request $request)
* @param int $id A Basket identifier
* @param Request $request A Symfony request
*
* @return BasketInterface
*
* @throws NotFoundHttpException
*
* @return BasketInterface
*/
public function putBasketAction($id, Request $request)
{
Expand All @@ -238,9 +238,9 @@ public function putBasketAction($id, Request $request)
*
* @param int $id A Basket identifier
*
* @return \FOS\RestBundle\View\View
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
*/
public function deleteBasketAction($id)
{
Expand Down Expand Up @@ -274,9 +274,9 @@ public function deleteBasketAction($id)
* @param int $id A basket identifier
* @param Request $request A Symfony request
*
* @return BasketInterface
*
* @throws NotFoundHttpException
*
* @return BasketInterface
*/
public function postBasketBasketelementsAction($id, Request $request)
{
Expand Down Expand Up @@ -304,9 +304,9 @@ public function postBasketBasketelementsAction($id, Request $request)
* @param int $elementId A basket element identifier
* @param Request $request A Symfony request
*
* @return BasketInterface
*
* @throws NotFoundHttpException
*
* @return BasketInterface
*/
public function putBasketBasketelementsAction($basketId, $elementId, Request $request)
{
Expand All @@ -331,9 +331,9 @@ public function putBasketBasketelementsAction($basketId, $elementId, Request $re
* @param int $basketId A basket identifier
* @param int $elementId A basket element identifier
*
* @return \FOS\RestBundle\View\View
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
*/
public function deleteBasketBasketelementsAction($basketId, $elementId)
{
Expand Down Expand Up @@ -487,9 +487,9 @@ protected function handleWriteBasketElement($basketId, $request, $elementId = nu
*
* @param $id
*
* @return BasketInterface
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*
* @return BasketInterface
*/
protected function getBasket($id)
{
Expand All @@ -507,9 +507,9 @@ protected function getBasket($id)
*
* @param $id
*
* @return BasketElementInterface
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*
* @return BasketElementInterface
*/
protected function getBasketElement($id)
{
Expand All @@ -527,9 +527,9 @@ protected function getBasketElement($id)
*
* @param $id
*
* @return ProductInterface
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*
* @return ProductInterface
*/
protected function getProduct($id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('form.xml');
$loader->load('twig.xml');

if (isset($bundles['FOSRestBundle']) && isset($bundles['NelmioApiDocBundle'])) {
if (isset($bundles['FOSRestBundle'], $bundles['NelmioApiDocBundle'])) {
$loader->load('api_controllers.xml');
$loader->load('api_form.xml');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Form/EventListener/BasketResizeFormListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public function preBind(FormEvent $event)
}

/**
* @throws \Symfony\Component\Form\Exception\UnexpectedTypeException
*
* @param $form
* @param $basketElements
*
* @throws \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
private function buildBasketElements($form, $basketElements)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Form/Transformer/QuantityTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public function transform($quantity)
*/
public function reverseTransform($quantity)
{
return intval($quantity);
return (int) $quantity;
}
}
2 changes: 1 addition & 1 deletion src/Component/Generator/PostgresReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function order(OrderInterface $order)
*
* @return string
*/
protected function generateReference($object, $tableName)
private function generateReference($object, $tableName)
{
$date = new \DateTime();

Expand Down
Loading

0 comments on commit 230b8fa

Please sign in to comment.