mirror of
https://github.com/symfony/demo.git
synced 2026-03-24 00:02:32 +01:00
Upgrade to PHPStan 2
This commit is contained in:
28
.github/workflows/lint.yaml
vendored
28
.github/workflows/lint.yaml
vendored
@@ -56,11 +56,8 @@ jobs:
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: "Install dependencies"
|
||||
run: composer install --ansi --no-interaction --no-progress
|
||||
|
||||
- name: Install PHPUnit
|
||||
id: install
|
||||
run: vendor/bin/simple-phpunit install
|
||||
run: composer install --ansi --no-interaction --no-progress
|
||||
|
||||
- name: Lint YAML files
|
||||
if: always() && steps.install.outcome == 'success'
|
||||
@@ -94,6 +91,25 @@ jobs:
|
||||
if: always() && steps.install.outcome == 'success'
|
||||
run: composer audit
|
||||
|
||||
static-analysis:
|
||||
name: PHPStan
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: none
|
||||
php-version: '8.3'
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --ansi --no-interaction --no-progress
|
||||
|
||||
- name: Install PHPUnit
|
||||
run: vendor/bin/simple-phpunit install
|
||||
|
||||
- name: Run PHPStan
|
||||
if: always() && steps.install.outcome == 'success'
|
||||
run: ./vendor/bin/phpstan analyze
|
||||
run: vendor/bin/phpstan analyze --no-progress
|
||||
|
||||
@@ -54,10 +54,9 @@
|
||||
"require-dev": {
|
||||
"dama/doctrine-test-bundle": "^8.0.2",
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.5",
|
||||
"phpstan/extension-installer": "^1.2",
|
||||
"phpstan/phpstan": "^1.2",
|
||||
"phpstan/phpstan-doctrine": "^1.3",
|
||||
"phpstan/phpstan-symfony": "^1.2",
|
||||
"phpstan/phpstan": "^2.0",
|
||||
"phpstan/phpstan-doctrine": "^2.0",
|
||||
"phpstan/phpstan-symfony": "^2.0",
|
||||
"symfony/browser-kit": "^7",
|
||||
"symfony/css-selector": "^7",
|
||||
"symfony/debug-bundle": "^7",
|
||||
@@ -70,8 +69,7 @@
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"symfony/flex": true,
|
||||
"symfony/runtime": true,
|
||||
"phpstan/extension-installer": true
|
||||
"symfony/runtime": true
|
||||
},
|
||||
"platform": {
|
||||
"php": "8.2.0"
|
||||
|
||||
@@ -1,71 +1,7 @@
|
||||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Comment\\:\\:\\$author type mapping mismatch\\: property can contain App\\\\Entity\\\\User\\|null but database expects App\\\\Entity\\\\User\\.$#"
|
||||
message: '#^Call to function method_exists\(\) with ''Symfony\\\\Component\\\\Dotenv\\\\Dotenv'' and ''bootEnv'' will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 1
|
||||
path: src/Entity/Comment.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Comment\\:\\:\\$content type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Comment.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Comment\\:\\:\\$post type mapping mismatch\\: property can contain App\\\\Entity\\\\Post\\|null but database expects App\\\\Entity\\\\Post\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Comment.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Post\\:\\:\\$author type mapping mismatch\\: property can contain App\\\\Entity\\\\User\\|null but database expects App\\\\Entity\\\\User\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Post.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Post\\:\\:\\$content type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Post.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Post\\:\\:\\$slug type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Post.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Post\\:\\:\\$summary type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Post.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\Post\\:\\:\\$title type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/Post.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\User\\:\\:\\$email type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/User.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\User\\:\\:\\$fullName type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/User.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\User\\:\\:\\$password type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/User.php
|
||||
|
||||
-
|
||||
message: "#^Property App\\\\Entity\\\\User\\:\\:\\$username type mapping mismatch\\: property can contain string\\|null but database expects string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/User.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Entity\\\\User::getUserIdentifier\\(\\) should return non-empty-string but returns string\\.$#"
|
||||
count: 1
|
||||
path: src/Entity/User.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$function of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/Twig/SourceCodeExtension.php
|
||||
path: tests/bootstrap.php
|
||||
|
||||
@@ -1,8 +1,26 @@
|
||||
includes:
|
||||
- phpstan-baseline.neon
|
||||
- vendor/phpstan/phpstan-doctrine/extension.neon
|
||||
- vendor/phpstan/phpstan-symfony/extension.neon
|
||||
- vendor/phpstan/phpstan-symfony/rules.neon
|
||||
|
||||
parameters:
|
||||
bootstrapFiles:
|
||||
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
|
||||
|
||||
doctrine:
|
||||
objectManagerLoader: tests/object-manager.php
|
||||
|
||||
ignoreErrors:
|
||||
- identifier: missingType.generics
|
||||
|
||||
level: 6
|
||||
paths:
|
||||
- bin/
|
||||
- config/
|
||||
- public/
|
||||
- src/
|
||||
- tests/
|
||||
- bin
|
||||
- config
|
||||
- public
|
||||
- src
|
||||
- tests
|
||||
|
||||
symfony:
|
||||
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
includes:
|
||||
- phpstan-baseline.neon
|
||||
|
||||
parameters:
|
||||
level: max
|
||||
paths:
|
||||
- src
|
||||
- tests
|
||||
bootstrapFiles:
|
||||
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
|
||||
doctrine:
|
||||
objectManagerLoader: tests/object-manager.php
|
||||
symfony:
|
||||
containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
|
||||
@@ -49,7 +49,7 @@ final class DateTimePickerType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): ?string
|
||||
public function getParent(): string
|
||||
{
|
||||
return DateTimeType::class;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ final class TagsInputType extends AbstractType
|
||||
$view->vars['tags'] = $this->tags->findAll();
|
||||
}
|
||||
|
||||
public function getParent(): ?string
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ class BlogControllerTest extends WebTestCase
|
||||
/** @var PostRepository $postRepository */
|
||||
$postRepository = static::getContainer()->get(PostRepository::class);
|
||||
|
||||
/** @var \App\Entity\Post $post */
|
||||
$post = $postRepository->findOneByTitle($postTitle);
|
||||
|
||||
$this->assertNotNull($post);
|
||||
|
||||
@@ -75,7 +75,6 @@ final class UserControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseRedirects('/en/profile/edit', Response::HTTP_SEE_OTHER);
|
||||
|
||||
/** @var User $user */
|
||||
$user = $userRepository->findOneByEmail($newUserEmail);
|
||||
|
||||
$this->assertNotNull($user);
|
||||
|
||||
Reference in New Issue
Block a user