Skip to content

Commit

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

* DevKit updates

* DevKit updates

* DevKit updates

* Remove StyleCI

* Fix cs

* Bump composer requirements
  • Loading branch information
SonataCI authored and jordisala1991 committed Dec 7, 2017
1 parent 4ef7af0 commit 09ac395
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 96 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 <thomas.rabaix@sonata-project.org>
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 <thomas.rabaix@sonata-project.org>
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
42 changes: 25 additions & 17 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,36 +40,38 @@ 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=3.2.*
- php: '7.1'
- php: '7.2'
env: SYMFONY=3.3.*
- php: '7.1'
env: SYMFONY='dev-master as 3.3'
- php: '7.1'
- php: '7.2'
env: SYMFONY=3.4.*
- php: '7.2'
env: SYMFONY='dev-master as 3.4.x-dev'
- php: '7.2'
env: SONATA_CORE=3.*
- php: '7.1'
env: SONATA_CORE='dev-master as 3'
- php: '7.1'
- php: '7.2'
env: SONATA_CORE='dev-master as 3.x-dev'
- php: '7.2'
env: SONATA_ADMIN=3.*
- php: '7.1'
env: SONATA_ADMIN='dev-master as 3'
- php: '7.1'
- php: '7.2'
env: SONATA_ADMIN='dev-master as 3.x-dev'
- php: '7.2'
env: SYMFONY_DEPRECATIONS_HELPER=0
allow_failures:
- php: nightly
- env: SYMFONY_DEPRECATIONS_HELPER=0
- env: SYMFONY='dev-master as 3.3'
- env: SONATA_CORE='dev-master as 3'
- env: SONATA_ADMIN='dev-master as 3'
- env: SYMFONY='dev-master as 3.4.x-dev'
- env: SONATA_CORE='dev-master as 3.x-dev'
- env: SONATA_ADMIN='dev-master as 3.x-dev'

before_install:
- git remote add upstream ${UPSTREAM_URL} && git fetch --all
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
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
],
"require": {
"php": "^5.6 || ^7.0",
"sonata-project/admin-bundle": "^3.23",
"sonata-project/block-bundle": "^3.4",
"sonata-project/core-bundle": "^3.6",
"sonata-project/admin-bundle": "^3.28",
"sonata-project/block-bundle": "^3.8",
"sonata-project/core-bundle": "^3.7.1",
"symfony/framework-bundle": "^2.8 || ^3.2",
"symfony/options-resolver": "^2.8 || ^3.2",
"twig/twig": "^1.35 || ^2.4"
Expand All @@ -29,8 +29,7 @@
"doctrine/orm": "^2.5",
"knplabs/doctrine-behaviors": "^1.4",
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
"sllh/php-cs-fixer-styleci-bridge": "^2.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.1",
"sonata-project/doctrine-orm-admin-bundle": "^3.2",
"stof/doctrine-extensions-bundle": "^1.1",
"symfony/phpunit-bridge": "^3.3"
},
Expand Down
2 changes: 0 additions & 2 deletions src/Model/Gedmo/AbstractPersonalTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public function getTranslation($field, $locale)
return $translation->getContent();
}
}

return;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Test/DoctrineOrmTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* Inspired by BaseTestCaseORM
* @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
*/
abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase
abstract class DoctrineOrmTestCase extends \PHPUnit\Framework\TestCase
{
/**
* @var EntityManager
Expand Down
2 changes: 0 additions & 2 deletions src/Traits/Gedmo/PersonalTranslatableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public function getTranslation($field, $locale)
return $translation->getContent();
}
}

return;
}

/**
Expand Down

0 comments on commit 09ac395

Please sign in to comment.