Fixed some deprecations related to missing return types

This commit is contained in:
Jan Böhmer 2023-10-25 17:27:37 +02:00
parent eb24aa2e68
commit 294f7cf005
11 changed files with 20 additions and 21 deletions

View file

@ -36,7 +36,7 @@ class Field2 extends FunctionNode
private $values = []; 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_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS); $parser->match(Lexer::T_OPEN_PARENTHESIS);
@ -58,7 +58,7 @@ class Field2 extends FunctionNode
$parser->match(Lexer::T_CLOSE_PARENTHESIS); $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('; $query = 'FIELD2(';

View file

@ -135,17 +135,17 @@ class OAuthToken extends AbstractNamedDBElement implements AccessTokenInterface
$this->expires_at = self::unixTimestampToDatetime($accessToken->getExpires() ?? time() + self::DEFAULT_EXPIRATION_TIME); $this->expires_at = self::unixTimestampToDatetime($accessToken->getExpires() ?? time() + self::DEFAULT_EXPIRATION_TIME);
} }
public function getExpires() public function getExpires(): ?int
{ {
return $this->expires_at->getTimestamp(); return $this->expires_at->getTimestamp();
} }
public function hasExpired() public function hasExpired(): bool
{ {
return $this->isExpired(); return $this->isExpired();
} }
public function getValues() public function getValues(): array
{ {
return []; return [];
} }

View file

@ -38,7 +38,7 @@ class SwitchUserEventSubscriber implements EventSubscriberInterface
{ {
} }
public static function getSubscribedEvents() public static function getSubscribedEvents(): array
{ {
return [ return [
'security.switch_user' => 'onSwitchUser', 'security.switch_user' => 'onSwitchUser',

View file

@ -43,7 +43,7 @@ class ProviderSelectType extends AbstractType
return ChoiceType::class; return ChoiceType::class;
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([
'choices' => $this->providerRegistry->getActiveProviders(), 'choices' => $this->providerRegistry->getActiveProviders(),

View file

@ -46,7 +46,7 @@ class PasswordTypeExtension extends AbstractTypeExtension
$resolver->setAllowedTypes('password_estimator', 'bool'); $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']; $view->vars['password_estimator'] = $options['password_estimator'];
} }

View file

@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints\NotNull;
class ProjectAddPartsType extends AbstractType class ProjectAddPartsType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder->add('project', StructuralEntityType::class, [ $builder->add('project', StructuralEntityType::class, [
'class' => Project::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([ $resolver->setDefaults([
'project' => null, 'project' => null,

View file

@ -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) { if (!$object instanceof Attachment) {
throw new \InvalidArgumentException('This normalizer only supports Attachment objects!'); throw new \InvalidArgumentException('This normalizer only supports Attachment objects!');

View file

@ -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)) { if (!is_a($type, BigNumber::class, true)) {
throw new \InvalidArgumentException('This normalizer only supports BigNumber objects!'); throw new \InvalidArgumentException('This normalizer only supports BigNumber objects!');
@ -67,7 +67,7 @@ class BigNumberNormalizer implements NormalizerInterface, DenormalizerInterface
return $type::of($data); 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 //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)); return (is_string($data) || is_numeric($data)) && (is_subclass_of($type, BigNumber::class));

View file

@ -41,7 +41,7 @@ class SnakeCasePropertyAccessExtractor implements PropertyAccessExtractorInterfa
//$this->reflectionExtractor = new ReflectionExtractor(); //$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 //Null means skip this extractor
return null; 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 //Check writeablity using a camelized property name
$isWriteable = $this->reflectionExtractor->isWritable($class, $this->camelize($property), $context); $isWriteable = $this->reflectionExtractor->isWritable($class, $this->camelize($property), $context);

View file

@ -32,7 +32,7 @@ use Symfony\Component\Validator\Exception\UnexpectedValueException;
class UniqueObjectCollectionValidator extends ConstraintValidator class UniqueObjectCollectionValidator extends ConstraintValidator
{ {
public function validate(mixed $value, Constraint $constraint) public function validate(mixed $value, Constraint $constraint): void
{ {
if (!$constraint instanceof UniqueObjectCollection) { if (!$constraint instanceof UniqueObjectCollection) {
throw new UnexpectedTypeException($constraint, UniqueObjectCollection::class); throw new UnexpectedTypeException($constraint, UniqueObjectCollection::class);

View file

@ -28,22 +28,21 @@ use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface;
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface; use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
use Symfony\Bundle\SecurityBundle\Security; use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase
{ {
protected function createValidator() protected function createValidator(): ConstraintValidatorInterface
{ {
$googleAuth = new class implements GoogleAuthenticatorInterface $googleAuth = new class implements GoogleAuthenticatorInterface
{ {
public function checkCode(TwoFactorInterface $user, string $code): bool public function checkCode(TwoFactorInterface $user, string $code): bool
{ {
if ($code === '123456') { return $code === '123456';
return true;
}
return false;
} }
public function getQRContent(TwoFactorInterface $user): string public function getQRContent(TwoFactorInterface $user): string