Skip to content

Commit e62b648

Browse files
NeloopMartin Kruliš
authored andcommitted
Fix: be prepared in scalar-to-array box to empty input scalar
1 parent 9ee4b34 commit e62b648

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/helpers/ExerciseConfig/Pipeline/Box/Boxes/base/ScalarToArrayBox.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public function getDefaultOutputPorts(): array {
9292
* @throws ExerciseConfigException
9393
*/
9494
public function compile(CompilationParams $params): array {
95+
if ($this->getInputPortValue(self::$IN_PORT_KEY)->isEmpty()) {
96+
// pointless usage of box, but hell, we have to be ready for that
97+
$this->getOutputPortValue(self::$OUT_PORT_KEY)->setValue(null);
98+
return [];
99+
}
100+
95101
// will not produce tasks, only convert scalar value into single-item array
96102
$in = $this->getInputPortValue(self::$IN_PORT_KEY)->getValue();
97103
$this->getOutputPortValue(self::$OUT_PORT_KEY)->setValue([ $in ]);

0 commit comments

Comments
 (0)