From 6fa4167416cb037bf0d9b5398b3706b8738aefb9 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Tue, 28 Nov 2017 02:07:58 +0100 Subject: [PATCH 1/7] DevKit updates --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 532739e9..b0c3b673 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,23 +47,23 @@ matrix: - php: '7.1' env: SYMFONY=3.3.* - php: '7.1' - env: SYMFONY='dev-master as 3.3' + env: SYMFONY='dev-master as 3.3.x-dev' - php: '7.1' env: SONATA_CORE=3.* - php: '7.1' - env: SONATA_CORE='dev-master as 3' + env: SONATA_CORE='dev-master as 3.x-dev' - php: '7.1' env: SONATA_ADMIN=3.* - php: '7.1' - env: SONATA_ADMIN='dev-master as 3' + env: SONATA_ADMIN='dev-master as 3.x-dev' - php: '7.1' 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.3.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 From 2bc4dcadc0c07c25611df931ccb3a3e8293c8535 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Fri, 1 Dec 2017 02:07:48 +0100 Subject: [PATCH 2/7] DevKit updates --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0c3b673..5e87495a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,7 +47,11 @@ matrix: - php: '7.1' env: SYMFONY=3.3.* - php: '7.1' - env: SYMFONY='dev-master as 3.3.x-dev' + env: SYMFONY=3.4.* + - php: '7.1' + env: SYMFONY=4.0.* + - php: '7.1' + env: SYMFONY='dev-master as 4.0.x-dev' - php: '7.1' env: SONATA_CORE=3.* - php: '7.1' @@ -61,7 +65,7 @@ matrix: allow_failures: - php: nightly - env: SYMFONY_DEPRECATIONS_HELPER=0 - - env: SYMFONY='dev-master as 3.3.x-dev' + - env: SYMFONY='dev-master as 4.0.x-dev' - env: SONATA_CORE='dev-master as 3.x-dev' - env: SONATA_ADMIN='dev-master as 3.x-dev' From e73e9b7e185b730c8c2428e7ce904688c9fe0b59 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Mon, 4 Dec 2017 18:20:56 +0100 Subject: [PATCH 3/7] DevKit updates --- .php_cs | 39 ++------------------- .php_cs.dist | 76 +++++++++++++++++++++++++++++++++++++++++ .styleci.yml | 31 +---------------- .travis.yml | 27 ++++++++------- .travis/install_lint.sh | 5 +++ CONTRIBUTING.md | 17 +++++++++ Makefile | 1 + 7 files changed, 116 insertions(+), 80 deletions(-) create mode 100644 .php_cs.dist diff --git a/.php_cs b/.php_cs index dcd9cd1b..5f6b5da1 100644 --- a/.php_cs +++ b/.php_cs @@ -1,40 +1,5 @@ - -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'; diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 00000000..8a9c5cf9 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,76 @@ + + +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, + 'ternary_to_null_coalescing' => 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:risky' => true, + '@PHPUnit60Migration:risky' => true, + ]); +} +if (\PHP_VERSION_ID >= 70100) { + $rules = array_merge($rules, [ + '@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) +; diff --git a/.styleci.yml b/.styleci.yml index 6424eea7..fb48254e 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -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 diff --git a/.travis.yml b/.travis.yml index 5e87495a..5214524b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ php: - '5.6' - '7.0' - '7.1' + - '7.2' - nightly sudo: false @@ -34,33 +35,33 @@ 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' + - php: '7.2' env: SYMFONY=3.4.* - - php: '7.1' + - php: '7.2' env: SYMFONY=4.0.* - - php: '7.1' + - php: '7.2' env: SYMFONY='dev-master as 4.0.x-dev' - - php: '7.1' + - php: '7.2' env: SONATA_CORE=3.* - - php: '7.1' + - php: '7.2' env: SONATA_CORE='dev-master as 3.x-dev' - - php: '7.1' + - php: '7.2' env: SONATA_ADMIN=3.* - - php: '7.1' + - php: '7.2' env: SONATA_ADMIN='dev-master as 3.x-dev' - - php: '7.1' + - php: '7.2' env: SYMFONY_DEPRECATIONS_HELPER=0 allow_failures: - php: nightly diff --git a/.travis/install_lint.sh b/.travis/install_lint.sh index ab8f0f39..864c751e 100755 --- a/.travis/install_lint.sh +++ b/.travis/install_lint.sh @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 029f06c3..30f3a9c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/Makefile b/Makefile index 43e65b4e..5ec0d389 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ lint: find . \( -name '*.xml' -or -name '*.xliff' \) \ -not -path './vendor/*' -not -path './Resources/public/vendor/*' -type f \ -exec xmllint --encode UTF-8 --output '{}' --format '{}' \; + php-cs-fixer fix --verbose git diff --exit-code test: From 4b750755a51be7a8481f2a37a1430f2d0fd92687 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Wed, 6 Dec 2017 11:16:34 +0100 Subject: [PATCH 4/7] DevKit updates --- .php_cs.dist | 3 ++- .travis.yml | 11 +++++++---- Makefile | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 8a9c5cf9..62b8e5aa 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -33,7 +33,6 @@ $rules = [ 'ordered_class_elements' => true, 'ordered_imports' => true, 'phpdoc_order' => true, - 'ternary_to_null_coalescing' => true, // To be tested before insertion: // 'strict_comparison' => true, // 'strict_param' => true, @@ -49,12 +48,14 @@ if (\PHP_VERSION_ID >= 50600) { } 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, ]); diff --git a/.travis.yml b/.travis.yml index 5214524b..e2d12d11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,11 @@ php: sudo: false dist: trusty +addons: + apt: + packages: + - libxml2-utils + cache: pip: true directories: @@ -50,9 +55,7 @@ matrix: - php: '7.2' env: SYMFONY=3.4.* - php: '7.2' - env: SYMFONY=4.0.* - - php: '7.2' - env: SYMFONY='dev-master as 4.0.x-dev' + env: SYMFONY='dev-master as 3.4.x-dev' - php: '7.2' env: SONATA_CORE=3.* - php: '7.2' @@ -66,7 +69,7 @@ matrix: allow_failures: - php: nightly - env: SYMFONY_DEPRECATIONS_HELPER=0 - - env: SYMFONY='dev-master as 4.0.x-dev' + - 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' diff --git a/Makefile b/Makefile index 5ec0d389..6fb54c87 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,8 @@ 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 From 4c201df85eeaac2e2dc9fcd064905cf3d440c445 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Wed, 6 Dec 2017 13:19:48 +0100 Subject: [PATCH 5/7] Remove StyleCI --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 1fbda3d5..da30d8a0 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "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", "stof/doctrine-extensions-bundle": "^1.1", "symfony/phpunit-bridge": "^3.3" From d34c0acbb069ac4fe01d92e143fe19beb371ef15 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Wed, 6 Dec 2017 13:20:44 +0100 Subject: [PATCH 6/7] Fix cs --- src/Model/Gedmo/AbstractPersonalTranslatable.php | 2 -- src/Test/DoctrineOrmTestCase.php | 2 +- src/Traits/Gedmo/PersonalTranslatableTrait.php | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Model/Gedmo/AbstractPersonalTranslatable.php b/src/Model/Gedmo/AbstractPersonalTranslatable.php index c3d5926f..52d5cb3b 100644 --- a/src/Model/Gedmo/AbstractPersonalTranslatable.php +++ b/src/Model/Gedmo/AbstractPersonalTranslatable.php @@ -58,8 +58,6 @@ public function getTranslation($field, $locale) return $translation->getContent(); } } - - return; } /** diff --git a/src/Test/DoctrineOrmTestCase.php b/src/Test/DoctrineOrmTestCase.php index d65ec72b..1d272d85 100644 --- a/src/Test/DoctrineOrmTestCase.php +++ b/src/Test/DoctrineOrmTestCase.php @@ -28,7 +28,7 @@ * Inspired by BaseTestCaseORM * @author Gediminas Morkevicius */ -abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase +abstract class DoctrineOrmTestCase extends \PHPUnit\Framework\TestCase { /** * @var EntityManager diff --git a/src/Traits/Gedmo/PersonalTranslatableTrait.php b/src/Traits/Gedmo/PersonalTranslatableTrait.php index a5d98b9e..eea593b0 100644 --- a/src/Traits/Gedmo/PersonalTranslatableTrait.php +++ b/src/Traits/Gedmo/PersonalTranslatableTrait.php @@ -43,8 +43,6 @@ public function getTranslation($field, $locale) return $translation->getContent(); } } - - return; } /** From 6da36e4270696af8e5f7cd46d341e879249b6d3f Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Thu, 7 Dec 2017 01:22:57 +0100 Subject: [PATCH 7/7] Bump composer requirements --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index da30d8a0..e95ee5c1 100644 --- a/composer.json +++ b/composer.json @@ -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" @@ -29,7 +29,7 @@ "doctrine/orm": "^2.5", "knplabs/doctrine-behaviors": "^1.4", "matthiasnoback/symfony-dependency-injection-test": "^1.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" },