From 198b6801b90bb19cf2b272b2f22f94f98cb5150d Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 16:12:54 +0100 Subject: [PATCH 1/6] Remove CS dependencies and add zend-coding-standard to require-dev --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2abc628..a7130c3 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } }, "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/PHPUnit": "~4.0" + "phpunit/PHPUnit": "~4.0", + "zendframework/zend-coding-standard": "~1.0.0" } } From 0e7583625e9c831e00725377fd711b2fa19984cd Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:04:18 +0100 Subject: [PATCH 2/6] Delete .php_cs --- .php_cs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .php_cs diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 8f4dd5a..0000000 --- a/.php_cs +++ /dev/null @@ -1,45 +0,0 @@ -in('src') - ->in('test') - ->notPath('TestAsset') - ->notPath('_files') - ->filter(function (SplFileInfo $file) { - if (strstr($file->getPath(), 'compatibility')) { - return false; - } - }); -$config = Symfony\CS\Config\Config::create(); -$config->level(null); -$config->fixers( - array( - 'braces', - 'duplicate_semicolon', - 'elseif', - 'empty_return', - 'encoding', - 'eof_ending', - 'function_call_space', - 'function_declaration', - 'indentation', - 'join_function', - 'line_after_namespace', - 'linefeed', - 'lowercase_keywords', - 'parenthesis', - 'multiple_use', - 'method_argument_space', - 'object_operator', - 'php_closing_tag', - 'remove_lines_between_uses', - 'short_array_syntax', - 'short_tag', - 'standardize_not_equal', - 'trailing_spaces', - 'unused_use', - 'visibility', - 'whitespacy_lines', - ) -); -$config->finder($finder); -return $config; From 0079a41bede930239fd930f6a35cdc861efe7ebf Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:07:04 +0100 Subject: [PATCH 3/6] add/update phpcs.xml --- phpcs.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..9e6a751 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,8 @@ + + + + + + src + test + From 4f49012ef8ae3c2a93cb3e3169c1d5253b289f22 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:28:15 +0100 Subject: [PATCH 4/6] add/update composer scripts --- composer.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/composer.json b/composer.json index a7130c3..3952074 100644 --- a/composer.json +++ b/composer.json @@ -31,5 +31,16 @@ "require-dev": { "phpunit/PHPUnit": "~4.0", "zendframework/zend-coding-standard": "~1.0.0" + }, + "scripts": { + "check": [ + "@cs-check", + "@test" + ], + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "test": "phpunit --colors=always", + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", + "upload-coverage": "coveralls -v" } } From 03123abf22861f655e5b9469bbfd4c44f0187ff0 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:41:39 +0100 Subject: [PATCH 5/6] Use composer scripts in .travis.yml --- .travis.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83e6585..ef51e54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,10 +26,10 @@ matrix: include: - php: 5.5 env: - - EXECUTE_CS_CHECK=true + - CS_CHECK=true - php: 5.6 env: - - EXECUTE_TEST_COVERALLS=true + - TEST_COVERAGE=true - DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)" - PATH="$HOME/.local/bin:$PATH" - php: 7 @@ -42,21 +42,20 @@ notifications: email: false before_install: - - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi + - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi - composer self-update - - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi install: - travis_retry composer install --no-interaction --ignore-platform-reqs script: - - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi - - if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi - - if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi + - if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi - if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi after_success: - if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi after_script: - - if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi + - if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi From 50dea8d882fa3418e02e894f9458d3b807d3e9c7 Mon Sep 17 00:00:00 2001 From: Koopzington Date: Sun, 13 Nov 2016 20:43:26 +0100 Subject: [PATCH 6/6] Replace mentions of php-cs-fixer with phpcs --- CONTRIBUTING.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8eb4657..c29125c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,24 +77,24 @@ To do so: ## Running Coding Standards Checks -This component uses [php-cs-fixer](http://cs.sensiolabs.org/) for coding +This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding standards checks, and provides configuration for our selected checks. -`php-cs-fixer` is installed by default via Composer. +`phpcs` is installed by default via Composer. To run checks only: ```console -$ ./vendor/bin/php-cs-fixer fix . -v --diff --dry-run --config-file=.php_cs +$ ./vendor/bin/phpcs ``` -To have `php-cs-fixer` attempt to fix problems for you, omit the `--dry-run` -flag: +`phpcs` also includes a tool for fixing most CS violations, `phpcbf`: + ```console -$ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs +$ ./vendor/bin/phpcbf ``` -If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure +If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure they pass, and make sure you add and commit the changes after verification. ## Recommended Workflow for Contributions