diff --git a/src/Maker/MakeVoter.php b/src/Maker/MakeVoter.php index b0543f996..cd607d466 100644 --- a/src/Maker/MakeVoter.php +++ b/src/Maker/MakeVoter.php @@ -18,7 +18,6 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Security\Core\Authorization\Voter\Voter; /** @@ -56,9 +55,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $generator->generateClass( $voterClassNameDetails->getFullName(), 'security/Voter.tpl.php', - [ - 'use_type_hints' => 50000 <= Kernel::VERSION_ID, - ] + [] ); $generator->writeChanges(); diff --git a/src/Resources/skeleton/doctrine/Repository.tpl.php b/src/Resources/skeleton/doctrine/Repository.tpl.php index 22e406a3d..2f4c6e421 100644 --- a/src/Resources/skeleton/doctrine/Repository.tpl.php +++ b/src/Resources/skeleton/doctrine/Repository.tpl.php @@ -70,33 +70,29 @@ public function upgradePassword( - // /** - // * @return [] Returns an array of objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('') - ->andWhere('.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ +// /** +// * @return [] Returns an array of objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('') +// ->andWhere('.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } - /* - public function findOneBySomeField($value): ? - { - return $this->createQueryBuilder('') - ->andWhere('.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ +// public function findOneBySomeField($value): ? +// { +// return $this->createQueryBuilder('') +// ->andWhere('.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } } diff --git a/src/Resources/skeleton/event/Subscriber.tpl.php b/src/Resources/skeleton/event/Subscriber.tpl.php index ef83b001f..816cf1a49 100644 --- a/src/Resources/skeleton/event/Subscriber.tpl.php +++ b/src/Resources/skeleton/event/Subscriber.tpl.php @@ -7,12 +7,12 @@ class implements EventSubscriberInterface { - public function () + public function (): void { // ... } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ => '', diff --git a/src/Resources/skeleton/message/Message.tpl.php b/src/Resources/skeleton/message/Message.tpl.php index 721c1d33c..ab6e6dab2 100644 --- a/src/Resources/skeleton/message/Message.tpl.php +++ b/src/Resources/skeleton/message/Message.tpl.php @@ -5,17 +5,17 @@ final class { /* - * Add whatever properties & methods you need to hold the - * data for this message class. + * Add whatever properties and methods you need + * to hold the data for this message class. */ // private $name; -// + // public function __construct(string $name) // { // $this->name = $name; // } -// + // public function getName(): string // { // return $this->name; diff --git a/src/Resources/skeleton/security/UserProvider.tpl.php b/src/Resources/skeleton/security/UserProvider.tpl.php index c7ee1ef38..961ac3f44 100644 --- a/src/Resources/skeleton/security/UserProvider.tpl.php +++ b/src/Resources/skeleton/security/UserProvider.tpl.php @@ -64,7 +64,7 @@ public function refreshUser(UserInterface $user): UserInterface /** * Tells Symfony to use this provider for this User class. */ - public function supportsClass($class): bool + public function supportsClass(string $class): bool { return ::class === $class || is_subclass_of($class, ::class); } diff --git a/src/Resources/skeleton/security/Voter.tpl.php b/src/Resources/skeleton/security/Voter.tpl.php index d012bec09..c56d6d94b 100644 --- a/src/Resources/skeleton/security/Voter.tpl.php +++ b/src/Resources/skeleton/security/Voter.tpl.php @@ -11,7 +11,7 @@ class extends Voter public const EDIT = 'POST_EDIT'; public const VIEW = 'POST_VIEW'; - protected function supports($attribute, $subject): bool + protected function supports(string $attribute, $subject): bool { // replace with your own logic // https://symfony.com/doc/current/security/voters.html @@ -19,7 +19,7 @@ protected function supports($attribute, && $subject instanceof \App\Entity\; } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool { $user = $token->getUser(); // if the user is anonymous, do not grant access diff --git a/src/Resources/skeleton/serializer/Encoder.tpl.php b/src/Resources/skeleton/serializer/Encoder.tpl.php index 490918f51..80db93d8a 100644 --- a/src/Resources/skeleton/serializer/Encoder.tpl.php +++ b/src/Resources/skeleton/serializer/Encoder.tpl.php @@ -9,24 +9,24 @@ class implements EncoderInterface, DecoderInterface { public const FORMAT = ''; - public function encode($data, $format, array $context = []) + public function encode($data, string $format, array $context = []): string { // TODO: return your encoded data return ''; } - public function supportsEncoding($format): bool + public function supportsEncoding(string $format, array $context = []): bool { return self::FORMAT === $format; } - public function decode($data, $format, array $context = []) + public function decode(string $data, string $format, array $context = []) { // TODO: return your decoded data return ''; } - public function supportsDecoding($format): bool + public function supportsDecoding(string $format, array $context = []): bool { return self::FORMAT === $format; } diff --git a/src/Resources/skeleton/serializer/Normalizer.tpl.php b/src/Resources/skeleton/serializer/Normalizer.tpl.php index ae315454e..c2950b193 100644 --- a/src/Resources/skeleton/serializer/Normalizer.tpl.php +++ b/src/Resources/skeleton/serializer/Normalizer.tpl.php @@ -15,16 +15,16 @@ public function __construct(ObjectNormalizer $normalizer) $this->normalizer = $normalizer; } - public function normalize($object, $format = null, array $context = []): array + public function normalize($object, string $format = null, array $context = []): array { $data = $this->normalizer->normalize($object, $format, $context); - // Here: add, edit, or delete some data + // TODO: add, edit, or delete some data return $data; } - public function supportsNormalization($data, $format = null): bool + public function supportsNormalization($data, string $format = null, array $context = []): bool { return $data instanceof \App\Entity\; } diff --git a/src/Resources/skeleton/validator/Constraint.tpl.php b/src/Resources/skeleton/validator/Constraint.tpl.php index 4c1425aef..e713088a8 100644 --- a/src/Resources/skeleton/validator/Constraint.tpl.php +++ b/src/Resources/skeleton/validator/Constraint.tpl.php @@ -6,7 +6,9 @@ /** * @Annotation + * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) */ +#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class extends Constraint { /* diff --git a/tests/Doctrine/fixtures/expected_xml/src/Repository/UserRepository.php b/tests/Doctrine/fixtures/expected_xml/src/Repository/UserRepository.php index dd3d8f374..64cd0ddfe 100644 --- a/tests/Doctrine/fixtures/expected_xml/src/Repository/UserRepository.php +++ b/tests/Doctrine/fixtures/expected_xml/src/Repository/UserRepository.php @@ -47,32 +47,28 @@ public function remove(UserXml $entity, bool $flush = false): void } } - // /** - // * @return UserXml[] Returns an array of UserXml objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('u') - ->andWhere('u.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('u.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ +// /** +// * @return UserXml[] Returns an array of UserXml objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('u') +// ->andWhere('u.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('u.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } - /* - public function findOneBySomeField($value): ?UserXml - { - return $this->createQueryBuilder('u') - ->andWhere('u.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ +// public function findOneBySomeField($value): ?UserXml +// { +// return $this->createQueryBuilder('u') +// ->andWhere('u.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } } diff --git a/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php b/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php index e81340dd0..594ef414d 100644 --- a/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php +++ b/tests/Doctrine/fixtures/expected_xml/src/Repository/XOtherRepository.php @@ -47,32 +47,28 @@ public function remove(XOther $entity, bool $flush = false): void } } - // /** - // * @return XOther[] Returns an array of XOther objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('x') - ->andWhere('x.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('x.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ +// /** +// * @return XOther[] Returns an array of XOther objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('x') +// ->andWhere('x.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('x.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } - /* - public function findOneBySomeField($value): ?XOther - { - return $this->createQueryBuilder('x') - ->andWhere('x.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ +// public function findOneBySomeField($value): ?XOther +// { +// return $this->createQueryBuilder('x') +// ->andWhere('x.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } }