Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPStan on level 5 #8

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
run: |
docker run --rm php-ci vendor/bin/ecs --config=development/tooling/ecs.php

- name: Run PHPStan
run: |
docker run --rm php-ci vendor/bin/phpstan --configuration=./development/tooling/phpstan.neon

- name: Run unit tests
run: |
docker run --rm php-ci vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox tests
4 changes: 4 additions & 0 deletions Taskfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function task:codestyle { ## Run codestyle test
dockercompose-exec vendor/bin/ecs --config=development/tooling/ecs.php
}

function task:phpstan { ## Run PHPStan
dockercompose-exec vendor/bin/phpstan --configuration=./development/tooling/phpstan.neon
}

function task:tests { ## Run unit tests
dockercompose-exec vendor/bin/phpunit -c development/tooling/phpunit.xml --testdox tests
}
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
},
"require-dev": {
"symplify/easy-coding-standard": "^12.5",
"phpunit/phpunit": "^11"
"phpunit/phpunit": "^11",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpstan/phpstan-doctrine": "^2.0"
},
"license": "MIT",
"autoload": {
Expand Down
20 changes: 20 additions & 0 deletions development/tooling/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
parameters:
level: 5
paths:
- ../../src
- ../../tests
ignoreErrors:
### Ignore all Symfony/Doctrine errors
- '#Symfony\\.*#'
- '#Doctrine\\.*#'
### Ignore warning about unused traits
- '#Trait .* is used zero times and is not analysed\.#'
### Exclude some paths with Symfony specific things
excludePaths:
- ../../src/EventListener/DoctrineMetadataListener.php
- ../../src/Form
- ../../src/Repository
includes:
- ../../vendor/phpstan/phpstan-symfony/extension.neon
- ../../vendor/phpstan/phpstan-symfony/rules.neon
- ../../vendor/phpstan/phpstan-doctrine/extension.neon
2 changes: 1 addition & 1 deletion src/Repository/UserAgreementRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use UserAgreements\Entity\UserAgreement;
use RobertvanLienden\UserAgreements\Entity\UserAgreement;

/**
* @extends ServiceEntityRepository<UserAgreement>
Expand Down
1 change: 0 additions & 1 deletion tests/unit/AgreementServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function testGetAgreements(): void
{
$agreements = $this->agreementService->getAgreements();

$this->assertIsArray($agreements);
$this->assertCount(2, $agreements);
$this->assertArrayHasKey('label', $agreements[0]);
$this->assertArrayHasKey('content', $agreements[0]);
Expand Down
Loading