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 = [];
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(';

View file

@ -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 [];
}

View file

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

View file

@ -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(),

View file

@ -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'];
}

View file

@ -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,

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) {
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)) {
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));

View file

@ -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);

View file

@ -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);

View file

@ -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