13
13
14
14
use Symfony \Component \Form \Exception \AlreadySubmittedException ;
15
15
use Symfony \Component \Form \Exception \BadMethodCallException ;
16
+ use Symfony \Component \Form \Exception \TransformationFailedException ;
17
+ use Symfony \Component \PropertyAccess \PropertyPathInterface ;
16
18
17
19
/**
18
20
* A form button.
@@ -82,7 +84,7 @@ public function offsetUnset(mixed $offset): void
82
84
/**
83
85
* {@inheritdoc}
84
86
*/
85
- public function setParent (FormInterface $ parent = null )
87
+ public function setParent (FormInterface $ parent = null ): static
86
88
{
87
89
if ($ this ->submitted ) {
88
90
throw new AlreadySubmittedException ('You cannot set the parent of a submitted button. ' );
@@ -96,7 +98,7 @@ public function setParent(FormInterface $parent = null)
96
98
/**
97
99
* {@inheritdoc}
98
100
*/
99
- public function getParent ()
101
+ public function getParent (): ? FormInterface
100
102
{
101
103
return $ this ->parent ;
102
104
}
@@ -108,7 +110,7 @@ public function getParent()
108
110
*
109
111
* @throws BadMethodCallException
110
112
*/
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
112
114
{
113
115
throw new BadMethodCallException ('Buttons cannot have children. ' );
114
116
}
@@ -120,7 +122,7 @@ public function add(string|FormInterface $child, string $type = null, array $opt
120
122
*
121
123
* @throws BadMethodCallException
122
124
*/
123
- public function get (string $ name )
125
+ public function get (string $ name ): FormInterface
124
126
{
125
127
throw new BadMethodCallException ('Buttons cannot have children. ' );
126
128
}
@@ -130,7 +132,7 @@ public function get(string $name)
130
132
*
131
133
* @return bool Always returns false
132
134
*/
133
- public function has (string $ name )
135
+ public function has (string $ name ): bool
134
136
{
135
137
return false ;
136
138
}
@@ -142,23 +144,23 @@ public function has(string $name)
142
144
*
143
145
* @throws BadMethodCallException
144
146
*/
145
- public function remove (string $ name )
147
+ public function remove (string $ name ): static
146
148
{
147
149
throw new BadMethodCallException ('Buttons cannot have children. ' );
148
150
}
149
151
150
152
/**
151
153
* {@inheritdoc}
152
154
*/
153
- public function all ()
155
+ public function all (): array
154
156
{
155
157
return [];
156
158
}
157
159
158
160
/**
159
161
* {@inheritdoc}
160
162
*/
161
- public function getErrors (bool $ deep = false , bool $ flatten = true )
163
+ public function getErrors (bool $ deep = false , bool $ flatten = true ): FormErrorIterator
162
164
{
163
165
return new FormErrorIterator ($ this , []);
164
166
}
@@ -170,7 +172,7 @@ public function getErrors(bool $deep = false, bool $flatten = true)
170
172
*
171
173
* @return $this
172
174
*/
173
- public function setData (mixed $ modelData )
175
+ public function setData (mixed $ modelData ): static
174
176
{
175
177
// no-op, called during initialization of the form tree
176
178
return $ this ;
@@ -179,23 +181,23 @@ public function setData(mixed $modelData)
179
181
/**
180
182
* Unsupported method.
181
183
*/
182
- public function getData ()
184
+ public function getData (): mixed
183
185
{
184
186
return null ;
185
187
}
186
188
187
189
/**
188
190
* Unsupported method.
189
191
*/
190
- public function getNormData ()
192
+ public function getNormData (): mixed
191
193
{
192
194
return null ;
193
195
}
194
196
195
197
/**
196
198
* Unsupported method.
197
199
*/
198
- public function getViewData ()
200
+ public function getViewData (): mixed
199
201
{
200
202
return null ;
201
203
}
@@ -205,17 +207,15 @@ public function getViewData()
205
207
*
206
208
* @return array Always returns an empty array
207
209
*/
208
- public function getExtraData ()
210
+ public function getExtraData (): array
209
211
{
210
212
return [];
211
213
}
212
214
213
215
/**
214
216
* Returns the button's configuration.
215
- *
216
- * @return FormConfigInterface
217
217
*/
218
- public function getConfig ()
218
+ public function getConfig (): FormConfigInterface
219
219
{
220
220
return $ this ->config ;
221
221
}
@@ -225,7 +225,7 @@ public function getConfig()
225
225
*
226
226
* @return bool true if the button was submitted
227
227
*/
228
- public function isSubmitted ()
228
+ public function isSubmitted (): bool
229
229
{
230
230
return $ this ->submitted ;
231
231
}
@@ -235,15 +235,15 @@ public function isSubmitted()
235
235
*
236
236
* @return string The name of the button
237
237
*/
238
- public function getName ()
238
+ public function getName (): string
239
239
{
240
240
return $ this ->config ->getName ();
241
241
}
242
242
243
243
/**
244
244
* Unsupported method.
245
245
*/
246
- public function getPropertyPath ()
246
+ public function getPropertyPath (): ? PropertyPathInterface
247
247
{
248
248
return null ;
249
249
}
@@ -253,7 +253,7 @@ public function getPropertyPath()
253
253
*
254
254
* @throws BadMethodCallException
255
255
*/
256
- public function addError (FormError $ error )
256
+ public function addError (FormError $ error ): static
257
257
{
258
258
throw new BadMethodCallException ('Buttons cannot have errors. ' );
259
259
}
@@ -263,7 +263,7 @@ public function addError(FormError $error)
263
263
*
264
264
* @return bool Always returns true
265
265
*/
266
- public function isValid ()
266
+ public function isValid (): bool
267
267
{
268
268
return true ;
269
269
}
@@ -273,15 +273,15 @@ public function isValid()
273
273
*
274
274
* @return bool Always returns false
275
275
*/
276
- public function isRequired ()
276
+ public function isRequired (): bool
277
277
{
278
278
return false ;
279
279
}
280
280
281
281
/**
282
282
* {@inheritdoc}
283
283
*/
284
- public function isDisabled ()
284
+ public function isDisabled (): bool
285
285
{
286
286
if ($ this ->parent && $ this ->parent ->isDisabled ()) {
287
287
return true ;
@@ -295,7 +295,7 @@ public function isDisabled()
295
295
*
296
296
* @return bool Always returns true
297
297
*/
298
- public function isEmpty ()
298
+ public function isEmpty (): bool
299
299
{
300
300
return true ;
301
301
}
@@ -305,15 +305,15 @@ public function isEmpty()
305
305
*
306
306
* @return bool Always returns true
307
307
*/
308
- public function isSynchronized ()
308
+ public function isSynchronized (): bool
309
309
{
310
310
return true ;
311
311
}
312
312
313
313
/**
314
314
* Unsupported method.
315
315
*/
316
- public function getTransformationFailure ()
316
+ public function getTransformationFailure (): ? TransformationFailedException
317
317
{
318
318
return null ;
319
319
}
@@ -323,7 +323,7 @@ public function getTransformationFailure()
323
323
*
324
324
* @throws BadMethodCallException
325
325
*/
326
- public function initialize ()
326
+ public function initialize (): static
327
327
{
328
328
throw new BadMethodCallException ('Buttons cannot be initialized. Call initialize() on the root form instead. ' );
329
329
}
@@ -333,7 +333,7 @@ public function initialize()
333
333
*
334
334
* @throws BadMethodCallException
335
335
*/
336
- public function handleRequest (mixed $ request = null )
336
+ public function handleRequest (mixed $ request = null ): static
337
337
{
338
338
throw new BadMethodCallException ('Buttons cannot handle requests. Call handleRequest() on the root form instead. ' );
339
339
}
@@ -345,7 +345,7 @@ public function handleRequest(mixed $request = null)
345
345
*
346
346
* @throws Exception\AlreadySubmittedException if the button has already been submitted
347
347
*/
348
- public function submit (array |string |null $ submittedData , bool $ clearMissing = true )
348
+ public function submit (array |string |null $ submittedData , bool $ clearMissing = true ): static
349
349
{
350
350
if ($ this ->submitted ) {
351
351
throw new AlreadySubmittedException ('A form can only be submitted once. ' );
@@ -359,23 +359,23 @@ public function submit(array|string|null $submittedData, bool $clearMissing = tr
359
359
/**
360
360
* {@inheritdoc}
361
361
*/
362
- public function getRoot ()
362
+ public function getRoot (): FormInterface
363
363
{
364
364
return $ this ->parent ? $ this ->parent ->getRoot () : $ this ;
365
365
}
366
366
367
367
/**
368
368
* {@inheritdoc}
369
369
*/
370
- public function isRoot ()
370
+ public function isRoot (): bool
371
371
{
372
372
return null === $ this ->parent ;
373
373
}
374
374
375
375
/**
376
376
* {@inheritdoc}
377
377
*/
378
- public function createView (FormView $ parent = null )
378
+ public function createView (FormView $ parent = null ): FormView
379
379
{
380
380
if (null === $ parent && $ this ->parent ) {
381
381
$ parent = $ this ->parent ->createView ();
0 commit comments