Skip to content

Commit

Permalink
Merge pull request #5 from nextcloud/lint
Browse files Browse the repository at this point in the history
add lint check and comply to coding standard
  • Loading branch information
ChristophWurst committed Apr 7, 2021
2 parents 742ed89 + efc2549 commit 68370dd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lint
on:
push:
branches:
- master
- stable*
pull_request:

jobs:
lint-php:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Dependencies
run: composer install --prefer-dist
- name: Load problem matcher for php -l
uses: korelstar/phplint-problem-matcher@v1
- name: PHP syntax check
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
- name: PHP Coding Standards Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff
4 changes: 3 additions & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ declare(strict_types=1);

require_once './vendor/autoload.php';

use ChristophWurst\Nextcloud\CodingStandard\Config;
use Nextcloud\CodingStandard\Config;

$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('vendor')
->in(__DIR__);
return $config;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $config
return $config;
```

To run the fixer you first have to [install it](https://github.com/FriendsOfPhp/PHP-CS-Fixer#installation). Then you can run `php-cs fix` to apply all automated fixes.
To run the fixer you first have to [install it](https://github.com/FriendsOfPhp/PHP-CS-Fixer#installation). Then you can run `php-cs-fixer fix` to apply all automated fixes.

For convenience you may add it to the `scripts` section of your `composer.json`:

Expand Down
11 changes: 3 additions & 8 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

use PhpCsFixer\Config as Base;

class Config extends Base
{

public function __construct($name = 'default')
{
class Config extends Base {
public function __construct($name = 'default') {
parent::__construct($name);
$this->setIndent("\t");
}

public function getRules()
{
public function getRules() {
return [
'@PSR1' => true,
'@PSR2' => true,
Expand Down Expand Up @@ -64,5 +60,4 @@ public function getRules()
],
];
}

}

0 comments on commit 68370dd

Please sign in to comment.