diff --git a/src/Doctrine/Functions/Field2.php b/src/Doctrine/Functions/Field2.php index dc12b294..2e11a855 100644 --- a/src/Doctrine/Functions/Field2.php +++ b/src/Doctrine/Functions/Field2.php @@ -36,7 +36,7 @@ class Field2 extends FunctionNode private $values = []; - public function parse(\Doctrine\ORM\Query\Parser $parser) + public function parse(\Doctrine\ORM\Query\Parser $parser): void { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); @@ -58,7 +58,7 @@ class Field2 extends FunctionNode $parser->match(Lexer::T_CLOSE_PARENTHESIS); } - public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) + public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker): string { $query = 'FIELD2('; diff --git a/src/Entity/OAuthToken.php b/src/Entity/OAuthToken.php index b1534a4d..3924e1a8 100644 --- a/src/Entity/OAuthToken.php +++ b/src/Entity/OAuthToken.php @@ -135,17 +135,17 @@ class OAuthToken extends AbstractNamedDBElement implements AccessTokenInterface $this->expires_at = self::unixTimestampToDatetime($accessToken->getExpires() ?? time() + self::DEFAULT_EXPIRATION_TIME); } - public function getExpires() + public function getExpires(): ?int { return $this->expires_at->getTimestamp(); } - public function hasExpired() + public function hasExpired(): bool { return $this->isExpired(); } - public function getValues() + public function getValues(): array { return []; } diff --git a/src/EventSubscriber/SwitchUserEventSubscriber.php b/src/EventSubscriber/SwitchUserEventSubscriber.php index a7f2e39c..b68f6b4f 100644 --- a/src/EventSubscriber/SwitchUserEventSubscriber.php +++ b/src/EventSubscriber/SwitchUserEventSubscriber.php @@ -38,7 +38,7 @@ class SwitchUserEventSubscriber implements EventSubscriberInterface { } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'security.switch_user' => 'onSwitchUser', diff --git a/src/Form/InfoProviderSystem/ProviderSelectType.php b/src/Form/InfoProviderSystem/ProviderSelectType.php index 6ebe663d..26ff6be9 100644 --- a/src/Form/InfoProviderSystem/ProviderSelectType.php +++ b/src/Form/InfoProviderSystem/ProviderSelectType.php @@ -43,7 +43,7 @@ class ProviderSelectType extends AbstractType return ChoiceType::class; } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'choices' => $this->providerRegistry->getActiveProviders(), diff --git a/src/Form/PasswordTypeExtension.php b/src/Form/PasswordTypeExtension.php index f97eeb8e..a911bf90 100644 --- a/src/Form/PasswordTypeExtension.php +++ b/src/Form/PasswordTypeExtension.php @@ -46,7 +46,7 @@ class PasswordTypeExtension extends AbstractTypeExtension $resolver->setAllowedTypes('password_estimator', 'bool'); } - public function finishView(FormView $view, FormInterface $form, array $options) + public function finishView(FormView $view, FormInterface $form, array $options): void { $view->vars['password_estimator'] = $options['password_estimator']; } diff --git a/src/Form/ProjectSystem/ProjectAddPartsType.php b/src/Form/ProjectSystem/ProjectAddPartsType.php index f89f3567..ddcdc33a 100644 --- a/src/Form/ProjectSystem/ProjectAddPartsType.php +++ b/src/Form/ProjectSystem/ProjectAddPartsType.php @@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints\NotNull; class ProjectAddPartsType extends AbstractType { - public function buildForm(FormBuilderInterface $builder, array $options) + public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('project', StructuralEntityType::class, [ 'class' => Project::class, @@ -73,7 +73,7 @@ class ProjectAddPartsType extends AbstractType }); } - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'project' => null, diff --git a/src/Serializer/AttachmentNormalizer.php b/src/Serializer/AttachmentNormalizer.php index 7911a9c3..c71e035d 100644 --- a/src/Serializer/AttachmentNormalizer.php +++ b/src/Serializer/AttachmentNormalizer.php @@ -40,7 +40,7 @@ class AttachmentNormalizer implements NormalizerInterface } - public function normalize(mixed $object, string $format = null, array $context = []) + public function normalize(mixed $object, string $format = null, array $context = []): array|null { if (!$object instanceof Attachment) { throw new \InvalidArgumentException('This normalizer only supports Attachment objects!'); diff --git a/src/Serializer/BigNumberNormalizer.php b/src/Serializer/BigNumberNormalizer.php index 80bb98d7..8ef06d67 100644 --- a/src/Serializer/BigNumberNormalizer.php +++ b/src/Serializer/BigNumberNormalizer.php @@ -58,7 +58,7 @@ class BigNumberNormalizer implements NormalizerInterface, DenormalizerInterface ]; } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []) + public function denormalize(mixed $data, string $type, string $format = null, array $context = []): BigNumber|null { if (!is_a($type, BigNumber::class, true)) { throw new \InvalidArgumentException('This normalizer only supports BigNumber objects!'); @@ -67,7 +67,7 @@ class BigNumberNormalizer implements NormalizerInterface, DenormalizerInterface return $type::of($data); } - public function supportsDenormalization(mixed $data, string $type, string $format = null) + public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool { //data must be a string or a number (int, float, etc.) and the type must be BigNumber or BigDecimal return (is_string($data) || is_numeric($data)) && (is_subclass_of($type, BigNumber::class)); diff --git a/src/Services/SnakeCasePropertyAccessExtractor.php b/src/Services/SnakeCasePropertyAccessExtractor.php index bfe82c63..0eaed204 100644 --- a/src/Services/SnakeCasePropertyAccessExtractor.php +++ b/src/Services/SnakeCasePropertyAccessExtractor.php @@ -41,7 +41,7 @@ class SnakeCasePropertyAccessExtractor implements PropertyAccessExtractorInterfa //$this->reflectionExtractor = new ReflectionExtractor(); } - public function isReadable(string $class, string $property, array $context = []) + public function isReadable(string $class, string $property, array $context = []): ?bool { //Null means skip this extractor return null; @@ -56,7 +56,7 @@ class SnakeCasePropertyAccessExtractor implements PropertyAccessExtractorInterfa } - public function isWritable(string $class, string $property, array $context = []) + public function isWritable(string $class, string $property, array $context = []): ?bool { //Check writeablity using a camelized property name $isWriteable = $this->reflectionExtractor->isWritable($class, $this->camelize($property), $context); diff --git a/src/Validator/Constraints/UniqueObjectCollectionValidator.php b/src/Validator/Constraints/UniqueObjectCollectionValidator.php index 5522ca19..eaac097d 100644 --- a/src/Validator/Constraints/UniqueObjectCollectionValidator.php +++ b/src/Validator/Constraints/UniqueObjectCollectionValidator.php @@ -32,7 +32,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException; class UniqueObjectCollectionValidator extends ConstraintValidator { - public function validate(mixed $value, Constraint $constraint) + public function validate(mixed $value, Constraint $constraint): void { if (!$constraint instanceof UniqueObjectCollection) { throw new UnexpectedTypeException($constraint, UniqueObjectCollection::class); diff --git a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php index 6b3887e4..5ba98a47 100644 --- a/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php +++ b/tests/Validator/Constraints/ValidGoogleAuthCodeValidatorTest.php @@ -28,22 +28,21 @@ use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface; use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase { - protected function createValidator() + protected function createValidator(): ConstraintValidatorInterface { $googleAuth = new class implements GoogleAuthenticatorInterface { public function checkCode(TwoFactorInterface $user, string $code): bool { - if ($code === '123456') { - return true; - } - return false; + return $code === '123456'; } public function getQRContent(TwoFactorInterface $user): string