Skip to content

Commit

Permalink
limit object iterate depth
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1 committed Jan 13, 2021
1 parent 20f101b commit 1a1d97e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Parsers/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Parameters
'name' => '字段',
'desc' => '描述'
];
private static $depth = [];

/**
* @param string $sn Struct Class Name
Expand Down Expand Up @@ -77,6 +78,13 @@ public function __construct(Method $method, $sn, $ns)
$struct = new $cn([], false);
$property = new Property($method, $struct, $p);
if ($property->annotation->isStructType) {
if (!isset(self::$depth[$cn])) {
self::$depth[$cn] = 0;
}
self::$depth[$cn]++;
if (self::$depth[$cn] >= 30) {
break;
}
$this->children[$p->name] = new Parameters($method, $property->annotation->type, $reflect->getNamespaceName());
}
// 4.2 children
Expand Down

0 comments on commit 1a1d97e

Please sign in to comment.