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.
yanzong/vendor/alibabacloud/tea/src/Parameter.php

50 lines
1.0 KiB

<?php
namespace AlibabaCloud\Tea;
use ArrayIterator;
use IteratorAggregate;
use ReflectionObject;
use Traversable;
/**
* Class Parameter.
*/
abstract class Parameter implements IteratorAggregate
{
/**
* @return ArrayIterator|Traversable
*/
#[\ReturnTypeWillChange]
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();
}
}