You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1004 B
50 lines
1004 B
12 months ago
|
<?php
|
||
|
|
||
|
namespace AlibabaCloud\Tea;
|
||
|
|
||
|
use ArrayIterator;
|
||
|
use IteratorAggregate;
|
||
|
use ReflectionObject;
|
||
|
use Traversable;
|
||
|
|
||
|
/**
|
||
|
* Class Parameter.
|
||
|
*/
|
||
|
abstract class Parameter implements IteratorAggregate
|
||
|
{
|
||
|
/**
|
||
|
* @return ArrayIterator|Traversable
|
||
|
*/
|
||
|
public function getIterator()
|
||
|
{
|
||
|
return new ArrayIterator($this->toArray());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array
|
||
|
*/
|
||
|
public function getRealParameters()
|
||
|
{
|
||
|
$array = [];
|
||
|
$obj = new ReflectionObject($this);
|
||
|
$properties = $obj->getProperties();
|
||
|
|
||
|
foreach ($properties as $property) {
|
||
|
$docComment = $property->getDocComment();
|
||
|
$key = trim(Helper::findFromString($docComment, '@real', "\n"));
|
||
|
$value = $property->getValue($this);
|
||
|
$array[$key] = $value;
|
||
|
}
|
||
|
|
||
|
return $array;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return array
|
||
|
*/
|
||
|
public function toArray()
|
||
|
{
|
||
|
return $this->getRealParameters();
|
||
|
}
|
||
|
}
|