本文整理汇总了PHP中Zend\Server\Reflection::reflectFunction方法的典型用法代码示例。如果您正苦于以下问题:PHP Reflection::reflectFunction方法的具体用法?PHP Reflection::reflectFunction怎么用?PHP Reflection::reflectFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Server\Reflection
的用法示例。
在下文中一共展示了Reflection::reflectFunction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addFunction
/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @param string $namespace Function namespace - Not Used
*/
public function addFunction($function, $namespace = '')
{
static $port;
static $operation;
static $binding;
if (!is_array($function)) {
$function = (array) $function;
}
$uri = $this->getUri();
if (!$this->_wsdl instanceof Wsdl) {
$parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
$name = $parts[0];
$wsdl = new Wsdl($name, $uri, $this->_strategy);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($name . 'Port');
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
$wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
} else {
$wsdl = $this->_wsdl;
}
foreach ($function as $func) {
$method = $this->_reflection->reflectFunction($func);
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
}
示例2: addFunction
/**
* Attach a function or callback to the server.
*
* @param callable $function Valid PHP callback
* @param string $namespace Ignored
* @return Server
* @throws Exception\InvalidArgumentException If function invalid or not callable.
*/
public function addFunction($function, $namespace = '')
{
if (!is_callable($function)) {
throw new Exception\InvalidArgumentException(sprintf('%s expects the first argument to be callable; received %s', __METHOD__, is_object($function) ? get_class($function) : gettype($function)));
}
$argv = null;
if (2 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 2);
}
$class = null;
if (!is_array($function)) {
$method = Reflection::reflectFunction($function, $argv, $namespace);
} else {
$class = array_shift($function);
$action = array_shift($function);
$reflection = Reflection::reflectClass($class, $argv, $namespace);
$methods = $reflection->getMethods();
$found = false;
foreach ($methods as $method) {
if ($action == $method->getName()) {
$found = true;
break;
}
}
if (!$found) {
$this->fault('Method not found', Error::ERROR_INVALID_METHOD);
return $this;
}
}
$definition = $this->_buildSignature($method, $class);
$this->addMethodServiceMap($definition);
return $this;
}
示例3: _generateFunctions
/**
* Generate the WSDL for a set of functions.
*
* @return Zend\Soap\Wsdl
*/
protected function _generateFunctions()
{
$methods = array();
foreach (array_unique($this->_functions) as $func) {
$methods[] = $this->_reflection->reflectFunction($func);
}
return $this->_generateWsdl($methods);
}
示例4: addFunction
/**
* Attach a function or callback to the server
*
* @param string|array|callable $function Valid PHP callback
* @param string $namespace Ignored
* @throws Exception\InvalidArgumentException if function invalid or not callable
* @return Server
*/
public function addFunction($function, $namespace = '')
{
if (!is_string($function) && (!is_array($function) || 2 > count($function))) {
throw new Exception\InvalidArgumentException('Unable to attach function; invalid');
}
if (!is_callable($function)) {
throw new Exception\InvalidArgumentException('Unable to attach function; does not exist');
}
$argv = null;
if (2 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 2);
}
$class = null;
if (is_string($function)) {
$method = Reflection::reflectFunction($function, $argv, $namespace);
} else {
$class = array_shift($function);
$action = array_shift($function);
$reflection = Reflection::reflectClass($class, $argv, $namespace);
$methods = $reflection->getMethods();
$found = false;
foreach ($methods as $method) {
if ($action == $method->getName()) {
$found = true;
break;
}
}
if (!$found) {
$this->fault('Method not found', Error::ERROR_INVALID_METHOD);
return $this;
}
}
$definition = $this->_buildSignature($method, $class);
$this->_addMethodServiceMap($definition);
return $this;
}
示例5: addFunction
/**
* Attach a callback as an XMLRPC method
*
* Attaches a callback as an XMLRPC method, prefixing the XMLRPC method name
* with $namespace, if provided. Reflection is done on the callback's
* docblock to create the methodHelp for the XMLRPC method.
*
* Additional arguments to pass to the function at dispatch may be passed;
* any arguments following the namespace will be aggregated and passed at
* dispatch time.
*
* @param string|array|callable $function Valid callback
* @param string $namespace Optional namespace prefix
* @return void
* @throws \Zend\XmlRpc\Exception\InvalidArgumentException
*/
public function addFunction($function, $namespace = '')
{
if (!is_string($function) && !is_array($function)) {
throw new Server\Exception\InvalidArgumentException('Unable to attach function; invalid', 611);
}
$argv = null;
if (2 < func_num_args()) {
$argv = func_get_args();
$argv = array_slice($argv, 2);
}
$function = (array) $function;
foreach ($function as $func) {
if (!is_string($func) || !function_exists($func)) {
throw new Server\Exception\InvalidArgumentException('Unable to attach function; invalid', 611);
}
$reflection = Reflection::reflectFunction($func, $argv, $namespace);
$this->_buildSignature($reflection);
}
}
示例6: testReflectFunction2
/**
* reflectFunction() test; test namespaces
*/
public function testReflectFunction2()
{
$reflection = Reflection::reflectFunction('ZendTest\\Server\\reflectionTestFunction', false, 'zsr');
$this->assertEquals('zsr', $reflection->getNamespace());
}
示例7: addFunction
/**
* Attach a function to the server
*
* Additional arguments to pass to the function at dispatch may be passed;
* any arguments following the namespace will be aggregated and passed at
* dispatch time.
*
* @param string|array $function Valid callback
* @param string $namespace Optional namespace prefix
* @return Server
* @throws Exception\InvalidArgumentException
*/
public function addFunction($function, $namespace = '')
{
if (!is_string($function) && !is_array($function)) {
throw new Exception\InvalidArgumentException('Unable to attach function');
}
$argv = null;
if (2 < func_num_args()) {
$argv = array_slice(func_get_args(), 2);
}
$function = (array) $function;
foreach ($function as $func) {
if (!is_string($func) || !function_exists($func)) {
throw new Exception\InvalidArgumentException('Unable to attach function');
}
$this->_methods[] = Reflection::reflectFunction($func, $argv, $namespace);
}
$this->_buildDispatchTable();
return $this;
}