10000 Add type declarations to Form component · symfony/symfony@9d4eb15 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d4eb15

Browse files
committed
Add type declarations to Form component
1 parent d336b11 commit 9d4eb15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+242
-356
lines changed

src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php

Lines changed: 3 additions & 3 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, $resource, string $blockName, array $variables = [])
43+
public function renderBlock(FormView $view, $resource, $blockName, array $variables = [])
4444
{
4545
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
4646

@@ -72,7 +72,7 @@ public function renderBlock(FormView $view, $resource, string $blockName, array
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($cacheKey, FormView $view, $blockName)
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]
@@ -145,7 +145,7 @@ protected function loadResourceForBlockName(string $cacheKey, FormView $view, st
145145
* this variable will be kept and be available upon
146146
* further calls to this method using the same theme.
147147
*/
148-
protected function loadResourcesFromTheme(string $cacheKey, &$theme)
148+
protected function loadResourcesFromTheme($cacheKey, &$theme)
149149
{
150150
if (!$theme instanceof Template) {
151151
/* @var Template $theme */

src/Symfony/Component/Form/AbstractExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract class AbstractExtension implements FormExtensionInterface
5050
/**
5151
* {@inheritdoc}
5252
*/
53-
public function getType($name)
53+
public function getType(string $name)
5454
{
5555
if (null === $this->types) {
5656
$this->initTypes();
@@ -66,7 +66,7 @@ public function getType($name)
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
public function hasType($name)
69+
public function hasType(string $name)
7070
{
7171
if (null === $this->types) {
7272
$this->initTypes();
@@ -78,7 +78,7 @@ public function hasType($name)
7878
/**
7979
* {@inheritdoc}
8080
*/
81-
public function getTypeExtensions($name)
81+
public function getTypeExtensions(string $name)
8282
{
8383
if (null === $this->typeExtensions) {
8484
$this->initTypeExtensions();
@@ -92,7 +92,7 @@ public function getTypeExtensions($name)
9292
/**
9393
* {@inheritdoc}
9494
*/
95-
public function hasTypeExtensions($name)
95+
public function hasTypeExtensions(string $name)
9696
{
9797
if (null === $this->typeExtensions) {
9898
$this->initTypeExtensions();

src/Symfony/Component/Form/AbstractRendererEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ abstract protected function loadResourceForBlockName(string $cacheKey, FormView
125125
*
126126
* @return bool True if the resource could be loaded, false otherwise
127127
*/
128-
private function loadResourceForBlockNameHierarchy(string $cacheKey, FormView $view, array $blockNameHierarchy, $hierarchyLevel)
128+
private function loadResourceForBlockNameHierarchy(string $cacheKey, FormView $view, array $blockNameHierarchy, int $hierarchyLevel)
129129
{
130130
$blockName = $blockNameHierarchy[$hierarchyLevel];
131131

src/Symfony/Component/Form/Button.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,10 @@ public function getParent()
129129
* This method should not be invoked.
130130
*
131131
* @param int|string|FormInterface $child
132-
* @param null $type
133-
* @param array $options
134132
*
135133
* @throws BadMethodCallException
136134
*/
137-
public function add($child, $type = null, array $options = [])
135+
public function add($child, string $type = null, array $options = [])
138136
{
139137
throw new BadMethodCallException('Buttons cannot have children.');
140138
}
@@ -148,7 +146,7 @@ public function add($child, $type = null, array $options = [])
148146
*
149147
* @throws BadMethodCallException
150148
*/
151-
public function get($name)
149+
public function get(string $name)
152150
{
153151
throw new BadMethodCallException('Buttons cannot have children.');
154152
}
@@ -160,7 +158,7 @@ public function get($name)
160158
*
161159
* @return bool Always returns false
162160
*/
163-
public function has($name)
161+
public function has(string $name)
164162
{
165163
return false;
166164
}
@@ -174,7 +172,7 @@ public function has($name)
174172
*
175173
* @throws BadMethodCallException
176174
*/
177-
public function remove($name)
175+
public function remove(string $name)
178176
{
179177
throw new BadMethodCallException('Buttons cannot have children.');
180178
}
@@ -190,7 +188,7 @@ public function all()
190188
/**
191189
* {@inheritdoc}
192190
*/
193-
public function getErrors($deep = false, $flatten = true)
191+
public function getErrors(bool $deep = false, bool $flatten = true)
194192
{
195193
return new FormErrorIterator($this, []);
196194
}
@@ -384,7 +382,7 @@ public function handleRequest($request = null)
384382
*
385383
* @throws Exception\AlreadySubmittedException if the button has already been submitted
386384
*/
387-
public function submit($submittedData, $clearMissing = true)
385+
public function submit($submittedData, bool $clearMissing = true)
388386
{
389387
if ($this->submitted) {
390388
throw new AlreadySubmittedException('A form can only be submitted once');

0 commit comments

Comments
 (0)
0