Skip to content

Commit 77b97d5

Browse files
committed
Added PHPStan
1 parent e95fbc8 commit 77b97d5

File tree

7 files changed

+11805
-14
lines changed

7 files changed

+11805
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,28 @@ on:
1010
jobs:
1111
cs-fix:
1212
name: Run code style check
13-
runs-on: "ubuntu-20.04"
14-
strategy:
15-
matrix:
16-
php:
17-
- '8.0'
13+
runs-on: "ubuntu-22.04"
1814
steps:
19-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
2016

2117
- name: Setup PHP Action
2218
uses: shivammathur/setup-php@v2
2319
with:
24-
php-version: ${{ matrix.php }}
20+
php-version: '8.0'
2521
coverage: none
2622
extensions: 'pdo_sqlite, gd'
2723
tools: cs2pr
2824

29-
- uses: "ramsey/composer-install@v1"
25+
- uses: ramsey/composer-install@v2
3026
with:
31-
dependency-versions: "highest"
27+
dependency-versions: highest
3228

3329
- name: Run code style check
3430
run: composer run-script check-cs -- --format=checkstyle | cs2pr
3531

3632
tests:
3733
name: Unit & integration tests
38-
runs-on: "ubuntu-20.04"
34+
runs-on: "ubuntu-22.04"
3935
timeout-minutes: 15
4036

4137
strategy:
@@ -47,7 +43,7 @@ jobs:
4743
- '8.1'
4844

4945
steps:
50-
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v3
5147

5248
- name: Setup PHP Action
5349
uses: shivammathur/setup-php@v2
@@ -57,9 +53,12 @@ jobs:
5753
extensions: pdo_sqlite, gd
5854
tools: cs2pr
5955

60-
- uses: "ramsey/composer-install@v1"
56+
- uses: ramsey/composer-install@v2
6157
with:
62-
dependency-versions: "highest"
58+
dependency-versions: highest
59+
60+
- name: Run PHPStan analysis
61+
run: composer run-script phpstan
6362

