Skip to content

Commit 161d882

Browse files
committed
nextcloud/coding-standard
Signed-off-by: Jean-Yves <[email protected]>
1 parent 69d9c92 commit 161d882

File tree

5 files changed

+219
-4
lines changed

5 files changed

+219
-4
lines changed

.github/workflows/lint-php-cs.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Lint php-cs
10+
11+
on:
12+
pull_request:
13+
paths:
14+
- 'php/**'
15+
push:
16+
branches:
17+
- main
18+
paths:
19+
- 'php/**'
20+
21+
permissions:
22+
contents: read
23+
24+
concurrency:
25+
group: lint-php-cs-${{ github.head_ref || github.run_id }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
lint:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
php-versions: [ "8.3" ]
34+
35+
name: php-cs
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
40+
41+
- name: Set up php ${{ matrix.php-versions }}
42+
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d # v2
43+
with:
44+
php-version: ${{ matrix.php-versions }}
45+
coverage: none
46+
ini-file: development
47+
48+
- name: Install dependencies
49+
run: cd php && composer i
50+
51+
- name: Lint
52+
run: cd php && composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
/php/session/*
77
!/php/data/.gitkeep
88
!/php/session/.gitkeep
9-
/php/vendor
9+
/php/vendor/
10+
/php/.php-cs-fixer.cache
1011

1112
/manual-install/*.conf
1213
!/manual-install/sample.conf

php/.php-cs-fixer.dist.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once './vendor/autoload.php';
6+
7+
use Nextcloud\CodingStandard\Config;
8+
9+
$config = new Config();
10+
$config
11+
->getFinder()
12+
->ignoreVCSIgnored(true)
13+
->notPath('data')
14+
->notPath('session')
15+
->notPath('public')
16+
->notPath('vendor')
17+
->in(__DIR__);
18+
return $config;

php/composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
"require-dev": {
2222
"sserbin/twig-linter": "@dev",
2323
"vimeo/psalm": "^5.25",
24-
"wapmorgan/php-deprecation-detector": "dev-master"
24+
"wapmorgan/php-deprecation-detector": "dev-master",
25+
"nextcloud/coding-standard": "^1.3",
26+
"friendsofphp/php-cs-fixer": "^3"
2527
},
2628
"scripts": {
27-
"dev": [
29+
"dev": [
2830
"Composer\\Config::disableProcessTimeout",
2931
"php -S localhost:8080 -t public"
3032
],
@@ -33,6 +35,8 @@
3335
"psalm:strict": "psalm --threads=1 --show-info=true",
3436
"lint": "php -l src/*.php src/**/*.php public/index.php",
3537
"lint:twig": "twig-linter lint ./templates",
38+
"cs:check": "php-cs-fixer fix --dry-run --diff",
39+
"cs:fix": "php-cs-fixer fix",
3640
"php-deprecation-detector": "phpdd scan -n -t 8.3 src/*.php src/**/*.php public/index.php"
3741
}
3842
}

php/composer.lock

Lines changed: 141 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)