Skip to content

Commit 811ee37

Browse files
authored
Setup phpstan & php linting Github Actions (#71)
1 parent 3d5eb71 commit 811ee37

4 files changed

Lines changed: 89 additions & 1 deletion

File tree

.github/workflows/lint.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "PHP Lint"
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
name: "Lint"
10+
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
php-version:
16+
- "5.3"
17+
- "7.4"
18+
19+
steps:
20+
- name: "Checkout"
21+
uses: "actions/checkout@v2"
22+
23+
- name: "Install PHP"
24+
uses: "shivammathur/setup-php@v2"
25+
with:
26+
coverage: "none"
27+
extensions: "intl"
28+
ini-values: "memory_limit=-1"
29+
php-version: "${{ matrix.php-version }}"
30+
31+
- name: "Lint PHP files"
32+
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"

.github/workflows/phpstan.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "PHPStan"
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist"
9+
10+
jobs:
11+
tests:
12+
name: "PHPStan"
13+
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
php-version:
19+
- "7.4"
20+
21+
steps:
22+
- name: "Checkout"
23+
uses: "actions/checkout@v2"
24+
25+
- name: "Install PHP"
26+
uses: "shivammathur/setup-php@v2"
27+
with:
28+
coverage: "none"
29+
ini-values: "memory_limit=-1"
30+
php-version: "${{ matrix.php-version }}"
31+
32+
33+
- name: "Determine composer cache directory"
34+
id: "determine-composer-cache-directory"
35+
run: "echo \"::set-output name=directory::$(php bin/composer config cache-dir)\""
36+
37+
- name: "Cache dependencies installed with composer"
38+
uses: "actions/cache@v1"
39+
with:
40+
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
41+
key: "php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}"
42+
restore-keys: "php-${{ matrix.php-version }}"
43+
44+
- name: "Install highest dependencies from composer.json using composer binary provided by system"
45+
run: "composer update ${{ env.COMPOSER_FLAGS }}"
46+
47+
- name: Run PHPStan
48+
run: |
49+
composer require --dev phpstan/phpstan:^0.12.26
50+
vendor/bin/phpstan analyse --configuration=phpstan-config.neon

phpstan-config.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 1
3+
4+
paths:
5+
- src/
6+
- tests/

src/Seld/JsonLint/JsonParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function parse($input, $flags = 0)
303303
'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
304304
'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
305305
);
306-
$r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack, $this->lstack);
306+
$r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
307307

308308
if (!$r instanceof Undefined) {
309309
return $r;

0 commit comments

Comments
 (0)