截流自动化的商城平台
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.

Parameter.php 1004B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace AlibabaCloud\Tea;
  3. use ArrayIterator;
  4. use IteratorAggregate;
  5. use ReflectionObject;
  6. use Traversable;
  7. /**
  8. * Class Parameter.
  9. */
  10. abstract class Parameter implements IteratorAggregate
  11. {
  12. /**
  13. * @return ArrayIterator|Traversable
  14. */
  15. public function getIterator()
  16. {
  17. return new ArrayIterator($this->toArray());
  18. }
  19. /**
  20. * @return array
  21. */
  22. public function getRealParameters()
  23. {
  24. $array = [];
  25. $obj = new ReflectionObject($this);
  26. $properties = $obj->getProperties();
  27. foreach ($properties as $property) {
  28. $docComment = $property->getDocComment();
  29. $key = trim(Helper::findFromString($docComment, '@real', "\n"));
  30. $value = $property->getValue($this);
  31. $array[$key] = $value;
  32. }
  33. return $array;
  34. }
  35. /**
  36. * @return array
  37. */
  38. public function toArray()
  39. {
  40. return $this->getRealParameters();
  41. }
  42. }