当前位置: 首页>>代码示例>>PHP>>正文


PHP Reflection::reflectFunction方法代码示例

本文整理汇总了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;
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:34,代码来源:AutoDiscover.php

示例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;
 }
开发者ID:zendframework,项目名称:zend-json-server,代码行数:42,代码来源:Server.php

示例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);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:AutoDiscover.php

示例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;
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:45,代码来源:Server.php

示例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);
     }
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:35,代码来源:Server.php

示例6: testReflectFunction2

 /**
  * reflectFunction() test; test namespaces
  */
 public function testReflectFunction2()
 {
     $reflection = Reflection::reflectFunction('ZendTest\\Server\\reflectionTestFunction', false, 'zsr');
     $this->assertEquals('zsr', $reflection->getNamespace());
 }
开发者ID:rexmac,项目名称:zf2,代码行数:8,代码来源:ReflectionTest.php

示例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;
    }
开发者ID:necrogami,项目名称:zf2,代码行数:34,代码来源:Server.php


注:本文中的Zend\Server\Reflection::reflectFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。