From ff0c656f40e53e0fc2f0078a21e5d7054fc9a9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Thu, 25 Apr 2024 16:04:28 +0200 Subject: [PATCH] IBX-8121: Fixed code style for 5.0 --- composer.json | 5 ++--- src/bundle/IbexaUserBundle.php | 1 + src/contracts/Notification/UserPasswordReset.php | 4 +--- src/contracts/Notification/UserRegister.php | 4 +--- src/lib/Behat/Context/UserSettingsContext.php | 1 + src/lib/Form/Data/UserInvitationData.php | 1 + src/lib/Form/Data/UserPasswordChangeData.php | 1 + src/lib/Form/DataMapper/UserRegisterMapper.php | 1 + .../Form/Processor/UserRegisterFormProcessor.php | 1 + src/lib/Form/Type/Invitation/InvitationType.php | 1 + .../Form/Type/Invitation/UserInvitationType.php | 1 + src/lib/Form/Type/UserRegisterType.php | 1 + .../UserPermissionsLimitationHandler.php | 1 + .../Permission/UserPermissionsLimitationType.php | 1 + src/lib/View/Register/ConfirmView.php | 1 + src/lib/View/Register/FormView.php | 1 + tests/integration/SampleTest.php | 1 + .../Loader/AvailableLocaleChoiceLoaderTest.php | 2 +- tests/lib/Invitation/InvitationServiceTest.php | 2 +- .../UserPermissionsLimitationTypeTest.php | 4 ++-- tests/lib/UserSetting/UserSettingServiceTest.php | 4 ++-- .../UserSetting/ValueDefinitionRegistryTest.php | 14 +++++++------- tests/lib/Validator/Constraint/PasswordTest.php | 6 +++--- .../Constraint/PasswordValidatorTest.php | 16 ++++++++-------- .../Constraint/UserPasswordValidatorTest.php | 14 +++++++------- 25 files changed, 49 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index c87aed5..6b08253 100644 --- a/composer.json +++ b/composer.json @@ -47,9 +47,8 @@ "twig/twig": "^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", "ibexa/ci-scripts": "^0.2@dev", - "ibexa/code-style": "^1.0", + "ibexa/code-style": "~2.0.0", "ibexa/design-engine": "~5.0.x-dev", "ibexa/doctrine-schema": "~5.0.x-dev", "ibexa/fieldtype-richtext": "~5.0.x-dev", @@ -60,7 +59,7 @@ "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-symfony": "^1.3", - "phpunit/phpunit": "^8.2", + "phpunit/phpunit": "^9.6", "symfony/phpunit-bridge": "^5.3", "symfony/proxy-manager-bridge": "^5.0" }, diff --git a/src/bundle/IbexaUserBundle.php b/src/bundle/IbexaUserBundle.php index f217143..5a0c137 100644 --- a/src/bundle/IbexaUserBundle.php +++ b/src/bundle/IbexaUserBundle.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\Bundle\User; use Ibexa\Bundle\User\DependencyInjection\Compiler\SecurityPass; diff --git a/src/contracts/Notification/UserPasswordReset.php b/src/contracts/Notification/UserPasswordReset.php index 52fd09f..a4c50e4 100644 --- a/src/contracts/Notification/UserPasswordReset.php +++ b/src/contracts/Notification/UserPasswordReset.php @@ -17,9 +17,7 @@ use Symfony\Component\Notifier\Recipient\EmailRecipientInterface; use Symfony\Component\Notifier\Recipient\SmsRecipientInterface; -final class UserPasswordReset -extends Notification -implements EmailNotificationInterface, SmsNotificationInterface, UserAwareNotificationInterface +final class UserPasswordReset extends Notification implements EmailNotificationInterface, SmsNotificationInterface, UserAwareNotificationInterface { private User $user; diff --git a/src/contracts/Notification/UserRegister.php b/src/contracts/Notification/UserRegister.php index 3132c15..2f07fb5 100644 --- a/src/contracts/Notification/UserRegister.php +++ b/src/contracts/Notification/UserRegister.php @@ -17,9 +17,7 @@ use Symfony\Component\Notifier\Recipient\EmailRecipientInterface; use Symfony\Component\Notifier\Recipient\SmsRecipientInterface; -final class UserRegister -extends Notification -implements EmailNotificationInterface, SmsNotificationInterface, UserAwareNotificationInterface +final class UserRegister extends Notification implements EmailNotificationInterface, SmsNotificationInterface, UserAwareNotificationInterface { private User $user; diff --git a/src/lib/Behat/Context/UserSettingsContext.php b/src/lib/Behat/Context/UserSettingsContext.php index 39fabf6..bca9c28 100644 --- a/src/lib/Behat/Context/UserSettingsContext.php +++ b/src/lib/Behat/Context/UserSettingsContext.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Behat\Context; use Behat\Behat\Context\Context; diff --git a/src/lib/Form/Data/UserInvitationData.php b/src/lib/Form/Data/UserInvitationData.php index 403b7e6..8f52141 100644 --- a/src/lib/Form/Data/UserInvitationData.php +++ b/src/lib/Form/Data/UserInvitationData.php @@ -18,6 +18,7 @@ final class UserInvitationData { /** * @Assert\NotBlank() + * * @Assert\Email() */ private string $email; diff --git a/src/lib/Form/Data/UserPasswordChangeData.php b/src/lib/Form/Data/UserPasswordChangeData.php index 546965b..53ab2e7 100644 --- a/src/lib/Form/Data/UserPasswordChangeData.php +++ b/src/lib/Form/Data/UserPasswordChangeData.php @@ -15,6 +15,7 @@ class UserPasswordChangeData { /** * @UserAssert\UserPassword() + * * @Assert\NotBlank() * * @var string diff --git a/src/lib/Form/DataMapper/UserRegisterMapper.php b/src/lib/Form/DataMapper/UserRegisterMapper.php index fc49ea8..830bb48 100644 --- a/src/lib/Form/DataMapper/UserRegisterMapper.php +++ b/src/lib/Form/DataMapper/UserRegisterMapper.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Form\DataMapper; use Ibexa\Contracts\ContentForms\Data\Content\FieldData; diff --git a/src/lib/Form/Processor/UserRegisterFormProcessor.php b/src/lib/Form/Processor/UserRegisterFormProcessor.php index 53bf033..5db18b4 100644 --- a/src/lib/Form/Processor/UserRegisterFormProcessor.php +++ b/src/lib/Form/Processor/UserRegisterFormProcessor.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Form\Processor; use Ibexa\ContentForms\Event\FormActionEvent; diff --git a/src/lib/Form/Type/Invitation/InvitationType.php b/src/lib/Form/Type/Invitation/InvitationType.php index 27b0327..f73f75c 100644 --- a/src/lib/Form/Type/Invitation/InvitationType.php +++ b/src/lib/Form/Type/Invitation/InvitationType.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Form\Type\Invitation; use Ibexa\Contracts\User\Invitation\InvitationService; diff --git a/src/lib/Form/Type/Invitation/UserInvitationType.php b/src/lib/Form/Type/Invitation/UserInvitationType.php index 48c87d0..797d18c 100644 --- a/src/lib/Form/Type/Invitation/UserInvitationType.php +++ b/src/lib/Form/Type/Invitation/UserInvitationType.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Form\Type\Invitation; use Ibexa\User\Form\Data\UserInvitationData; diff --git a/src/lib/Form/Type/UserRegisterType.php b/src/lib/Form/Type/UserRegisterType.php index 101bf8b..eba8a76 100644 --- a/src/lib/Form/Type/UserRegisterType.php +++ b/src/lib/Form/Type/UserRegisterType.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Form\Type; use Ibexa\ContentForms\Form\EventSubscriber\UserFieldsSubscriber; diff --git a/src/lib/Permission/UserPermissionsLimitationHandler.php b/src/lib/Permission/UserPermissionsLimitationHandler.php index 00d2665..4445710 100644 --- a/src/lib/Permission/UserPermissionsLimitationHandler.php +++ b/src/lib/Permission/UserPermissionsLimitationHandler.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Permission; use Ibexa\Contracts\Core\Persistence\User\Policy; diff --git a/src/lib/Permission/UserPermissionsLimitationType.php b/src/lib/Permission/UserPermissionsLimitationType.php index 45f07b4..e9f9519 100644 --- a/src/lib/Permission/UserPermissionsLimitationType.php +++ b/src/lib/Permission/UserPermissionsLimitationType.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\Permission; use Ibexa\Contracts\Core\Exception\InvalidArgumentType; diff --git a/src/lib/View/Register/ConfirmView.php b/src/lib/View/Register/ConfirmView.php index a4bbda3..1e30452 100644 --- a/src/lib/View/Register/ConfirmView.php +++ b/src/lib/View/Register/ConfirmView.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\View\Register; use Ibexa\Core\MVC\Symfony\View\BaseView; diff --git a/src/lib/View/Register/FormView.php b/src/lib/View/Register/FormView.php index b706c02..e5b7e42 100644 --- a/src/lib/View/Register/FormView.php +++ b/src/lib/View/Register/FormView.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ + namespace Ibexa\User\View\Register; use Ibexa\Core\MVC\Symfony\View\BaseView; diff --git a/tests/integration/SampleTest.php b/tests/integration/SampleTest.php index d29c4c5..6f1bfb6 100644 --- a/tests/integration/SampleTest.php +++ b/tests/integration/SampleTest.php @@ -10,6 +10,7 @@ /** * @group integration + * * @coversNothing */ final class SampleTest extends IbexaKernelTestCase diff --git a/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php b/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php index d8fe746..c028a67 100644 --- a/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php +++ b/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php @@ -64,7 +64,7 @@ public function testGetChoiceList( $availableTranslations ); - $this->assertSame($expectedLocales, $availableLocaleChoiceLoader->getChoiceList()); + self::assertSame($expectedLocales, $availableLocaleChoiceLoader->getChoiceList()); } public function providerForGetChoiceList(): array diff --git a/tests/lib/Invitation/InvitationServiceTest.php b/tests/lib/Invitation/InvitationServiceTest.php index a1618d9..8850804 100644 --- a/tests/lib/Invitation/InvitationServiceTest.php +++ b/tests/lib/Invitation/InvitationServiceTest.php @@ -63,7 +63,7 @@ public function testIsValid( $invitation->getSiteAccessIdentifier() )->willReturn('P2D'); - $this->assertSame( + self::assertSame( $isValid, $this->invitationService->isValid($invitation) ); diff --git a/tests/lib/Permission/UserPermissionsLimitationTypeTest.php b/tests/lib/Permission/UserPermissionsLimitationTypeTest.php index dab45e3..9128024 100644 --- a/tests/lib/Permission/UserPermissionsLimitationTypeTest.php +++ b/tests/lib/Permission/UserPermissionsLimitationTypeTest.php @@ -151,7 +151,7 @@ public function testValidateError(UserPermissionsLimitation $limitation, int $er ->method('loadRole') ->withConsecutive([4, Role::STATUS_DEFINED], [8, Role::STATUS_DEFINED]) ->willReturnOnConsecutiveCalls( - $this->throwException(new NotFoundException('Role', 4)), + self::throwException(new NotFoundException('Role', 4)), new Role() ); @@ -165,7 +165,7 @@ public function testValidateError(UserPermissionsLimitation $limitation, int $er ->method('loadContentInfo') ->withConsecutive([14], [18]) ->willReturnOnConsecutiveCalls( - $this->throwException(new NotFoundException('Role', 4)), + self::throwException(new NotFoundException('Role', 4)), new ContentInfo() ); diff --git a/tests/lib/UserSetting/UserSettingServiceTest.php b/tests/lib/UserSetting/UserSettingServiceTest.php index 134e1d3..b4b7bca 100644 --- a/tests/lib/UserSetting/UserSettingServiceTest.php +++ b/tests/lib/UserSetting/UserSettingServiceTest.php @@ -25,7 +25,7 @@ public function testCountUserSettings(): void $valueRegistry->method('countValueDefinitions')->willReturn(2); $userSettingService = new UserSettingService($userPreferenceService, $valueRegistry); - $this->assertEquals(2, $userSettingService->countUserSettings()); + self::assertEquals(2, $userSettingService->countUserSettings()); } public function testLoadUserSettings(): void @@ -65,7 +65,7 @@ public function testLoadUserSettings(): void 'value' => '3', ]), ]; - $this->assertEquals($expected, $settings); + self::assertEquals($expected, $settings); } /** diff --git a/tests/lib/UserSetting/ValueDefinitionRegistryTest.php b/tests/lib/UserSetting/ValueDefinitionRegistryTest.php index 9681432..1bf3bb9 100644 --- a/tests/lib/UserSetting/ValueDefinitionRegistryTest.php +++ b/tests/lib/UserSetting/ValueDefinitionRegistryTest.php @@ -24,7 +24,7 @@ public function testGetValueDefinitions() $registry = new ValueDefinitionRegistry($definitions); - $this->assertEquals($definitions, $registry->getValueDefinitions()); + self::assertEquals($definitions, $registry->getValueDefinitions()); } public function testAddValueDefinition() @@ -34,7 +34,7 @@ public function testAddValueDefinition() $registry = new ValueDefinitionRegistry([]); $registry->addValueDefinition('foo', $foo); - $this->assertEquals(['foo' => $foo], $registry->getValueDefinitions()); + self::assertEquals(['foo' => $foo], $registry->getValueDefinitions()); } public function testHasValueDefinition() @@ -43,8 +43,8 @@ public function testHasValueDefinition() 'foo' => $this->createMock(ValueDefinitionInterface::class), ]); - $this->assertTrue($registry->hasValueDefinition('foo')); - $this->assertFalse($registry->hasValueDefinition('bar')); + self::assertTrue($registry->hasValueDefinition('foo')); + self::assertFalse($registry->hasValueDefinition('bar')); } public function testGetValueDefinition() @@ -55,7 +55,7 @@ public function testGetValueDefinition() 'foo' => $foo, ]); - $this->assertEquals($foo, $registry->getValueDefinition('foo')); + self::assertEquals($foo, $registry->getValueDefinition('foo')); } public function testCountValueDefinitions() @@ -67,14 +67,14 @@ public function testCountValueDefinitions() $registry = new ValueDefinitionRegistry($definitions); - $this->assertEquals(2, $registry->countValueDefinitions()); + self::assertEquals(2, $registry->countValueDefinitions()); } public function testCountValueDefinitionsWithEmptyRegistry() { $registry = new ValueDefinitionRegistry([]); - $this->assertEquals(0, $registry->countValueDefinitions()); + self::assertEquals(0, $registry->countValueDefinitions()); } } diff --git a/tests/lib/Validator/Constraint/PasswordTest.php b/tests/lib/Validator/Constraint/PasswordTest.php index 28bc666..787d400 100644 --- a/tests/lib/Validator/Constraint/PasswordTest.php +++ b/tests/lib/Validator/Constraint/PasswordTest.php @@ -24,17 +24,17 @@ protected function setUp(): void public function testConstruct(): void { - $this->assertSame('ez.user.password.invalid', $this->constraint->message); + self::assertSame('ez.user.password.invalid', $this->constraint->message); } public function testValidatedBy(): void { - $this->assertSame(PasswordValidator::class, $this->constraint->validatedBy()); + self::assertSame(PasswordValidator::class, $this->constraint->validatedBy()); } public function testGetTargets(): void { - $this->assertSame([Password::CLASS_CONSTRAINT, Password::PROPERTY_CONSTRAINT], $this->constraint->getTargets()); + self::assertSame([Password::CLASS_CONSTRAINT, Password::PROPERTY_CONSTRAINT], $this->constraint->getTargets()); } } diff --git a/tests/lib/Validator/Constraint/PasswordValidatorTest.php b/tests/lib/Validator/Constraint/PasswordValidatorTest.php index 553c55b..0970bb1 100644 --- a/tests/lib/Validator/Constraint/PasswordValidatorTest.php +++ b/tests/lib/Validator/Constraint/PasswordValidatorTest.php @@ -44,11 +44,11 @@ protected function setUp(): void public function testValidateShouldBeSkipped($value): void { $this->userService - ->expects($this->never()) + ->expects(self::never()) ->method('validatePassword'); $this->executionContext - ->expects($this->never()) + ->expects(self::never()) ->method('buildViolation'); $this->validator->validate($value, new Password()); @@ -79,7 +79,7 @@ static function (string $actualPassword, PasswordValidationContext $actualContex ); $this->executionContext - ->expects($this->never()) + ->expects(self::never()) ->method('buildViolation'); $this->validator->validate( @@ -99,7 +99,7 @@ public function testInvalid(): void $errorMessage = 'error'; $this->userService - ->expects($this->once()) + ->expects(self::once()) ->method('validatePassword') ->willReturnCallback(function (string $actualPassword, PasswordValidationContext $actualContext) use ( $password, @@ -119,21 +119,21 @@ public function testInvalid(): void $constraintViolationBuilder = $this->createMock(ConstraintViolationBuilderInterface::class); $this->executionContext - ->expects($this->once()) + ->expects(self::once()) ->method('buildViolation') ->willReturn($constraintViolationBuilder); $this->executionContext - ->expects($this->once()) + ->expects(self::once()) ->method('buildViolation') ->with($errorMessage) ->willReturn($constraintViolationBuilder); $constraintViolationBuilder - ->expects($this->once()) + ->expects(self::once()) ->method('setParameters') ->with(['%foo%' => $errorParameter]) ->willReturn($constraintViolationBuilder); $constraintViolationBuilder - ->expects($this->once()) + ->expects(self::once()) ->method('addViolation'); $this->validator->validate('pass', new Password([ diff --git a/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php b/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php index 131da71..3c2a217 100644 --- a/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php +++ b/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php @@ -58,13 +58,13 @@ protected function setUp(): void public function testEmptyValueType($value) { $this->userService - ->expects($this->never()) + ->expects(self::never()) ->method('checkUserCredentials'); $this->tokenStorage - ->expects($this->never()) + ->expects(self::never()) ->method('getToken'); $this->executionContext - ->expects($this->never()) + ->expects(self::never()) ->method('buildViolation'); $this->validator->validate($value, new UserPassword()); @@ -81,7 +81,7 @@ public function emptyDataProvider(): array public function testValid() { $apiUser = $this->getMockForAbstractClass(APIUser::class, [], '', true, true, true, ['__get']); - $apiUser->method('__get')->with($this->equalTo('login'))->willReturn('login'); + $apiUser->method('__get')->with(self::equalTo('login'))->willReturn('login'); $user = $this->createMock(ReferenceUserInterface::class); $user->method('getAPIUser')->willReturn($apiUser); $token = $this->createMock(TokenInterface::class); @@ -92,7 +92,7 @@ public function testValid() ->with($apiUser, 'password') ->willReturn(true); $this->executionContext - ->expects($this->never()) + ->expects(self::never()) ->method('buildViolation'); $this->validator->validate('password', new UserPassword()); @@ -101,7 +101,7 @@ public function testValid() public function testInvalid() { $apiUser = $this->getMockForAbstractClass(APIUser::class, [], '', true, true, true, ['__get']); - $apiUser->method('__get')->with($this->equalTo('login'))->willReturn('login'); + $apiUser->method('__get')->with(self::equalTo('login'))->willReturn('login'); $user = $this->createMock(ReferenceUserInterface::class); $user->method('getAPIUser')->willReturn($apiUser); $token = $this->createMock(TokenInterface::class); @@ -114,7 +114,7 @@ public function testInvalid() $constraint = new UserPassword(); $constraintViolationBuilder = $this->createMock(ConstraintViolationBuilderInterface::class); $this->executionContext - ->expects($this->once()) + ->expects(self::once()) ->method('buildViolation') ->with($constraint->message) ->willReturn($constraintViolationBuilder);