$out .= "class Protocol" . protocol_version($json_spec) . "\n"; $out .= "{\n"; foreach ($json_spec['classes'] as $c) { foreach ($c['methods'] as $m) { if ($m['id'] % 10 == 0) { $out .= "\n\tpublic function " . method_name($c['name'], $m['name']) . "("; $out .= add_method_arguments($m['arguments']); $out .= ") {\n"; $out .= "\t\t\$args = new AMQPWriter();\n"; foreach ($m['arguments'] as $arg) { $out .= call_write_argument($json_spec['domains'], $arg); } $out .= "\t\treturn array(" . $c['id'] . ", " . $m['id'] . ", \$args);\n"; $out .= "\t}\n"; } else { $out .= "\n\tpublic static function " . method_name($c['name'], $m['name']) . "(\$args) {\n"; $out .= "\t\t\$ret = array();\n"; foreach ($m['arguments'] as $arg) { $out .= "\t\t\$ret[] = " . call_read_argument($json_spec['domains'], $arg); } $out .= "\t\treturn \$ret;\n"; $out .= "\t}\n"; } } } $out .= "}\n"; file_put_contents(__DIR__ . '/../PhpAmqpLib/Helper/Protocol/Protocol' . protocol_version($json_spec) . '.php', $out); function frame_types($json_spec) { $ret = array(); foreach ($json_spec['constants'] as $c) {
$methods .= 'public function ' . method_name($c['name'], $m['name']) . "("; $methods .= add_method_arguments($m['arguments']); $methods .= ")\n{\n"; $methods .= indent($methodBody) . "\n"; $methods .= "}\n"; } else { $methodBody = '$ret = array();' . "\n"; foreach ($m['arguments'] as $arg) { $methodBody .= '$ret[] = ' . call_read_argument($json_spec['domains'], $arg); } $methodBody .= 'return $ret;'; $methods .= '/**' . "\n"; $methods .= ' * @param AMQPReader $args' . "\n"; $methods .= ' * @return array' . "\n"; $methods .= ' */' . "\n"; $methods .= 'public static function ' . method_name($c['name'], $m['name']) . '($args)' . "\n{\n"; $methods .= indent($methodBody) . "\n"; $methods .= "}\n"; } $methods .= "\n\n"; } } $out .= indent(rtrim($methods)) . "\n\n"; $out .= "}\n"; file_put_contents(__DIR__ . '/../PhpAmqpLib/Helper/Protocol/Protocol' . protocol_version($json_spec) . '.php', $out); function export_property($ret) { if (!is_array($ret)) { return var_export($ret, true); } $code = '';
$methods .= 'public function ' . method_name($c['name'], $m['name']) . "("; $methods .= add_method_arguments($m['arguments']); $methods .= ")\n{\n"; $methods .= indent($methodBody) . "\n"; $methods .= "}\n"; } else { $methodBody = '$response = array();' . "\n"; foreach ($m['arguments'] as $arg) { $methodBody .= '$response[] = ' . call_read_argument($json_spec['domains'], $arg); } $methodBody .= 'return $response;'; $methods .= '/**' . "\n"; $methods .= ' * @param AMQPReader $reader' . "\n"; $methods .= ' * @return array' . "\n"; $methods .= ' */' . "\n"; $methods .= 'public static function ' . method_name($c['name'], $m['name']) . '(AMQPReader $reader)' . "\n{\n"; $methods .= indent($methodBody) . "\n"; $methods .= "}\n"; } } } $out .= indent(rtrim($methods)) . "\n"; $out .= "}\n"; file_put_contents(__DIR__ . '/../PhpAmqpLib/Helper/Protocol/Protocol' . protocol_version($json_spec) . '.php', $out); function export_property($ret) { if (!is_array($ret)) { return var_export($ret, true); } $code = ''; foreach ($ret as $key => $value) {