mirror of
https://github.com/symfony/maker-bundle.git
synced 2026-03-23 23:42:10 +01:00
Upgrade to PHPStan v2
This commit is contained in:
40
CONTRIBUTING.md
Normal file
40
CONTRIBUTING.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Contributing
|
||||
|
||||
This project is part of the Symfony ecosystem and follows the
|
||||
[Symfony Contribution Guidelines](https://symfony.com/doc/current/contributing/index.html).
|
||||
|
||||
## Running Tests
|
||||
|
||||
This project uses [PHPUnit Bridge](https://phpunit.de/getting-started/phpunit-bridge.html) to run the tests.
|
||||
|
||||
Install the required dependencies with:
|
||||
|
||||
```bash
|
||||
composer install
|
||||
```
|
||||
|
||||
To run the tests, use the following command:
|
||||
|
||||
```bash
|
||||
./vendor/bin/simple-phpunit
|
||||
```
|
||||
|
||||
## Static Analysis
|
||||
|
||||
This project uses [PHPStan](https://phpstan.org/) for static analysis.
|
||||
To run PHPStan, use the following command:
|
||||
|
||||
Install the required dependencies for the project, PHPStan itself and the extra
|
||||
packages that the project uses:
|
||||
|
||||
```bash
|
||||
composer update
|
||||
composer update --working-dir=tools/phpstan
|
||||
composer update --working-dir=tools/phpstan/includes
|
||||
```
|
||||
|
||||
Run PHPStan with:
|
||||
|
||||
```bash
|
||||
tools/phpstan/vendor/bin/phpstan
|
||||
```
|
||||
@@ -139,6 +139,7 @@ class MakeResetPassword extends AbstractMaker
|
||||
|
||||
// reset-password-bundle 1.6 includes the ability to generate a fake token.
|
||||
// we need to check that version 1.6 is installed
|
||||
// @phpstan-ignore function.alreadyNarrowedType
|
||||
if (class_exists(ResetPasswordHelper::class) && !method_exists(ResetPasswordHelper::class, 'generateFakeResetToken')) {
|
||||
throw new RuntimeCommandException('Please run "composer upgrade symfonycasts/reset-password-bundle". Version 1.6 or greater of this bundle is required.');
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\UX\StimulusBundle\StimulusBundle;
|
||||
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
|
||||
|
||||
/**
|
||||
* @author Abdelilah Jabri <jbrabdelilah@gmail.com>
|
||||
@@ -339,17 +338,7 @@ final class MakeStimulusController extends AbstractMaker
|
||||
|
||||
public function configureDependencies(DependencyBuilder $dependencies): void
|
||||
{
|
||||
// lower than 8.1, allow WebpackEncoreBundle
|
||||
if (\PHP_VERSION_ID < 80100) {
|
||||
$dependencies->addClassDependency(
|
||||
WebpackEncoreBundle::class,
|
||||
'symfony/webpack-encore-bundle'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// else: encourage StimulusBundle by requiring it
|
||||
// Encourage StimulusBundle by requiring it
|
||||
$dependencies->addClassDependency(
|
||||
StimulusBundle::class,
|
||||
'symfony/stimulus-bundle'
|
||||
|
||||
@@ -221,7 +221,7 @@ final class MakeUser extends AbstractMaker
|
||||
} else {
|
||||
$nextSteps[] = \sprintf(
|
||||
'Open <info>%s</info> to finish implementing your user provider.',
|
||||
/* @phpstan-ignore-next-line - $customProviderPath is defined in this else statement */
|
||||
// @phpstan-ignore variable.undefined ($customProviderPath is defined in this else statement)
|
||||
$this->fileManager->relativizePath($customProviderPath)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ class MakerCommandTest extends TestCase
|
||||
public function testExceptionOnMissingDependencies(): void
|
||||
{
|
||||
$this->expectException(RuntimeCommandException::class);
|
||||
// @phpstan-ignore function.alreadyNarrowedType
|
||||
if (method_exists($this, 'expectExceptionMessageMatches')) {
|
||||
$this->expectExceptionMessageMatches('/composer require foo-package/');
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ class MakeControllerTest extends MakerTestCase
|
||||
|
||||
// Ensure the generated controller matches what we expect
|
||||
self::assertSame(
|
||||
expected: file_get_contents(\dirname(__DIR__).'/fixtures/make-controller/expected/FinalController.php'),
|
||||
actual: file_get_contents($runner->getPath('src/Controller/FooBarController.php'))
|
||||
file_get_contents(\dirname(__DIR__).'/fixtures/make-controller/expected/FinalController.php'),
|
||||
file_get_contents($runner->getPath('src/Controller/FooBarController.php'))
|
||||
);
|
||||
}),
|
||||
];
|
||||
@@ -92,8 +92,8 @@ class MakeControllerTest extends MakerTestCase
|
||||
|
||||
// Ensure the generated controller matches what we expect
|
||||
self::assertSame(
|
||||
expected: file_get_contents(\dirname(__DIR__).'/fixtures/make-controller/expected/FinalControllerWithTemplate.php'),
|
||||
actual: file_get_contents($runner->getPath('src/Controller/FooTwigController.php'))
|
||||
file_get_contents(\dirname(__DIR__).'/fixtures/make-controller/expected/FinalControllerWithTemplate.php'),
|
||||
file_get_contents($runner->getPath('src/Controller/FooTwigController.php'))
|
||||
);
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -39,8 +39,8 @@ class MakeSerializerEncoderTest extends MakerTestCase
|
||||
);
|
||||
|
||||
self::assertStringContainsString(
|
||||
needle: 'public function decode(string $data, string $format, array $context = []): mixed',
|
||||
haystack: file_get_contents($runner->getPath('src/Serializer/FooBarEncoder.php'))
|
||||
'public function decode(string $data, string $format, array $context = []): mixed',
|
||||
file_get_contents($runner->getPath('src/Serializer/FooBarEncoder.php'))
|
||||
);
|
||||
}),
|
||||
];
|
||||
@@ -61,8 +61,8 @@ class MakeSerializerEncoderTest extends MakerTestCase
|
||||
);
|
||||
|
||||
self::assertStringNotContainsString(
|
||||
needle: 'public function decode(string $data, string $format, array $context = []): mixed',
|
||||
haystack: file_get_contents($runner->getPath('src/Serializer/FooBarEncoder.php'))
|
||||
'public function decode(string $data, string $format, array $context = []): mixed',
|
||||
file_get_contents($runner->getPath('src/Serializer/FooBarEncoder.php'))
|
||||
);
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"require": {
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpstan/extension-installer": "^1.3",
|
||||
"phpstan/phpstan-symfony": "^1.3",
|
||||
"phpstan/phpstan-doctrine": "^1.3",
|
||||
"phpstan/phpstan-phpunit": "^1.3"
|
||||
"phpstan/phpstan": "^2.1",
|
||||
"phpstan/extension-installer": "^1.4",
|
||||
"phpstan/phpstan-symfony": "^2",
|
||||
"phpstan/phpstan-doctrine": "^2",
|
||||
"phpstan/phpstan-phpunit": "^2"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
"symfony/validator": "^7.0",
|
||||
"symfonycasts/reset-password-bundle": "^1.21",
|
||||
"symfonycasts/verify-email-bundle": "^1.17",
|
||||
"symfony/webpack-encore-bundle": "^2.1",
|
||||
"symfony/panther": "^2.1",
|
||||
"symfony/webhook": "^7.0",
|
||||
"symfony/expression-language": "^7.0"
|
||||
|
||||
Reference in New Issue
Block a user