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


PHP ReflectionParameter::export方法代码示例

本文整理汇总了PHP中ReflectionParameter::export方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionParameter::export方法的具体用法?PHP ReflectionParameter::export怎么用?PHP ReflectionParameter::export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionParameter的用法示例。


在下文中一共展示了ReflectionParameter::export方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ReflectionParameterTest

<?php

function ReflectionParameterTest($test, $test2 = null)
{
    echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
$params = $reflect->getParameters();
foreach ($params as $key => $value) {
    ReflectionParameter::export('ReflectionParameterTest', 'incorrect_parameter');
}
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:ReflectionParameter_export_error3.php

示例2: testExport

 /**
  * @dataProvider getFunctionNamesAndParamKeys
  */
 public function testExport($functionName = null, $paramKey = null)
 {
     if (strpos($functionName, '::') !== false) {
         $function = explode('::', $functionName);
     } else {
         $function = $functionName;
     }
     self::assertEquals(ReflectionParameter::export($function, $paramKey, true), ezcReflectionParameter::export($function, $paramKey, true));
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:12,代码来源:parameter_test.php

示例3: export

 /**
  * This method can be used to export a single function or method parameter.
  *
  * @param string|array   $function  Name of the parent function.
  * @param string|integer $parameter Name or offset of the export parameter.
  * @param boolean        $return    Should this method return the export.
  *
  * @return string|null
  */
 public static function export($function, $parameter, $return = false)
 {
     if (is_callable($function) === false) {
         throw new ReflectionException(__METHOD__ . '() is not supported.');
     }
     return parent::export($function, $parameter, $return);
 }
开发者ID:rouffj,项目名称:pdepend,代码行数:16,代码来源:Parameter.php

示例4: testToString

 /**
  * Tests export.
  */
 public function testToString()
 {
     $tests = array('declaringFunction', 'reference', 'noReference', 'class', 'noClass', 'array', 'noArray', 'nullClass', 'noNullClass', 'nullArray', 'noNullArray', 'noOptional', 'optionalNull', 'optionalTrue', 'optionalFalse', 'optionalArray', 'optionalString', 'optionalInteger', 'optionalFloat', 'optionalConstant');
     foreach ($tests as $test) {
         $rfl = $this->getParameterReflection($test);
         $this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
         $this->assertSame(InternalReflectionParameter::export($this->getFunctionName($test), 0, true), ReflectionParameter::export($this->getBroker(), $this->getFunctionName($test), 0, true));
         // Test loading from a string
         $rfl = $this->getParameterReflection($test, true);
         $this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
     }
     $this->assertSame(InternalReflectionParameter::export('strpos', 0, true), ReflectionParameter::export($this->getBroker(), 'strpos', 0, true));
 }
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:16,代码来源:ReflectionParameterTest.php

示例5: export

 /**
  * Exports a reflection object.
  *
  * Returns the output if TRUE is specified for $return, printing it otherwise.
  * This is purely a wrapper method, which calls the corresponding method of
  * the parent class.
  * @param mixed $function Function or Method
  * @param mixed $parameter Parameter
  * @param boolean $return
  *        Whether to return (TRUE) or print (FALSE) the output
  * @return mixed
  */
 public static function export($function, $parameter, $return = false)
 {
     return parent::export($function, $parameter, $return);
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:16,代码来源:parameter.php

示例6: getParamType

 /**
  * Tries to find out if the type of the given parameter. Will
  * return empty string if not possible.
  *
  * @example
  * <code>
  *  <?php
  *      $reflector = new \\ReflectionClass('MyClass');
  *      foreach($reflector->getMethods() as $method ) {
  *          foreach($method->getParameters() as $param) {
  *              $name = $param->getName();
  *              $type = Reflector::getParamType($param);
  *              printf("%s = %s\n", $name, $type);
  *          }
  *      }
  * </code>
  *
  * @param \ReflectionParameter $refParam
  * @return string
  */
 static function getParamType(\ReflectionParameter $refParam)
 {
     $export = \ReflectionParameter::export(array($refParam->getDeclaringClass()->name, $refParam->getDeclaringFunction()->name), $refParam->name, true);
     $export = str_replace(' or NULL', '', $export);
     $type = preg_replace('/.*?([\\w\\\\]+)\\s+\\$' . current(explode('=', $refParam->name)) . '.*/', '\\1', $export);
     if (strpos($type, 'Parameter ') !== false) {
         return '';
     }
     if ($type != 'array' && strpos($type, '\\') !== 0) {
         $type = '\\' . $type;
     }
     return $type;
 }
开发者ID:jarednova,项目名称:PHP-Markdown-Documentation-Generator,代码行数:33,代码来源:Reflector.php

示例7: ReflectionParameterTest

<?php

function ReflectionParameterTest($test, $test2 = null)
{
    echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
$params = $reflect->getParameters();
try {
    foreach ($params as $key => $value) {
        ReflectionParameter::export($reflect, $key);
    }
} catch (ReflectionException $e) {
    echo $e->getMessage() . "\n";
}
try {
    foreach ($params as $key => $value) {
        ReflectionParameter::export(42, $key);
    }
} catch (ReflectionException $e) {
    echo $e->getMessage() . "\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:22,代码来源:ReflectionParameter_export_error2.php

示例8: ReflectionParameterTest

<?php

function ReflectionParameterTest($test, $test2 = null)
{
    echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach ($reflect->getParameters() as $key => $value) {
    echo ReflectionParameter::export('ReflectionParameterTest', $key);
}
?>
==DONE==
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:ReflectionParameter_export_basic.php

示例9: getPropsAsStringByReflectionMethod

 public static function getPropsAsStringByReflectionMethod(\ReflectionMethod $method, $withoutValues = false)
 {
     $props = array();
     if ($method->getDocComment()) {
         $docComment = new \phpDocumentor\Reflection\DocBlock($method->getDocComment());
         foreach ($docComment->getTags() as $tag) {
             /* @var $tag \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag */
             if ($tag->getName() == "param") {
                 $props[] = self::getInstance()->getValueByType($tag->getType(), $withoutValues);
             }
         }
     } else {
         foreach ($method->getParameters() as $parameter) {
             //                    var_dump($parameter->getDefaultValue());
             //                  var_dump($parameter->getDefaultValueConstantName());
             $param = \ReflectionParameter::export(array($parameter->getDeclaringClass()->name, $parameter->getDeclaringFunction()->name), $parameter->name, true);
             preg_match('/(\\[ )(<)(.*)(>)( )([^\\]=]+)/', $param, $matches);
             if (count($matches) === 7) {
                 $t = explode(" ", trim($matches[6]));
                 if (count($t) === 2) {
                     if (strtolower($t[0]) == "array") {
                         return 'array()';
                     }
                     if (strtolower($t[0]) == "closure") {
                         return 'function(){}';
                     }
                     $props[] = '$this->getMock(\'' . str_replace('\\', '\\\\', $t[0]) . '\')';
                 } else {
                     if ($parameter->isDefaultValueAvailable()) {
                         $props[] = $parameter->getDefaultValue();
                     } else {
                         $props[] = 1;
                     }
                 }
             }
         }
     }
     $props2 = array();
     foreach ($props as $prop2) {
         if ($prop2 != "") {
             $props2[] = $prop2;
         }
     }
     return implode(",", $props2);
 }
开发者ID:basuritas-php,项目名称:phpunitgenerator,代码行数:45,代码来源:Generator.php

示例10: ReflectionParameterTest

<?php

function ReflectionParameterTest($test, $test2 = null)
{
    echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach ($reflect->getParameters() as $key => $value) {
    ReflectionParameter::export();
}
?>
==DONE==
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:ReflectionParameter_export_error.php


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