AggregationBuilderExecuteToGetAggregationRector

Replace deprecated aggregation Builder::execute() with getAggregation()->getIterator()

-$result = $builder->execute(['allowDiskUse' => true]);
+$result = $builder->getAggregation(['allowDiskUse' => true])->getIterator();

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Doctrine\Odm22\Rector\MethodCall\AggregationBuilderExecuteToGetAggregationRector;

return RectorConfig::configure()
    ->withRules([
        AggregationBuilderExecuteToGetAggregationRector::class,
    ]);
PACKAGE:  doctrine/mongodb-odm >=2.2 <5.0