Skip to content

Commit

Permalink
minor symfony#1170 Add missing type declarations (derrabus)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
javiereguiluz committed Oct 22, 2020
2 parents 559a2ac + 336a332 commit 1a397dd
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ services:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind: # defines the scalar arguments once and apply them to any service defined/created in this file
$locales: '%app_locales%'
$defaultLocale: '%locale%'
$emailSender: '%app.notifications.email_sender%'
string $locales: '%app_locales%'
string $defaultLocale: '%locale%'
string $emailSender: '%app.notifications.email_sender%'

# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ListUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ListUsersCommand extends Command
private $emailSender;
private $users;

public function __construct(MailerInterface $mailer, $emailSender, UserRepository $users)
public function __construct(MailerInterface $mailer, string $emailSender, UserRepository $users)
{
parent::__construct();

Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Post
private $author;

/**
* @var Comment[]|ArrayCollection
* @var Comment[]|Collection
*
* @ORM\OneToMany(
* targetEntity="Comment",
Expand All @@ -106,7 +106,7 @@ class Post
private $comments;

/**
* @var Tag[]|ArrayCollection
* @var Tag[]|Collection
*
* @ORM\ManyToMany(targetEntity="App\Entity\Tag", cascade={"persist"})
* @ORM\JoinTable(name="symfony_demo_post_tag")
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/CommentNotificationSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CommentNotificationSubscriber implements EventSubscriberInterface
private $urlGenerator;
private $sender;

public function __construct(MailerInterface $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, $sender)
public function __construct(MailerInterface $mailer, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, string $sender)
{
$this->mailer = $mailer;
$this->urlGenerator = $urlGenerator;
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/DateTimePickerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function configureOptions(OptionsResolver $resolver): void
/**
* {@inheritdoc}
*/
public function getParent()
public function getParent(): ?string
{
return DateTimeType::class;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/TagsInputType.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function buildView(FormView $view, FormInterface $form, array $options):
/**
* {@inheritdoc}
*/
public function getParent()
public function getParent(): ?string
{
return TextType::class;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Security/PostVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ class PostVoter extends Voter
/**
* {@inheritdoc}
*/
protected function supports($attribute, $subject): bool
protected function supports(string $attribute, $subject): bool
{
// this voter is only executed for three specific permissions on Post objects
return $subject instanceof Post && \in_array($attribute, [self::SHOW, self::EDIT, self::DELETE], true);
}

/**
* {@inheritdoc}
*
* @param Post $post
*/
protected function voteOnAttribute($attribute, $post, TokenInterface $token): bool
protected function voteOnAttribute(string $attribute, $post, TokenInterface $token): bool
{
$user = $token->getUser();

Expand Down
8 changes: 4 additions & 4 deletions src/Twig/SourceCodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function getFunctions(): array
];
}

/**
* @param string|TemplateWrapper|array $template
*/
public function showSourceCode(Environment $twig, $template): string
{
return $twig->render('debug/source_code.html.twig', [
Expand Down Expand Up @@ -94,10 +97,7 @@ private function getCallableReflector(callable $callable): \ReflectionFunctionAb
return new \ReflectionFunction($callable);
}

/**
* @param TemplateWrapper|Template $template
*/
private function getTemplateSource($template): array
private function getTemplateSource(TemplateWrapper $template): array
{
$templateSource = $template->getSourceContext();

Expand Down

0 comments on commit 1a397dd

Please sign in to comment.