2020-03-02 16:14:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
2022-03-15 18:05:33 +08:00
|
|
|
declare(strict_types=1);
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
namespace ZM\Annotation;
|
|
|
|
|
|
2022-04-03 01:47:38 +08:00
|
|
|
use ArrayIterator;
|
2020-03-02 16:14:20 +08:00
|
|
|
use Closure;
|
2022-04-03 01:47:38 +08:00
|
|
|
use IteratorAggregate;
|
|
|
|
|
use Traversable;
|
2020-03-02 16:14:20 +08:00
|
|
|
|
2022-04-03 01:47:38 +08:00
|
|
|
abstract class AnnotationBase implements IteratorAggregate
|
2020-03-02 16:14:20 +08:00
|
|
|
{
|
2022-03-20 01:53:36 +08:00
|
|
|
public $method = '';
|
2020-03-02 16:14:20 +08:00
|
|
|
|
2022-03-20 01:53:36 +08:00
|
|
|
public $class = '';
|
2020-03-02 16:14:20 +08:00
|
|
|
|
2022-03-15 18:05:33 +08:00
|
|
|
public function __toString()
|
|
|
|
|
{
|
|
|
|
|
$str = __CLASS__ . ': ';
|
2020-03-02 16:14:20 +08:00
|
|
|
foreach ($this as $k => $v) {
|
2022-03-15 18:05:33 +08:00
|
|
|
$str .= "\n\t" . $k . ' => ';
|
|
|
|
|
if (is_string($v)) {
|
|
|
|
|
$str .= "\"{$v}\"";
|
|
|
|
|
} elseif (is_numeric($v)) {
|
|
|
|
|
$str .= $v;
|
|
|
|
|
} elseif (is_bool($v)) {
|
|
|
|
|
$str .= ($v ? 'TRUE' : 'FALSE');
|
|
|
|
|
} elseif (is_array($v)) {
|
|
|
|
|
$str .= json_encode($v, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
} elseif ($v instanceof Closure) {
|
|
|
|
|
$str .= '@AnonymousFunction';
|
|
|
|
|
} elseif (is_null($v)) {
|
|
|
|
|
$str .= 'NULL';
|
|
|
|
|
} else {
|
|
|
|
|
$str .= '@Unknown';
|
|
|
|
|
}
|
2020-03-02 16:14:20 +08:00
|
|
|
}
|
|
|
|
|
return $str;
|
|
|
|
|
}
|
2022-04-03 01:47:38 +08:00
|
|
|
|
|
|
|
|
public function getIterator(): Traversable
|
|
|
|
|
{
|
|
|
|
|
return new ArrayIterator($this);
|
|
|
|
|
}
|
2022-03-15 18:05:33 +08:00
|
|
|
}
|