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

Update PHPStan packages to v2 (major) #768

Merged
merged 3 commits into from
Feb 9, 2025
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
2 changes: 1 addition & 1 deletion src/Action/LoginAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(
}

/**
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings("PHPMD.NPathComplexity")
*/
public function __invoke(Request $request): Response
{
Expand Down
9 changes: 6 additions & 3 deletions src/Action/RequestResetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class RequestResetAction
private readonly TranslatorInterface $translator;

/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings("PHPMD.ExcessiveParameterList")
*
* @param UserProviderInterface<UserInterface> $userProvider
*/
Expand Down Expand Up @@ -114,8 +114,8 @@ public function __invoke(Request $request): Response
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
* @SuppressWarnings("PHPMD.NPathComplexity")
*/
private function process(Request $request): ?Response
{
Expand Down Expand Up @@ -190,6 +190,9 @@ private function getFlashBag(Request $request): ?FlashBagInterface
return $session->getFlashBag();
}

/**
* @return FormInterface<mixed>
*/
private function createForm(): FormInterface
{
return $this->formFactory
Expand Down
5 changes: 4 additions & 1 deletion src/Action/UpdateSecurityAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct(
}

/**
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings("PHPMD.NPathComplexity")
*/
public function __invoke(Request $request): Response
{
Expand Down Expand Up @@ -107,6 +107,9 @@ public function __invoke(Request $request): Response
]));
}

/**
* @return FormInterface<UserInterface>
*/
private function createForm(UserInterface $model): FormInterface
{
return $this->formFactory
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyInjection/NucleosUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ final class NucleosUserExtension extends Extension implements PrependExtensionIn
private bool $mailerNeeded = false;

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
* @SuppressWarnings("PHPMD.NPathComplexity")
* @SuppressWarnings("PHPMD.ExcessiveMethodLength")
*/
public function load(array $configs, ContainerBuilder $container): void
{
Expand Down Expand Up @@ -166,7 +166,7 @@ private function remapParameters(array $config, ContainerBuilder $container, arr
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
private function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces): void
{
Expand Down
12 changes: 12 additions & 0 deletions src/Event/FormEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,32 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @template T
*/
class FormEvent extends Event
{
/**
* @var FormInterface<T>
*/
private readonly FormInterface $form;

private readonly Request $request;

private ?Response $response = null;

/**
* @param FormInterface<T> $form
*/
public function __construct(FormInterface $form, Request $request)
{
$this->form = $form;
$this->request = $request;
}

/**
* @return FormInterface<T>
*/
public function getForm(): FormInterface
{
return $this->form;
Expand Down
7 changes: 3 additions & 4 deletions src/EventListener/ResettingListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ public function onResettingResetInitialize(GetResponseUserEvent $event): void
}
}

/**
* @param FormEvent<Resetting> $event
*/
public function onResettingResetSuccess(FormEvent $event): void
{
$model = $event->getForm()->getData();

if (!$model instanceof Resetting) {
return;
}

$user = $model->getUser();

$user->setConfirmationToken(null);
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/AccountDeletionFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* @extends AbstractType<AccountDeletion>
*/
final class AccountDeletionFormType extends AbstractType
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/LoginFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* @extends AbstractType<mixed>
*/
final class LoginFormType extends AbstractType
{
private readonly AuthenticationUtils $authenticationUtils;
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/RequestPasswordFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @extends AbstractType<mixed>
*/
final class RequestPasswordFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/ResettingFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @extends AbstractType<Resetting>
*/
final class ResettingFormType extends AbstractType
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/UpdateSecurityFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Validator\Constraints\NotBlank;

/**
* @extends AbstractType<UserInterface>
*/
final class UpdateSecurityFormType extends AbstractType
{
/**
Expand Down
6 changes: 3 additions & 3 deletions src/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings("PHPMD.TooManyPublicMethods")
*
* @phpstan-template GroupTemplate of GroupInterface
*
* @phpstan-implements GroupAwareUser<GroupTemplate>
*
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings("PHPMD.TooManyPublicMethods")
*/
abstract class User implements UserInterface, GroupAwareUser, LocaleAwareUser
{
Expand Down Expand Up @@ -300,7 +300,7 @@ public function getTimezone(): ?string
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
public function isEqualTo(BaseUserInterface $user): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Constraints/Pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class Pattern extends Constraint
public string $specialChars = '.,:;!?:+-*#\/|(){}[]';

/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings("PHPMD.ExcessiveParameterList")
*/
public function __construct(
mixed $options = null,
Expand Down
6 changes: 3 additions & 3 deletions tests/App/Entity/TestUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Nucleos\UserBundle\Model\GroupInterface;
use Nucleos\UserBundle\Model\User;

/**
* @phpstan-extends User<GroupInterface>
* @phpstan-extends User<TestGroup>
*/
#[ORM\Entity]
#[ORM\Table(name: 'user__user')]
Expand All @@ -31,11 +30,12 @@ class TestUser extends User
protected int $id;

/**
* @var Collection<array-key, GroupInterface>
* @var Collection<array-key, TestGroup>
*/
#[ORM\ManyToMany(targetEntity: TestGroup::class)]
#[ORM\JoinTable(name: 'user__user_group')]
protected Collection $groups;

private static int $index = 1;

public function __construct()
Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/NucleosUserExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Symfony\Component\Yaml\Parser;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings("PHPMD.TooManyPublicMethods")
*/
final class NucleosUserExtensionTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/SimpleUserManipulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings("PHPMD.TooManyPublicMethods")
*/
final class SimpleUserManipulatorTest extends TestCase
{
Expand Down
10 changes: 5 additions & 5 deletions vendor-bin/tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"matthiasnoback/symfony-dependency-injection-test": "^6.0",
"phpmd/phpmd": "^2.13",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10.14",
"phpstan/phpstan-doctrine": "^1.3.37",
"phpstan/phpstan-phpunit": "^1.3.11",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpstan/phpstan-symfony": "^1.3.1",
"phpstan/phpstan": "^2.0.0",
"phpstan/phpstan-doctrine": "^2.0.0",
"phpstan/phpstan-phpunit": "^2.0.0",
"phpstan/phpstan-strict-rules": "^2.0.0",
"phpstan/phpstan-symfony": "^2.0.0",
"phpunit/phpunit": "^10.1.2",
"symfony/phpunit-bridge": "^7.0"
},
Expand Down
Loading