Skip to content

Commit 4cd0c67

Browse files
Add return types to bridges
1 parent ec0c2d6 commit 4cd0c67

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

AppVariable.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function setDebug(bool $debug)
5656
*
5757
* @throws \RuntimeException When the TokenStorage is not available
5858
*/
59-
public function getToken()
59+
public function getToken(): ?TokenInterface
6060
{
6161
if (null === $tokenStorage = $this->tokenStorage) {
6262
throw new \RuntimeException('The "app.token" variable is not available.');
@@ -72,7 +72,7 @@ public function getToken()
7272
*
7373
* @see TokenInterface::getUser()
7474
*/
75-
public function getUser()
75+
public function getUser(): ?object
7676
{
7777
if (null === $tokenStorage = $this->tokenStorage) {
7878
throw new \RuntimeException('The "app.user" variable is not available.');
@@ -92,7 +92,7 @@ public function getUser()
9292
*
9393
* @return Request|null The HTTP request object
9494
*/
95-
public function getRequest()
95+
public function getRequest(): ?Request
9696
{
9797
if (null === $this->requestStack) {
9898
throw new \RuntimeException('The "app.request" variable is not available.');
@@ -106,7 +106,7 @@ public function getRequest()
106106
*
107107
* @return Session|null The session
108108
*/
109-
public function getSession()
109+
public function getSession(): ?Session
110110
{
111111
if (null === $this->requestStack) {
112112
throw new \RuntimeException('The "app.session" variable is not available.');
@@ -121,7 +121,7 @@ public function getSession()
121121
*
122122
* @return string The current environment string (e.g 'dev')
123123
*/
124-
public function getEnvironment()
124+
public function getEnvironment(): string
125125
{
126126
if (null === $this->environment) {
127127
throw new \RuntimeException('The "app.environment" variable is not available.');
@@ -135,7 +135,7 @@ public function getEnvironment()
135135
*
136136
* @return bool The current debug mode
137137
*/
138-
public function getDebug()
138+
public function getDebug(): bool
139139
{
140140
if (null === $this->debug) {
141141
throw new \RuntimeException('The "app.debug" variable is not available.');
@@ -152,7 +152,7 @@ public function getDebug()
152152
*
153153
* @return array
154154
*/
155-
public function getFlashes(string|array $types = null)
155+
public function getFlashes(string|array $types = null): array
156156
{
157157
try {
158158
if (null === $session = $this->getSession()) {

Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function configure()
8686
;
8787
}
8888

89-
protected function execute(InputInterface $input, OutputInterface $output)
89+
protected function execute(InputInterface $input, OutputInterface $output): int
9090
{
9191
$io = new SymfonyStyle($input, $output);
9292
$name = $input->getArgument('name');

Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function configure()
8181
;
8282
}
8383

84-
protected function execute(InputInterface $input, OutputInterface $output)
84+
protected function execute(InputInterface $input, OutputInterface $output): int
8585
{
8686
$io = new SymfonyStyle($input, $output);
8787
$filenames = $input->getArgument('filename');

Form/TwigRendererEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(array $defaultThemes, Environment $environment)
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = [])
43+
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string
4444
{
4545
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
4646

@@ -72,7 +72,7 @@ public function renderBlock(FormView $view, mixed $resource, string $blockName,
7272
*
7373
* @return bool True if the resource could be loaded, false otherwise
7474
*/
75-
protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName)
75+
protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName): bool
7676
{
7777
// The caller guarantees that $this->resources[$cacheKey][$block] is
7878
// not set, but it doesn't have to check whether $this->resources[$cacheKey]

Mime/NotificationEmail.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function markAsPublic(): self
8080
/**
8181
* @return $this
8282
*/
83-
public function markdown(string $content)
83+
public function markdown(string $content): static
8484
{
8585
if (!class_exists(MarkdownExtension::class)) {
8686
throw new \LogicException(sprintf('You cannot use "%s" if the Markdown Twig extension is not available; try running "composer require twig/markdown-extra".', __METHOD__));
@@ -94,7 +94,7 @@ public function markdown(string $content)
9494
/**
9595
* @return $this
9696
*/
97-
public function content(string $content, bool $raw = false)
97+
public function content(string $content, bool $raw = false): static
9898
{
9999
$this->context['content'] = $content;
100100
$this->context['raw'] = $raw;
@@ -105,7 +105,7 @@ public function content(string $content, bool $raw = false)
105105
/**
106106
* @return $this
107107
*/
108-
public function action(string $text, string $url)
108+
public function action(string $text, string $url): static
109109
{
110110
$this->context['action_text'] = $text;
111111
$this->context['action_url'] = $url;
@@ -116,7 +116,7 @@ public function action(string $text, string $url)
116116
/**
117117
* @return $this
118118
*/
119-
public function importance(string $importance)
119+
public function importance(string $importance): static
120120
{
121121
$this->context['importance'] = $importance;
122122

@@ -126,7 +126,7 @@ public function importance(string $importance)
126126
/**
127127
* @return $this
128128
*/
129-
public function exception(\Throwable|FlattenException $exception)
129+
public function exception(\Throwable|FlattenException $exception): static
130130
{
131131
$exceptionAsString = $this->getExceptionAsString($exception);
132132

@@ -144,7 +144,7 @@ public function exception(\Throwable|FlattenException $exception)
144144
/**
145145
* @return $this
146146
*/
147-
public function theme(string $theme)
147+
public function theme(string $theme): static
148148
{
149149
$this->theme = $theme;
150150

Mime/TemplatedEmail.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TemplatedEmail extends Email
2525
/**
2626
* @return $this
2727
*/
28-
public function textTemplate(?string $template)
28+
public function textTemplate(?string $template): static
2929
{
3030
$this->textTemplate = $template;
3131

@@ -35,7 +35,7 @@ public function textTemplate(?string $template)
3535
/**
3636
* @return $this
3737
*/
38-
public function htmlTemplate(?string $template)
38+
public function htmlTemplate(?string $template): static
3939
{
4040
$this->htmlTemplate = $template;
4141

@@ -55,7 +55,7 @@ public function getHtmlTemplate(): ?string
5555
/**
5656
* @return $this
5757
*/
58-
public function context(array $context)
58+
public function context(array $context): static
5959
{
6060
$this->context = $context;
6161

NodeVisitor/Scope.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(self $parent = null)
3030
*
3131
* @return self
3232
*/
33-
public function enter()
33+
public function enter(): \Symfony\Bridge\Twig\NodeVisitor\Scope
3434
{
3535
return new self($this);
3636
}
@@ -40,7 +40,7 @@ public function enter()
4040
*
4141
* @return self|null
4242
*/
43-
public function leave()
43+
public function leave(): ?\Symfony\Bridge\Twig\NodeVisitor\Scope
4444
{
4545
$this->left = true;
4646

@@ -54,7 +54,7 @@ public function leave()
5454
*
5555
* @throws \LogicException
5656
*/
57-
public function set(string $key, mixed $value)
57+
public function set(string $key, mixed $value): static
5858
{
5959
if ($this->left) {
6060
throw new \LogicException('Left scope is not mutable.');
@@ -70,7 +70,7 @@ public function set(string $key, mixed $value)
7070
*
7171
* @return bool
7272
*/
73-
public function has(string $key)
73+
public function has(string $key): bool
7474
{
7575
if (\array_key_exists($key, $this->data)) {
7676
return true;
@@ -88,7 +88,7 @@ public function has(string $key)
8888
*
8989
* @return mixed
9090
*/
91-
public function get(string $key, mixed $default = null)
91+
public function get(string $key, mixed $default = null): mixed
9292
{
9393
if (\array_key_exists($key, $this->data)) {
9494
return $this->data[$key];

Translation/TwigExtractor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ protected function extractTemplate(string $template, MessageCatalogue $catalogue
8787
/**
8888
* @return bool
8989
*/
90-
protected function canBeExtracted(string $file)
90+
protected function canBeExtracted(string $file): bool
9191
{
9292
return $this->isFile($file) && 'twig' === pathinfo($file, \PATHINFO_EXTENSION);
9393
}
9494

9595
/**
9696
* {@inheritdoc}
9797
*/
98-
protected function extractFromDirectory($directory)
98+
protected function extractFromDirectory($directory): iterable
9999
{
100100
$finder = new Finder();
101101

UndefinedCallableHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class UndefinedCallableHandler
7171
/**
7272
* @return TwigFilter|false
7373
*/
74-
public static function onUndefinedFilter(string $name)
74+
public static function onUndefinedFilter(string $name): TwigFilter|false
7575
{
7676
if (!isset(self::FILTER_COMPONENTS[$name])) {
7777
return false;
@@ -83,7 +83,7 @@ public static function onUndefinedFilter(string $name)
8383
/**
8484
* @return TwigFunction|false
8585
*/
86-
public static function onUndefinedFunction(string $name)
86+
public static function onUndefinedFunction(string $name): TwigFunction|false
8787
{
8888
if (!isset(self::FUNCTION_COMPONENTS[$name])) {
8989
return false;

0 commit comments

Comments
 (0)