Skip to content

Commit

Permalink
Added PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Aug 14, 2023
1 parent 215cffe commit 6b284cb
Show file tree
Hide file tree
Showing 7 changed files with 12,165 additions and 14 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,28 @@ on:
jobs:
cs-fix:
name: Run code style check
runs-on: "ubuntu-20.04"
strategy:
matrix:
php:
- '8.0'
runs-on: "ubuntu-22.04"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
php-version: '8.0'
coverage: none
extensions: 'pdo_sqlite, gd'
tools: cs2pr

- uses: "ramsey/composer-install@v1"
- uses: ramsey/composer-install@v2
with:
dependency-versions: "highest"
dependency-versions: highest

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

tests:
name: Unit tests
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
timeout-minutes: 15

strategy:
Expand All @@ -48,7 +44,7 @@ jobs:
- '8.1'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP Action
uses: shivammathur/setup-php@v2
Expand All @@ -58,15 +54,19 @@ jobs:
extensions: pdo_sqlite, gd
tools: cs2pr

- uses: "ramsey/composer-install@v1"
- uses: ramsey/composer-install@v2
with:
dependency-versions: "highest"
dependency-versions: highest

- name: Run PHPStan analysis
run: composer run-script phpstan

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run unit test suite
run: composer test

integration-tests:
name: "REST integration tests"
uses: ./.github/workflows/integration-tests-callable.yaml
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"nyholm/psr7": "^1.1",
"symfony/http-client": "^5.3",
"symfony/browser-kit": "^5.3"
"symfony/browser-kit": "^5.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-webmozart-assert": "^1.2"
},
"config": {
"allow-plugins": {
Expand All @@ -62,6 +66,7 @@
"scripts": {
"fix-cs": "php-cs-fixer fix -v --show-progress=estimating",
"check-cs": "@fix-cs --dry-run",
"phpstan": "phpstan analyse -c phpstan.neon",
"test": "phpunit -c phpunit.xml",
"integration": "phpunit -c phpunit-integration-rest.xml"
},
Expand Down
56 changes: 56 additions & 0 deletions phpstan-baseline-7.4.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$file of function file_put_contents expects string, string\\|false given\\.$#"
count: 1
path: src/lib/FieldTypeProcessor/BinaryInputProcessor.php

-
message: "#^Parameter \\#1 \\$input of function array_slice expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#"
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/ContentType.php

-
message: "#^Parameter \\#1 \\$arr1 of function array_merge expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\User\\\\Policy\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Role.php

-
message: "#^Parameter \\#1 \\$input of function array_slice expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\User\\\\Role\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Role.php

-
message: "#^Parameter \\#2 \\$error_type of function trigger_error expects int, string given\\.$#"
count: 4
path: src/lib/Server/Controller/User.php

-
message: "#^Parameter \\#1 \\$message of method Psr\\\\Log\\\\LoggerInterface\\:\\:error\\(\\) expects string, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null given\\.$#"
count: 1
path: src/lib/Server/Security/RestAuthenticator.php

-
message: "#^Parameter \\#1 \\$str of function base64_encode expects string, string\\|false given\\.$#"
count: 1
path: tests/bundle/Functional/BinaryContentTest.php

-
message: "#^Parameter \\#1 \\$pathname of function mkdir expects string, string\\|false given\\.$#"
count: 1
path: tests/lib/FieldTypeProcessor/BinaryInputProcessorTest.php

-
message: "#^Parameter \\#2 \\$newvalue of function ini_set expects string, int given\\.$#"
count: 2
path: tests/lib/Output/Generator/FieldTypeHashGeneratorBaseTest.php
81 changes: 81 additions & 0 deletions phpstan-baseline-8.0.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$filename of function file_put_contents expects string, string\\|false given\\.$#"
count: 1
path: src/lib/FieldTypeProcessor/BinaryInputProcessor.php

-
message: "#^Access to an undefined property DOMNode\\:\\:\\$data\\.$#"
count: 2
path: src/lib/Input/Handler/Xml.php

-
message: "#^Access to an undefined property DOMNode\\:\\:\\$tagName\\.$#"
count: 2
path: src/lib/Input/Handler/Xml.php

-
message: "#^Access to an undefined property DOMNode\\:\\:\\$wholeText\\.$#"
count: 2
path: src/lib/Input/Handler/Xml.php

-
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
count: 1
path: src/lib/Input/Handler/Xml.php

-
message: "#^Call to an undefined method DOMNode\\:\\:hasAttribute\\(\\)\\.$#"
count: 1
path: src/lib/Input/Handler/Xml.php

-
message: "#^Parameter \\#1 \\$domElement of method EzSystems\\\\EzPlatformRest\\\\Input\\\\Handler\\\\Xml\\:\\:parseFieldTypeHash\\(\\) expects DOMElement, DOMNode given\\.$#"
count: 1
path: src/lib/Input/Handler/Xml.php

-
message: "#^Parameter \\#1 \\$array of function array_slice expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\Content\\\\Relation\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#2 \\$string of function explode expects string, string\\|null given\\.$#"
count: 1
path: src/lib/Server/Controller/Content.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\ContentType\\\\ContentType\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/ContentType.php

-
message: "#^Parameter \\#1 \\$array of function array_slice expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\User\\\\Role\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Role.php

-
message: "#^Parameter \\#1 \\.\\.\\.\\$arrays of function array_merge expects array, iterable\\<eZ\\\\Publish\\\\API\\\\Repository\\\\Values\\\\User\\\\Policy\\> given\\.$#"
count: 1
path: src/lib/Server/Controller/Role.php

-
message: "#^Parameter \\#2 \\$error_level of function trigger_error expects int, string given\\.$#"
count: 4
path: src/lib/Server/Controller/User.php

-
message: "#^Parameter \\#1 \\$message of method Psr\\\\Log\\\\LoggerInterface\\:\\:error\\(\\) expects string\\|Stringable, Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null given\\.$#"
count: 1
path: src/lib/Server/Security/RestAuthenticator.php

-
message: "#^Parameter \\#1 \\$string of function base64_encode expects string, string\\|false given\\.$#"
count: 1
path: tests/bundle/Functional/BinaryContentTest.php

-
message: "#^Parameter \\#1 \\$directory of function mkdir expects string, string\\|false given\\.$#"
count: 1
path: tests/lib/FieldTypeProcessor/BinaryInputProcessorTest.php
Loading

0 comments on commit 6b284cb

Please sign in to comment.