From 8b91f20f307405dc8705d66599436bc7a85c7a15 Mon Sep 17 00:00:00 2001 From: Leho Kraav Date: Thu, 24 Sep 2020 15:20:48 +0300 Subject: [PATCH] phpcbf lint-staged integration [1] 1: https://github.com/squizlabs/PHP_CodeSniffer/issues/1359 --- bin/phpcbf-fix-exit-0 | 25 +++++++++++++++++++++++++ composer.json | 3 +++ 2 files changed, 28 insertions(+) create mode 100644 bin/phpcbf-fix-exit-0 diff --git a/bin/phpcbf-fix-exit-0 b/bin/phpcbf-fix-exit-0 new file mode 100644 index 0000000..19ef67c --- /dev/null +++ b/bin/phpcbf-fix-exit-0 @@ -0,0 +1,25 @@ +#!/usr/bin/env php + + * @see https://github.com/squizlabs/PHP_CodeSniffer/blob/master/bin/phpcbf + * @see https://github.com/squizlabs/PHP_CodeSniffer/issues/1359 + */ + +if (is_file(__DIR__.'/../autoload.php') === true) { + include_once __DIR__.'/../autoload.php'; +} else { + include_once 'PHP/CodeSniffer/autoload.php'; +} + +$runner = new PHP_CodeSniffer\Runner(); +$exitCode = $runner->runPHPCBF(); + +if ( 1 === $exitCode ){ + $exitCode = 0; +} +exit($exitCode); diff --git a/composer.json b/composer.json index ef5009e..9ea5c67 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,9 @@ "name": "cxl/phpcs-ruleset", "description": "PHP CS coding standards for CXL projects.", "type": "phpcodesniffer-standard", + "bin": [ + "bin/phpcbf-fix-exit-0" + ], "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", "wp-coding-standards/wpcs": "^2.3"