Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
],
"require": {
"php": "^8.1",
"laravel/pint": "^1.0"
"laravel/pint": "^1.0",
"squizlabs/php_codesniffer": "^4.0"
},
"require-dev": {
},
Expand All @@ -21,6 +22,7 @@
}
},
"bin": [
"phpcs",
"pint",
"pint-test"
],
Expand All @@ -43,4 +45,4 @@
"code-quality",
"psr-12"
]
}
}
23 changes: 23 additions & 0 deletions phpcs
Original file line number Diff line number Diff line change
@@ -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" "$@"
28 changes: 28 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!-- @see https://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php -->
<ruleset>
<file>app</file>
<file>database</file>
<file>tests</file>

<!-- Show progress of the run -->
<arg value="p"/>

<!-- Show sniff codes in all reports -->
<arg value="s"/>

<rule ref="PSR12">
<exclude name="Generic.Files.LineLength.TooLong"/>
<exclude name="Generic.Files.LineLength"/>
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
<exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose"/>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>database/</exclude-pattern>
</rule>
</ruleset>
7 changes: 6 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
"sort_algorithm": "none"
},
"ordered_imports": {
"imports_order": [
"class",
"const",
"function"
],
"sort_algorithm": "alpha"
},
"ordered_traits": true,
Expand All @@ -81,4 +86,4 @@
"storage",
"bootstrap/cache"
]
}
}