diff --git a/composer.json b/composer.json index a2ebe14..c34f44e 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ ], "require": { "php": "^8.1", - "laravel/pint": "^1.0" + "laravel/pint": "^1.0", + "squizlabs/php_codesniffer": "^4.0" }, "require-dev": { }, @@ -21,6 +22,7 @@ } }, "bin": [ + "phpcs", "pint", "pint-test" ], @@ -43,4 +45,4 @@ "code-quality", "psr-12" ] -} \ No newline at end of file +} diff --git a/phpcs b/phpcs new file mode 100644 index 0000000..4b55233 --- /dev/null +++ b/phpcs @@ -0,0 +1,23 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +CONFIG_FILE="$SCRIPT_DIR/phpcs.xml" + +PINT_EXECUTABLE="" +if [ -f "./vendor/squizlabs/php_codesniffer/bin/phpcs" ]; then + PINT_EXECUTABLE="./vendor/squizlabs/php_codesniffer/bin/phpcs" +else + echo "Error: PHP CS not found." + exit 1 +fi + +# Check if config file exists +if [ ! -f "$CONFIG_FILE" ]; then + echo "Error: phpcs.xml config file not found at $CONFIG_FILE" + exit 1 +fi + +# Run pint with the config file and pass through all arguments +echo "Running PHP CS with config: $CONFIG_FILE" +$PINT_EXECUTABLE --standard="$CONFIG_FILE" "$@" diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..fbb4201 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,28 @@ + + + + app + database + tests + + + + + + + + + + + + + + + + + + + + database/ + + diff --git a/pint.json b/pint.json index ddc35ef..b1b3bcd 100644 --- a/pint.json +++ b/pint.json @@ -64,6 +64,11 @@ "sort_algorithm": "none" }, "ordered_imports": { + "imports_order": [ + "class", + "const", + "function" + ], "sort_algorithm": "alpha" }, "ordered_traits": true, @@ -81,4 +86,4 @@ "storage", "bootstrap/cache" ] -} \ No newline at end of file +}