diff --git a/composer.json b/composer.json index 685acee1..bc4df8b7 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,6 @@ }, "require-dev": { "phpunit/phpunit": "4.1.*", - "squizlabs/php_codesniffer": "2.*", "cakephp/cakephp-codesniffer": "dev-master" }, "support": { diff --git a/contrib/pre-commit b/contrib/pre-commit index 3a5dfc49..17332fc6 100644 --- a/contrib/pre-commit +++ b/contrib/pre-commit @@ -1,5 +1,6 @@ #!/bin/sh FILES=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php` +PROJECT=`php -r "echo dirname(dirname(realpath('$0')));"` # Determine if a file list is passed if [ "$#" -eq 1 ] @@ -12,14 +13,26 @@ then fi SFILES=${SFILES:-$FILES} -if [ "$FILES" != "" ] +echo "Checking PHP Lint..." +for FILE in $SFILES +do + php -l -d display_errors=0 $PROJECT/$FILE + if [ $? != 0 ] + then + echo "Fix the error before commit." + exit 1 + fi + FILES="$FILES $PROJECT/$FILE" +done + +if [ "$SFILES" != "" ] then echo "Running PHPCS" - ./vendor/bin/phpcs --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=*/config/Migrations/* $SFILES + ./vendor/bin/phpcs --standard=vendor/cakephp/cakephp-codesniffer/CakePHP $SFILES if [ $? != 0 ] then echo "PHPCS Errors found; commit aborted." exit 1 fi fi -exit $? \ No newline at end of file +exit $? diff --git a/src/View/Helper/OptionsAwareTrait.php b/src/View/Helper/OptionsAwareTrait.php index e2a31b3b..ea7f580c 100644 --- a/src/View/Helper/OptionsAwareTrait.php +++ b/src/View/Helper/OptionsAwareTrait.php @@ -9,7 +9,7 @@ trait OptionsAwareTrait * * @var array */ - public $ButtonStyles = [ + public $buttonClasses = [ 'default', 'btn-default', 'success', 'btn-success', 'warning', 'btn-warning', @@ -23,7 +23,7 @@ trait OptionsAwareTrait * * @var array */ - public $ButtonStyleAliases = [ + public $buttonClassAliases = [ 'default' => 'btn-default', 'success' => 'btn-success', 'warning' => 'btn-warning', @@ -40,12 +40,12 @@ trait OptionsAwareTrait */ public function applyButtonStyles(array $data) { - if ($this->hasAnyClass($this->ButtonStyles, $data)) { + if ($this->hasAnyClass($this->buttonClasses, $data)) { $data = $this->injectClasses('btn', $data); } else { $data = $this->injectClasses('btn btn-default', $data); } - return $this->renameClasses($this->ButtonStyleAliases, $data); + return $this->renameClasses($this->buttonClassAliases, $data); } /**