6463
- name: Setup problem matchers for PHPUnit
6564
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
@@ -68,6 +67,7 @@ jobs:
6867
run: composer test
6968
- name: Run integration test suite
7069
run: composer test-integration
70+
7171
functional-tests:
7272
name: "REST functional tests"
7373
uses: ./.github/workflows/integration-tests-callable.yaml

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@
5656
"nyholm/psr7": "^1.1",
5757
"symfony/http-client": "^5.3",
5858
"symfony/browser-kit": "^5.3",
59-
"justinrainbow/json-schema": "^5.2"
59+
"justinrainbow/json-schema": "^5.2",
60+
"phpstan/phpstan": "^1.10",
61+
"phpstan/phpstan-symfony": "^1.3",
62+
"phpstan/phpstan-phpunit": "^1.3",
63+
"phpstan/phpstan-webmozart-assert": "^1.2"
6064
},
6165
"config": {
6266
"allow-plugins": {
@@ -68,6 +72,7 @@
6872
"scripts": {
6973
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
7074
"check-cs": "@fix-cs --dry-run",
75+
"phpstan": "phpstan analyse -c phpstan.neon",
7176
"test": "phpunit -c phpunit.xml",
7277
"test-integration": "phpunit -c phpunit.integration.xml",
7378
"test-functional": "phpunit -c phpunit.functional.xml"

phpstan-baseline-7.4.neon

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$file of function file_put_contents expects string, string\\|false given\\.$#"
5+
count: 1
6+
path: src/lib/FieldTypeProcessor/BinaryInputProcessor.php
7+
8+
-
9+
message: "#^Parameter \\#1 \\$input of function array_slice expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
10+
count: 1
11+
path: src/lib/Server/Controller/Content.php
12+
13+
-
14+
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#"
15+
count: 1
16+
path: src/lib/Server/Controller/Content.php
17+
18+
-
19+
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\> given\\.$#"
20+
count: 1
21+
path: src/lib/Server/Controller/ContentType.php
22+
23+
-
24+
message: "#^Parameter \\#1 \\$arr1 of function array_merge expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\Policy\\> given\\.$#"
25+
count: 1
26+
path: src/lib/Server/Controller/Role.php
27+
28+
-
29+
message: "#^Parameter \\#1 \\$input of function array_slice expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\Role\\> given\\.$#"
30+
count: 1
31+
path: src/lib/Server/Controller/Role.php
32+
33+
-
34+
message: "#^Parameter \\#2 \\$error_type of function trigger_error expects int, string given\\.$#"
35+
count: 4
36+
path: src/lib/Server/Controller/User.php
37+
38+
-
39+
message: "#^Parameter \\#1 \\$message of method Psr\\\\Log\\\\LoggerInterface\\:\\:error\\(\\) expects string, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null given\\.$#"
40+
count: 1
41+
path: src/lib/Server/Security/RestAuthenticator.php
42+
43+
-
44+
message: "#^Parameter \\#1 \\$str of function base64_encode expects string, string\\|false given\\.$#"
45+
count: 1
46+
path: tests/bundle/Functional/BinaryContentTest.php
47+
48+
-
49+
message: "#^Parameter \\#1 \\$pathname of function mkdir expects string, string\\|false given\\.$#"
50+
count: 1
51+
path: tests/lib/FieldTypeProcessor/BinaryInputProcessorTest.php
52+
53+
-
54+
message: "#^Parameter \\#2 \\$newvalue of function ini_set expects string, int given\\.$#"
55+
count: 2
56+
path: tests/lib/Output/Generator/FieldTypeHashGeneratorBaseTest.php

phpstan-baseline-8.0.neon

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Parameter \\#1 \\$filename of function file_put_contents expects string, string\\|false given\\.$#"
5+
count: 1
6+
path: src/lib/FieldTypeProcessor/BinaryInputProcessor.php
7+
8+
-
9+
message: "#^Access to an undefined property DOMNode\\:\\:\\$data\\.$#"
10+
count: 2
11+
path: src/lib/Input/Handler/Xml.php
12+
13+
-
14+
message: "#^Access to an undefined property DOMNode\\:\\:\\$tagName\\.$#"
15+
count: 2
16+
path: src/lib/Input/Handler/Xml.php
17+
18+
-
19+
message: "#^Access to an undefined property DOMNode\\:\\:\\$wholeText\\.$#"
20+
count: 2
21+
path: src/lib/Input/Handler/Xml.php
22+
23+
-
24+
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
25+
count: 1
26+
path: src/lib/Input/Handler/Xml.php
27+
28+
-
29+
message: "#^Call to an undefined method DOMNode\\:\\:hasAttribute\\(\\)\\.$#"
30+
count: 1
31+
path: src/lib/Input/Handler/Xml.php
32+
33+
-
34+
message: "#^Parameter \\#1 \\$domElement of method Ibexa\\\\Rest\\\\Input\\\\Handler\\\\Xml\\:\\:parseFieldTypeHash\\(\\) expects DOMElement, DOMNode given\\.$#"
35+
count: 1
36+
path: src/lib/Input/Handler/Xml.php
37+
38+
-
39+
message: "#^Parameter \\#1 \\$array of function array_slice expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
40+
count: 1
41+
path: src/lib/Server/Controller/Content.php
42+
43+
-
44+
message: "#^Parameter \\#2 \\$string of function explode expects string, string\\|null given\\.$#"
45+
count: 1
46+
path: src/lib/Server/Controller/Content.php
47+
48+
-
49+
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\> given\\.$#"
50+
count: 1
51+
path: src/lib/Server/Controller/ContentType.php
52+
53+
-
54+
message: "#^Parameter \\#1 \\$array of function array_slice expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\Role\\> given\\.$#"
55+
count: 1
56+
path: src/lib/Server/Controller/Role.php
57+
58+
-
59+
message: "#^Parameter \\#1 \\.\\.\\.\\$arrays of function array_merge expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\Policy\\> given\\.$#"
60+
count: 1
61+
path: src/lib/Server/Controller/Role.php
62+
63+
-
64+
message: "#^Parameter \\#2 \\$error_level of function trigger_error expects int, string given\\.$#"
65+
count: 4
66+
path: src/lib/Server/Controller/User.php
67+
68+
-
69+
message: "#^Parameter \\#1 \\$message of method Psr\\\\Log\\\\LoggerInterface\\:\\:error\\(\\) expects string\\|Stringable, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null given\\.$#"
70+
count: 1
71+
path: src/lib/Server/Security/RestAuthenticator.php
72+
73+
-
74+
message: "#^Parameter \\#1 \\$string of function base64_encode expects string, string\\|false given\\.$#"
75+
count: 1
76+
path: tests/bundle/Functional/BinaryContentTest.php
77+
78+
-
79+
message: "#^Parameter \\#1 \\$directory of function mkdir expects string, string\\|false given\\.$#"
80+
count: 1
81+
path: tests/lib/FieldTypeProcessor/BinaryInputProcessorTest.php

0 commit comments

Comments
 (0)