Skip to content

Commit f7403f2

Browse files
Add return types - batch 6/n
1 parent eb7f466 commit f7403f2

File tree

291 files changed

+1104
-1413
lines changed

Some content is hidden

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

291 files changed

+1104
-1413
lines changed

src/Symfony/Component/ExpressionLanguage/Tests/Fixtures/TestProvider.php

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
1515
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
16-
use Symfony\Component\ExpressionLanguage\ExpressionPhpFunction;
1716

1817
class TestProvider implements ExpressionFunctionProviderInterface
1918
{

src/Symfony/Component/Form/AbstractExtension.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class AbstractExtension implements FormExtensionInterface
4646
/**
4747
* {@inheritdoc}
4848
*/
49-
public function getType(string $name)
49+
public function getType(string $name): FormTypeInterface
5050
{
5151
if (!isset($this->types)) {
5252
$this->initTypes();
@@ -62,7 +62,7 @@ public function getType(string $name)
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function hasType(string $name)
65+
public function hasType(string $name): bool
6666
{
6767
if (!isset($this->types)) {
6868
$this->initTypes();
@@ -74,7 +74,7 @@ public function hasType(string $name)
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
public function getTypeExtensions(string $name)
77+
public function getTypeExtensions(string $name): array
7878
{
7979
if (!isset($this->typeExtensions)) {
8080
$this->initTypeExtensions();
@@ -87,7 +87,7 @@ public function getTypeExtensions(string $name)
8787
/**
8888
* {@inheritdoc}
8989
*/
90-
public function hasTypeExtensions(string $name)
90+
public function hasTypeExtensions(string $name): bool
9191
{
9292
if (!isset($this->typeExtensions)) {
9393
$this->initTypeExtensions();
@@ -99,7 +99,7 @@ public function hasTypeExtensions(string $name)
9999
/**
100100
* {@inheritdoc}
101101
*/
102-
public function getTypeGuesser()
102+
public function getTypeGuesser(): ?FormTypeGuesserInterface
103103
{
104104
if (!$this->typeGuesserLoaded) {
105105
$this->initTypeGuesser();
@@ -123,7 +123,7 @@ protected function loadTypes()
123123
*
124124
* @return FormTypeExtensionInterface[]
125125
*/
126-
protected function loadTypeExtensions()
126+
protected function loadTypeExtensions(): array
127127
{
128128
return [];
129129
}

src/Symfony/Component/Form/AbstractRendererEngine.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes =
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
public function getResourceForBlockName(FormView $view, string $blockName)
82+
public function getResourceForBlockName(FormView $view, string $blockName): mixed
8383
{
8484
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
8585

@@ -93,7 +93,7 @@ public function getResourceForBlockName(FormView $view, string $blockName)
9393
/**
9494
* {@inheritdoc}
9595
*/
96-
public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, int $hierarchyLevel)
96+
public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, int $hierarchyLevel): mixed
9797
{
9898
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
9999
$blockName = $blockNameHierarchy[$hierarchyLevel];
@@ -108,7 +108,7 @@ public function getResourceForBlockNameHierarchy(FormView $view, array $blockNam
108108
/**
109109
* {@inheritdoc}
110110
*/
111-
public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, int $hierarchyLevel)
111+
public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, int $hierarchyLevel): int|bool
112112
{
113113
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
114114
$blockName = $blockNameHierarchy[$hierarchyLevel];

src/Symfony/Component/Form/Button.php

+32-32
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use Symfony\Component\Form\Exception\AlreadySubmittedException;
1515
use Symfony\Component\Form\Exception\BadMethodCallException;
16+
use Symfony\Component\Form\Exception\TransformationFailedException;
17+
use Symfony\Component\PropertyAccess\PropertyPathInterface;
1618

1719
/**
1820
* A form button.
@@ -82,7 +84,7 @@ public function offsetUnset(mixed $offset): void
8284
/**
8385
* {@inheritdoc}
8486
*/
85-
public function setParent(FormInterface $parent = null)
87+
public function setParent(FormInterface $parent = null): static
8688
{
8789
if ($this->submitted) {
8890
throw new AlreadySubmittedException('You cannot set the parent of a submitted button.');
@@ -96,7 +98,7 @@ public function setParent(FormInterface $parent = null)
9698
/**
9799
* {@inheritdoc}
98100
*/
99-
public function getParent()
101+
public function getParent(): ?FormInterface
100102
{
101103
return $this->parent;
102104
}
@@ -108,7 +110,7 @@ public function getParent()
108110
*
109111
* @throws BadMethodCallException
110112
*/
111-
public function add(string|FormInterface $child, string $type = null, array $options = [])
113+
public function add(string|FormInterface $child, string $type = null, array $options = []): static
112114
{
113115
throw new BadMethodCallException('Buttons cannot have children.');
114116
}
@@ -120,7 +122,7 @@ public function add(string|FormInterface $child, string $type = null, array $opt
120122
*
121123
* @throws BadMethodCallException
122124
*/
123-
public function get(string $name)
125+
public function get(string $name): FormInterface
124126
{
125127
throw new BadMethodCallException('Buttons cannot have children.');
126128
}
@@ -130,7 +132,7 @@ public function get(string $name)
130132
*
131133
* @return bool Always returns false
132134
*/
133-
public function has(string $name)
135+
public function has(string $name): bool
134136
{
135137
return false;
136138
}
@@ -142,23 +144,23 @@ public function has(string $name)
142144
*
143145
* @throws BadMethodCallException
144146
*/
145-
public function remove(string $name)
147+
public function remove(string $name): static
146148
{
147149
throw new BadMethodCallException('Buttons cannot have children.');
148150
}
149151

150152
/**
151153
* {@inheritdoc}
152154
*/
153-
public function all()
155+
public function all(): array
154156
{
155157
return [];
156158
}
157159

158160
/**
159161
* {@inheritdoc}
160162
*/
161-
public function getErrors(bool $deep = false, bool $flatten = true)
163+
public function getErrors(bool $deep = false, bool $flatten = true): FormErrorIterator
162164
{
163165
return new FormErrorIterator($this, []);
164166
}
@@ -170,7 +172,7 @@ public function getErrors(bool $deep = false, bool $flatten = true)
170172
*
171173
* @return $this
172174
*/
173-
public function setData(mixed $modelData)
175+
public function setData(mixed $modelData): static
174176
{
175177
// no-op, called during initialization of the form tree
176178
return $this;
@@ -179,23 +181,23 @@ public function setData(mixed $modelData)
179181
/**
180182
* Unsupported method.
181183
*/
182-
public function getData()
184+
public function getData(): mixed
183185
{
184186
return null;
185187
}
186188

187189
/**
188190
* Unsupported method.
189191
*/
190-
public function getNormData()
192+
public function getNormData(): mixed
191193
{
192194
return null;
193195
}
194196

195197
/**
196198
* Unsupported method.
197199
*/
198-
public function getViewData()
200+
public function getViewData(): mixed
199201
{
200202
return null;
201203
}
@@ -205,17 +207,15 @@ public function getViewData()
205207
*
206208
* @return array Always returns an empty array
207209
*/
208-
public function getExtraData()
210+
public function getExtraData(): array
209211
{
210212
return [];
211213
}
212214

213215
/**
214216
* Returns the button's configuration.
215-
*
216-
* @return FormConfigInterface
217217
*/
218-
public function getConfig()
218+
public function getConfig(): FormConfigInterface
219219
{
220220
return $this->config;
221221
}
@@ -225,7 +225,7 @@ public function getConfig()
225225
*
226226
* @return bool true if the button was submitted
227227
*/
228-
public function isSubmitted()
228+
public function isSubmitted(): bool
229229
{
230230
return $this->submitted;
231231
}
@@ -235,15 +235,15 @@ public function isSubmitted()
235235
*
236236
* @return string The name of the button
237237
*/
238-
public function getName()
238+
public function getName(): string
239239
{
240240
return $this->config->getName();
241241
}
242242

243243
/**
244244
* Unsupported method.
245245
*/
246-
public function getPropertyPath()
246+
public function getPropertyPath(): ?PropertyPathInterface
247247
{
248248
return null;
249249
}
@@ -253,7 +253,7 @@ public function getPropertyPath()
253253
*
254254
* @throws BadMethodCallException
255255
*/
256-
public function addError(FormError $error)
256+
public function addError(FormError $error): static
257257
{
258258
throw new BadMethodCallException('Buttons cannot have errors.');
259259
}
@@ -263,7 +263,7 @@ public function addError(FormError $error)
263263
*
264264
* @return bool Always returns true
265265
*/
266-
public function isValid()
266+
public function isValid(): bool
267267
{
268268
return true;
269269
}
@@ -273,15 +273,15 @@ public function isValid()
273273
*
274274
* @return bool Always returns false
275275
*/
276-
public function isRequired()
276+
public function isRequired(): bool
277277
{
278278
return false;
279279
}
280280

281281
/**
282282
* {@inheritdoc}
283283
*/
284-
public function isDisabled()
284+
public function isDisabled(): bool
285285
{
286286
if ($this->parent && $this->parent->isDisabled()) {
287287
return true;
@@ -295,7 +295,7 @@ public function isDisabled()
295295
*
296296
* @return bool Always returns true
297297
*/
298-
public function isEmpty()
298+
public function isEmpty(): bool
299299
{
300300
return true;
301301
}
@@ -305,15 +305,15 @@ public function isEmpty()
305305
*
306306
* @return bool Always returns true
307307
*/
308-
public function isSynchronized()
308+
public function isSynchronized(): bool
309309
{
310310
return true;
311311
}
312312

313313
/**
314314
* Unsupported method.
315315
*/
316-
public function getTransformationFailure()
316+
public function getTransformationFailure(): ?TransformationFailedException
317317
{
318318
return null;
319319
}
@@ -323,7 +323,7 @@ public function getTransformationFailure()
323323
*
324324
* @throws BadMethodCallException
325325
*/
326-
public function initialize()
326+
public function initialize(): static
327327
{
328328
throw new BadMethodCallException('Buttons cannot be initialized. Call initialize() on the root form instead.');
329329
}
@@ -333,7 +333,7 @@ public function initialize()
333333
*
334334
* @throws BadMethodCallException
335335
*/
336-
public function handleRequest(mixed $request = null)
336+
public function handleRequest(mixed $request = null): static
337337
{
338338
throw new BadMethodCallException('Buttons cannot handle requests. Call handleRequest() on the root form instead.');
339339
}
@@ -345,7 +345,7 @@ public function handleRequest(mixed $request = null)
345345
*
346346
* @throws Exception\AlreadySubmittedException if the button has already been submitted
347347
*/
348-
public function submit(array|string|null $submittedData, bool $clearMissing = true)
348+
public function submit(array|string|null $submittedData, bool $clearMissing = true): static
349349
{
350350
if ($this->submitted) {
351351
throw new AlreadySubmittedException('A form can only be submitted once.');
@@ -359,23 +359,23 @@ public function submit(array|string|null $submittedData, bool $clearMissing = tr
359359
/**
360360
* {@inheritdoc}
361361
*/
362-
public function getRoot()
362+
public function getRoot(): FormInterface
363363
{
364364
return $this->parent ? $this->parent->getRoot() : $this;
365365
}
366366

367367
/**
368368
* {@inheritdoc}
369369
*/
370-
public function isRoot()
370+
public function isRoot(): bool
371371
{
372372
return null === $this->parent;
373373
}
374374

375375
/**
376376
* {@inheritdoc}
377377
*/
378-
public function createView(FormView $parent = null)
378+
public function createView(FormView $parent = null): FormView
379379
{
380380
if (null === $parent && $this->parent) {
381381
$parent = $this->parent->createView();

0 commit comments

Comments
 (0)