| 1 |
<?php declare(strict_types=1); |
| 2 |
|
| 3 |
/** |
| 4 |
* @license Apache 2.0 |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace OpenApi\Processors; |
| 8 |
|
| 9 |
use OpenApi\Analysis; |
| 10 |
use OpenApi\Annotations as OA; |
| 11 |
|
| 12 |
class CleanUnmerged |
| 13 |
{ |
| 14 |
public function __invoke(Analysis $analysis): void |
| 15 |
{ |
| 16 |
$split = $analysis->split(); |
| 17 |
$merged = $split->merged->annotations; |
| 18 |
$unmerged = $split->unmerged->annotations; |
| 19 |
|
| 20 |
/** @var OA\AbstractAnnotation $annotation */ |
| 21 |
foreach ($analysis->annotations as $annotation) { |
| 22 |
if (property_exists($annotation, '_unmerged')) { |
| 23 |
foreach ($annotation->_unmerged as $ii => $item) { |
| 24 |
if ($merged->offsetExists($item)) { |
| 25 |
unset($annotation->_unmerged[$ii]); // Property was merged |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
$analysis->openapi->_unmerged = []; |
| 31 |
foreach ($unmerged as $annotation) { |
| 32 |
$analysis->openapi->_unmerged[] = $annotation; |
| 33 |
} |
| 34 |
} |
| 35 |
} |