Skip to content

Commit 1a397dd

Browse files
committed
minor #1170 Add missing type declarations (derrabus)
This PR was merged into the master branch. Discussion ---------- Add missing type declarations This PR adds some type declarations where they were missing before. Commits ------- 336a332 Add missing type declarations.
2 parents 559a2ac + 336a332 commit 1a397dd

File tree

8 files changed

+17
-15
lines changed

8 files changed

+17
-15
lines changed

config/services.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ services:
1515
autowire: true # Automatically injects dependencies in your services.
1616
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
1717
bind: # defines the scalar arguments once and apply them to any service defined/created in this file
18-
$locales: '%app_locales%'
19-
$defaultLocale: '%locale%'
20-
$emailSender: '%app.notifications.email_sender%'
18+
string $locales: '%app_locales%'
19+
string $defaultLocale: '%locale%'
20+
string $emailSender: '%app.notifications.email_sender%'
2121

2222
# makes classes in src/ available to be used as services
2323
# this creates a service per class whose id is the fully-qualified class name

src/Command/ListUsersCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ListUsersCommand extends Command
4646
private $emailSender;
4747
private $users;
4848

49-
public function __construct(MailerInterface $mailer, $emailSender, UserRepository $users)
49+
public function __construct(MailerInterface $mailer, string $emailSender, UserRepository $users)
5050
{
5151
parent::__construct();
5252

src/Entity/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Post
9393
private $author;
9494

9595
/**
96-
* @var Comment[]|ArrayCollection
96+
* @var Comment[]|Collection
9797
*
9898
* @ORM\OneToMany(
9999
* targetEntity="Comment",
@@ -106,7 +106,7 @@ class Post
106106
private $comments;
107107

108108
/**
109-
* @var Tag[]|ArrayCollection
109+
* @var Tag[]|Collection
110110
*
111111
* @ORM\ManyToMany(targetEntity="App\Entity\Tag", cascade={"persist"})
112112
* @ORM\JoinTable(name="symfony_demo_post_tag")

src/EventSubscriber/CommentNotificationSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CommentNotificationSubscriber implements EventSubscriberInterface
3131
private $urlGenerator;
3232
private $sender;
3333

34-
public function __construct(MailerInterface $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, $sender)
34+
public function __construct(MailerInterface $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, string $sender)
3535
{
3636
$this->mailer = $mailer;
3737
$this->urlGenerator = $urlGenerator;

src/Form/Type/DateTimePickerType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function configureOptions(OptionsResolver $resolver): void
6161
/**
6262
* {@inheritdoc}
6363
*/
64-
public function getParent()
64+
public function getParent(): ?string
6565
{
6666
return DateTimeType::class;
6767
}

src/Form/Type/TagsInputType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public function getParent()
66+
public function getParent(): ?string
6767
{
6868
return TextType::class;
6969
}

src/Security/PostVoter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ class PostVoter extends Voter
3535
/**
3636
* {@inheritdoc}
3737
*/
38-
protected function supports($attribute, $subject): bool
38+
protected function supports(string $attribute, $subject): bool
3939
{
4040
// this voter is only executed for three specific permissions on Post objects
4141
return $subject instanceof Post && \in_array($attribute, [self::SHOW, self::EDIT, self::DELETE], true);
4242
}
4343

4444
/**
4545
* {@inheritdoc}
46+
*
47+
* @param Post $post
4648
*/
47-
protected function voteOnAttribute($attribute, $post, TokenInterface $token): bool
49+
protected function voteOnAttribute(string $attribute, $post, TokenInterface $token): bool
4850
{
4951
$user = $token->getUser();
5052

src/Twig/SourceCodeExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function getFunctions(): array
4646
];
4747
}
4848

49+
/**
50+
* @param string|TemplateWrapper|array $template
51+
*/
4952
public function showSourceCode(Environment $twig, $template): string
5053
{
5154
return $twig->render('debug/source_code.html.twig', [
@@ -94,10 +97,7 @@ private function getCallableReflector(callable $callable): \ReflectionFunctionAb
9497
return new \ReflectionFunction($callable);
9598
}
9699

97-
/**
98-
* @param TemplateWrapper|Template $template
99-
*/
100-
private function getTemplateSource($template): array
100+
private function getTemplateSource(TemplateWrapper $template): array
101101
{
102102
$templateSource = $template->getSourceContext();
103103

0 commit comments

Comments
 (0)