Add composer lint, phpcs, and test commands
authorKunal Mehta <legoktm@gmail.com>
Tue, 6 Jan 2015 18:47:25 +0000 (10:47 -0800)
committerBryanDavis <bdavis@wikimedia.org>
Sun, 1 Mar 2015 07:07:38 +0000 (07:07 +0000)
lint uses jakub-onderka/php-parallel-lint to check the syntax of the provided
PHP files or directories.

phpcs uses the MediaWiki codesniffer standard to check the provided files or
directories.

test runs both lint and phpcs together. phpunit is not included at this time
because our phpunit tests require a database to be set up and are very very
slow.

Example usage:
  composer lint .  # Lint all files
  composer phpcs includes/FooBar.php  # Check code style of one file
  composer test extensions/FooBar  # Lint and check an extension

Change-Id: I3c7ac7a02668776de6400ac268f37e7e6b35a3c6

composer.json

index a289446..11520ef 100644 (file)
                "zordius/lightncandy": "0.18"
        },
        "require-dev": {
+               "jakub-onderka/php-parallel-lint": "~0.8",
                "justinrainbow/json-schema": "~1.3",
-               "phpunit/phpunit": "~4.5"
+               "phpunit/phpunit": "~4.5",
+               "mediawiki/mediawiki-codesniffer": "0.1.0"
        },
        "suggest": {
                "ext-fileinfo": "*",
                }
        },
        "scripts": {
+               "lint": "parallel-lint --exclude vendor",
+               "phpcs": "phpcs $PHPCS_ARGS -s --standard=vendor/mediawiki/mediawiki-codesniffer/MediaWiki --ignore=vendor --encoding=utf-8 --extensions=php,php5,inc,sample",
+               "test": [
+                       "composer lint",
+                       "composer phpcs"
+               ],
                "pre-update-cmd": "ComposerHookHandler::onPreUpdate",
                "pre-install-cmd": "ComposerHookHandler::onPreInstall"
        },