public function testObjectLists() { $actual = Output::getList(4, true, true, Output::getObject(array('read' => Output::getList(0, true, true, Output::getValue(1, false, Output::TYPE_INTEGER)), 'unread' => Output::getList(2, true, true, Output::getValue(3, false, Output::TYPE_INTEGER))))); $expected = <<<'EOS' foreach ($input as $row) { if (isset($row[4])) { if (isset($row[0])) { $output[$row[4]]['read'][$row[0]] = (integer)$row[1]; } if (isset($row[2])) { $output[$row[4]]['unread'][$row[2]] = (integer)$row[3]; } } } $output = isset($output) ? array_values($output) : array(); foreach ($output as &$x0) { $x0['read'] = isset($x0['read']) ? array_values($x0['read']) : array(); $x0['unread'] = isset($x0['unread']) ? array_values($x0['unread']) : array(); } EOS; $this->verify($expected, $actual); }
private function getFunctionSequence($topLevelFunction, $id, $hasZero) { $idAlias = null; if ($topLevelFunction === 'get') { $idAlias = $this->mysql->addValue($this->context, $id); } $this->getOptionalFilterFunction(); $this->getOptionalSortFunction(); $this->getOptionalSliceFunction(); if (!isset($this->request) || count($this->request) === 0) { throw CompilerException::badGetArgument($this->request); } if ($this->readFork()) { return $this->getFunctionSequence($topLevelFunction, null, null); } $this->request = reset($this->request); if ($this->readGet()) { $this->phpOutput = Output::getList($idAlias, $hasZero, true, $this->phpOutput); return true; } if ($this->readCount()) { return true; } if ($this->readParameterizedAggregator($topLevelFunction)) { return true; } throw CompilerException::invalidMethodSequence($this->request); }