Skip to content

Commit 521581f

Browse files
derrabusnicolas-grekas
authored andcommitted
Add types to constructors and private/final/internal methods (Batch III)
1 parent e944c59 commit 521581f

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private function getMetadata(string $type, $entity)
360360
return null;
361361
}
362362

363-
private function getPrettyMetadata(string $type, $entity, bool $decorated)
363+
private function getPrettyMetadata(string $type, $entity, bool $decorated): ?string
364364
{
365365
if ('tests' === $type) {
366366
return '';

Command/LintCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private function getStdin(): string
119119
return $template;
120120
}
121121

122-
private function getFilesInfo(array $filenames)
122+
private function getFilesInfo(array $filenames): array
123123
{
124124
$filesInfo = [];
125125
foreach ($filenames as $filename) {

Extension/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public function formatFileFromText($text)
236236
/**
237237
* @internal
238238
*/
239-
public function formatLogMessage($message, array $context)
239+
public function formatLogMessage(string $message, array $context): string
240240
{
241241
if ($context && false !== strpos($message, '{')) {
242242
$replacements = [];

Extension/FormExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getName()
111111
*
112112
* @see ChoiceView::isSelected()
113113
*/
114-
function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
114+
function twig_is_selected_choice(ChoiceView $choice, $selectedValue): bool
115115
{
116116
if (\is_array($selectedValue)) {
117117
return \in_array($choice->value, $selectedValue, true);
@@ -123,7 +123,7 @@ function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
123123
/**
124124
* @internal
125125
*/
126-
function twig_is_root_form(FormView $formView)
126+
function twig_is_root_form(FormView $formView): bool
127127
{
128128
return null === $formView->parent;
129129
}

NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private function isNamedArguments(Node $arguments): bool
132132
return false;
133133
}
134134

135-
private function getVarName()
135+
private function getVarName(): string
136136
{
137137
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
138138
}

UndefinedCallableHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class UndefinedCallableHandler
6565
'workflow' => 'enable "framework.workflows"',
6666
];
6767

68-
public static function onUndefinedFilter($name)
68+
public static function onUndefinedFilter(string $name): bool
6969
{
7070
if (!isset(self::$filterComponents[$name])) {
7171
return false;
@@ -76,7 +76,7 @@ public static function onUndefinedFilter($name)
7676
return true;
7777
}
7878

79-
public static function onUndefinedFunction($name)
79+
public static function onUndefinedFunction(string $name): bool
8080
{
8181
if (!isset(self::$functionComponents[$name])) {
8282
return false;
@@ -87,7 +87,7 @@ public static function onUndefinedFunction($name)
8787
return true;
8888
}
8989

90-
private static function onUndefined($name, $type, $component)
90+
private static function onUndefined(string $name, string $type, string $component)
9191
{
9292
if (class_exists(FullStack::class) && isset(self::$fullStackEnable[$component])) {
9393
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::$fullStackEnable[$component], $type, $name));

0 commit comments

Comments
 (0)