diff --git a/build.xml b/build.xml index 0a56bf8c8a4cd6620a95743fd3afedb150fa34c8..2a314c7342ff52549b8b1dff95ef9cc5a5d3fb9d 100644 --- a/build.xml +++ b/build.xml @@ -92,11 +92,14 @@ </target> <!-- PHP CodeSniffer --> + <target name="phpcbf"> + <exec command="${srcdir}/vendor/bin/phpcbf --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" /> + </target> <target name="phpcs"> - <exec command="${srcdir}/vendor/bin/phpcs --standard=PEAR --ignore=*/config/*,*/tests/* --extensions=php --report=checkstyle ${srcdir}/module > ${builddir}/reports/checkstyle.xml" escape="false" /> + <exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml --report=checkstyle > ${builddir}/reports/checkstyle.xml" escape="false" /> </target> <target name="phpcs-console"> - <exec command="${srcdir}/vendor/bin/phpcs --standard=PEAR --ignore=*/config/*,*/tests/* --extensions=php ${srcdir}/module" escape="false" passthru="true" checkreturn="true" /> + <exec command="${srcdir}/vendor/bin/phpcs --standard=${srcdir}/tests/phpcs.xml" escape="false" passthru="true" checkreturn="true" /> </target> <!-- php-cs-fixer (first task applies fixes, second task simply checks if they are needed) --> diff --git a/composer.json b/composer.json index d5046ea3463e3f96078489ec6b5a9b15dff856eb..0afc479631004325f6c6ac17189c3931d65e430c 100644 --- a/composer.json +++ b/composer.json @@ -75,7 +75,7 @@ "phpmd/phpmd": "2.6.0", "phpunit/phpunit": "5.7.23", "sebastian/phpcpd": "2.0.4", - "squizlabs/php_codesniffer": "2.8.1" + "squizlabs/php_codesniffer": "3.1.1" }, "scripts": { "phing-install-dependencies": "phing installsolr installswaggerui", diff --git a/composer.lock b/composer.lock index 7e8e449caa7b6cc70140ebd2b8c14b40cd51e117..ceead32b014646ee8d83bee8a31236ada2a3ec1c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7c0daace37c9f5a977d2e56498140d40", + "content-hash": "b3732e69cc23cbf54b86739810be5607", "packages": [ { "name": "aferrandini/phpqrcode", @@ -5894,64 +5894,37 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.8.1", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" + "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d667e245d5dcd4d7bf80f26f2c947d476b66213e", + "reference": "d667e245d5dcd4d7bf80f26f2c947d476b66213e", "shasum": "" }, "require": { "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.1.2" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" }, "bin": [ - "scripts/phpcs", - "scripts/phpcbf" + "bin/phpcs", + "bin/phpcbf" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -5968,7 +5941,7 @@ "phpcs", "standards" ], - "time": "2017-03-01T22:17:45+00:00" + "time": "2017-10-16T22:40:25+00:00" }, { "name": "symfony/config", diff --git a/tests/phpcs.xml b/tests/phpcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..66d337ea4c4aecd865f396ae1500033ddc527c9e --- /dev/null +++ b/tests/phpcs.xml @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<ruleset name="VuFind Coding Standards" namespace="VuFind\PHPCS"> + <description>Coding standards for VuFind.</description> + <file>../module</file> + <exclude-pattern>*/config/*</exclude-pattern> + <exclude-pattern>*/tests/*</exclude-pattern> + <arg name="extensions" value="php"/> + <rule ref="PEAR"> + <exclude name="PEAR.Commenting.FunctionComment.ParamCommentAlignment" /> + </rule> +</ruleset>