-
-
Notifications
You must be signed in to change notification settings - Fork 437
Add missing types in code templates #1109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,12 @@ | |
|
|
||
| class <?= $class_name ?> implements EventSubscriberInterface | ||
| { | ||
| public function <?= $method_name ?>(<?= $event_arg ?>) | ||
| public function <?= $method_name ?>(<?= $event_arg ?>): void | ||
| { | ||
| // ... | ||
| } | ||
|
|
||
| public static function getSubscribedEvents() | ||
| public static function getSubscribedEvents(): array | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. triggers a deprecation without the return type |
||
| { | ||
| return [ | ||
| <?= $event ?> => '<?= $method_name ?>', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,15 +11,15 @@ class <?= $class_name ?> extends Voter | |
| public const EDIT = 'POST_EDIT'; | ||
| public const VIEW = 'POST_VIEW'; | ||
|
|
||
| protected function supports(<?= $use_type_hints ? 'string ' : null ?>$attribute, $subject): bool | ||
| protected function supports(string $attribute, $subject): bool | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kernel is at 5.4 minimum already |
||
| { | ||
| // replace with your own logic | ||
| // https://symfony.com/doc/current/security/voters.html | ||
| return in_array($attribute, [self::EDIT, self::VIEW]) | ||
| && $subject instanceof \App\Entity\<?= str_replace('Voter', null, $class_name) ?>; | ||
| } | ||
|
|
||
| protected function voteOnAttribute(<?= $use_type_hints ? 'string ' : null ?>$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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,24 +9,24 @@ class <?= $class_name ?> implements EncoderInterface, DecoderInterface | |
| { | ||
| public const FORMAT = '<?= $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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not adding $context is deprecated |
||
| { | ||
| 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; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consistency |
||
|
|
||
| return $data; | ||
| } | ||
|
|
||
| public function supportsNormalization($data, $format = null): bool | ||
| public function supportsNormalization($data, string $format = null, array $context = []): bool | ||
| { | ||
| return $data instanceof \App\Entity\<?= str_replace('Normalizer', null, $class_name) ?>; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,9 @@ | |
|
|
||
| /** | ||
| * @Annotation | ||
| * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) | ||
| */ | ||
| #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because we can, isn't it? |
||
| class <?= $class_name ?> extends Constraint | ||
| { | ||
| /* | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sticking to a consistent CS for examples