Example #1
0
                $methodBody .= $argumentWriter->call_write_argument($json_spec['domains'], $arg);
            }
            $methodBody .= $argumentWriter->write_bits();
            $methodBody .= 'return array(' . $c['id'] . ", " . $m['id'] . ', $args);';
            $methods .= '/**' . "\n";
            $methods .= ' * @return array' . "\n";
            $methods .= ' */' . "\n";
            $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";
Example #2
0
    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) {
        if (substr($c['name'], 0, 5) == "FRAME") {
            $ret[$c['value']] = $c['name'];
        }