@@ -181,8 +181,12 @@ public function getUntrustedValues(string|object|null $returnType = null, ?array
181181 }
182182
183183
184- /** @deprecated use getUntrustedValues() */
185- public function getUnsafeValues ($ returnType , ?array $ controls = null )
184+ /**
185+ * @deprecated use getUntrustedValues()
186+ * @param ?list<Control> $controls
187+ * @return object|array<string, mixed>
188+ */
189+ public function getUnsafeValues (string |object |null $ returnType , ?array $ controls = null ): object |array
186190 {
187191 return $ this ->getUntrustedValues ($ returnType , $ controls );
188192 }
@@ -303,7 +307,52 @@ public function addComponent(
303307 */
304308 public function getControls (): \Iterator
305309 {
306- return $ this ->getComponents (true , Control::class);
310+ return new class ($ this ->getComponentTree ()) implements \Iterator {
311+ /** @var Controls\BaseControl[] */
312+ private array $ controls = [];
313+ private int $ position = 0 ;
314+
315+
316+ /** @param list<Nette\ComponentModel\IComponent> $tree */
317+ public function __construct (array $ tree )
318+ {
319+ foreach ($ tree as $ component ) {
320+ if ($ component instanceof Controls \BaseControl) {
321+ $ this ->controls [] = $ component ;
322+ }
323+ }
324+ }
325+
326+
327+ public function current (): Controls \BaseControl
328+ {
329+ return $ this ->controls [$ this ->position ];
330+ }
331+
332+
333+ public function key (): string
334+ {
335+ return $ this ->controls [$ this ->position ]->getName ();
336+ }
337+
338+
339+ public function next (): void
340+ {
341+ ++$ this ->position ;
342+ }
343+
344+
345+ public function rewind (): void
346+ {
347+ $ this ->position = 0 ;
348+ }
349+
350+
351+ public function valid (): bool
352+ {
353+ return isset ($ this ->controls [$ this ->position ]);
354+ }
355+ };
307356 }
308357
309358
0 commit comments