$out .= "{\n\n"; $out .= indent($properties) . "\n"; $out .= "}\n"; file_put_contents(__DIR__ . '/../PhpAmqpLib/Wire/Constants' . protocol_version($json_spec) . '.php', $out); function method_waits($json_spec) { $ret = array(); foreach ($json_spec['classes'] as $c) { foreach ($c['methods'] as $m) { $ret[$c['name'] . '.' . to_snake_case($m['name'])] = $c['id'] . "," . $m['id']; } } return export_property($ret); } $classBody = ''; $classBody .= "protected \$wait = " . method_waits($json_spec) . ";\n\n\n\n"; $classBody .= 'public function get_wait($method)' . "\n{\n"; $classBody .= indent('return $this->wait[$method];') . "\n"; $classBody .= "}\n"; $out = '<?php' . "\n\n"; $out .= '/* This file was autogenerated by spec/parser.php - Do not modify */' . "\n\n"; $out .= 'namespace PhpAmqpLib\\Helper\\Protocol;' . "\n\n"; $out .= "class Wait" . protocol_version($json_spec) . "\n"; $out .= "{\n\n"; $out .= indent($classBody) . "\n"; $out .= "}\n"; file_put_contents(__DIR__ . '/../PhpAmqpLib/Helper/Protocol/Wait' . protocol_version($json_spec) . '.php', $out); function method_map($json_spec) { $ret = array(); $special_map = array('60,30' => 'basic_cancel_from_server', '60,80' => 'basic_ack_from_server', '60,120' => 'basic_nack_from_server');
function method_waits($json_spec) { $ret = array(); foreach ($json_spec['classes'] as $c) { foreach ($c['methods'] as $m) { $ret[$c['name'] . '.' . to_snake_case($m['name'])] = $c['id'] . "," . $m['id']; } } return var_export($ret, true); } $out = "<?php\n\n"; $out .= "/* This file was autogenerated by spec/parser.php - Do not modify */\n\n"; $out .= "namespace PhpAmqpLib\\Helper\\Protocol;\n\n"; $out .= "class Wait" . protocol_version($json_spec) . "\n"; $out .= "{\n"; $out .= "\tprotected \$wait = " . method_waits($json_spec) . ";\n\n"; $out .= "\tpublic function get_wait(\$method) {\n"; $out .= "\t\t return \$this->wait[\$method];\n"; $out .= "\t}\n"; $out .= "}\n"; file_put_contents(__DIR__ . '/../PhpAmqpLib/Helper/Protocol/Wait' . protocol_version($json_spec) . '.php', $out); function method_map($json_spec) { $ret = array(); foreach ($json_spec['classes'] as $c) { foreach ($c['methods'] as $m) { $ret[$c['id'] . "," . $m['id']] = $c['name'] . '_' . to_snake_case($m['name']); } } return var_export($ret, true); }