Skip to content

Commit

Permalink
feat: added phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
benborla committed Nov 17, 2023
1 parent 66d4566 commit 2a4735e
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 6 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,25 @@ jobs:
uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate --strict
run: |
cd api
composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
path: api/vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
run: |
cd api
composer install --prefer-dist --no-progress
- name: PHP Lint
run: find . -name "*.php" -print0 | xargs -0 -n1 php -l
run: |
cd api
composer run lint ./src ./tests
5 changes: 5 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###

###> squizlabs/php_codesniffer ###
/.phpcs-cache
/phpcs.xml
###< squizlabs/php_codesniffer ###
4 changes: 3 additions & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"doctrine/doctrine-fixtures-bundle": "^3.5",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7",
"symfony/browser-kit": "6.3.*",
"symfony/css-selector": "6.3.*",
"symfony/maker-bundle": "^1.51",
Expand Down Expand Up @@ -65,7 +66,8 @@
"@auto-scripts"
],
"test_setup_db": "php bin/console doctrine:fixtures:load --env=test",
"test": "php bin/phpunit"
"test": "php bin/phpunit",
"lint": "./vendor/bin/phpcs --standard=PSR12"
},
"conflict": {
"symfony/symfony": "*"
Expand Down
59 changes: 58 additions & 1 deletion api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions api/phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>

<rule ref="PSR12"/>

<file>bin/</file>
<file>config/</file>
<file>public/</file>
<file>src/</file>
<file>tests/</file>

</ruleset>
12 changes: 12 additions & 0 deletions api/symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@
"tests/bootstrap.php"
]
},
"squizlabs/php_codesniffer": {
"version": "3.7",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "3.6",
"ref": "1019e5c08d4821cb9b77f4891f8e9c31ff20ac6f"
},
"files": [
"phpcs.xml.dist"
]
},
"symfony/console": {
"version": "6.3",
"recipe": {
Expand Down

0 comments on commit 2a4735e

Please sign in to comment.