本文整理汇总了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');
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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";
}
示例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==
示例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);
}
示例10: ReflectionParameterTest
<?php
function ReflectionParameterTest($test, $test2 = null)
{
echo $test;
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach ($reflect->getParameters() as $key => $value) {
ReflectionParameter::export();
}
?>
==DONE==