Skip to content

Commit

Permalink
Merge pull request #19 from uniondrug/nested-object-bug-fix
Browse files Browse the repository at this point in the history
limit object iterate depth
  • Loading branch information
fuyibing authored Jan 14, 2021
2 parents 20f101b + 1a1d97e commit d2d63c6
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 d2d63c6

Please sign in to comment.