Skip to content

Commit

Permalink
nextcloud/coding-standard
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Yves <[email protected]>
  • Loading branch information
docjyJ committed Oct 4, 2024
1 parent 69d9c92 commit 161d882
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 4 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/lint-php-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Lint php-cs

on:
pull_request:
paths:
- 'php/**'
push:
branches:
- main
paths:
- 'php/**'

permissions:
contents: read

concurrency:
group: lint-php-cs-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ "8.3" ]

name: php-cs

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d # v2
with:
php-version: ${{ matrix.php-versions }}
coverage: none
ini-file: development

- name: Install dependencies
run: cd php && composer i

- name: Lint
run: cd php && composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/php/session/*
!/php/data/.gitkeep
!/php/session/.gitkeep
/php/vendor
/php/vendor/
/php/.php-cs-fixer.cache

/manual-install/*.conf
!/manual-install/sample.conf
Expand Down
18 changes: 18 additions & 0 deletions php/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

require_once './vendor/autoload.php';

use Nextcloud\CodingStandard\Config;

$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('data')
->notPath('session')
->notPath('public')
->notPath('vendor')
->in(__DIR__);
return $config;
8 changes: 6 additions & 2 deletions php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
"require-dev": {
"sserbin/twig-linter": "@dev",
"vimeo/psalm": "^5.25",
"wapmorgan/php-deprecation-detector": "dev-master"
"wapmorgan/php-deprecation-detector": "dev-master",
"nextcloud/coding-standard": "^1.3",
"friendsofphp/php-cs-fixer": "^3"
},
"scripts": {
"dev": [
"dev": [
"Composer\\Config::disableProcessTimeout",
"php -S localhost:8080 -t public"
],
Expand All @@ -33,6 +35,8 @@
"psalm:strict": "psalm --threads=1 --show-info=true",
"lint": "php -l src/*.php src/**/*.php public/index.php",
"lint:twig": "twig-linter lint ./templates",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"php-deprecation-detector": "phpdd scan -n -t 8.3 src/*.php src/**/*.php public/index.php"
}
}
142 changes: 141 additions & 1 deletion php/composer.lock

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

0 comments on commit 161d882

Please sign in to comment.