Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/Utils/BeanDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,10 @@ public function generateResultIteratorPhpCode(): ?FileGenerator
$tableName = $this->table->getName();

$className = $this->namingStrategy->getResultIteratorClassName($tableName);
$classFullName = $this->resultIteratorNamespace.'\\'.$className;
$baseClassName = $this->namingStrategy->getBaseResultIteratorClassName($tableName);
$beanClassWithoutNameSpace = $this->namingStrategy->getBeanClassName($tableName);
$beanClassName = $this->beanNamespace.'\\'.$beanClassWithoutNameSpace;
$beanClassName = $this->namingStrategy->getBeanClassName($tableName);
$beanClassFullName = $this->beanNamespace.'\\'.$beanClassName;

$file->setDocBlock(new DocBlockGenerator(
<<<EOF
Expand All @@ -1167,14 +1168,27 @@ public function generateResultIteratorPhpCode(): ?FileGenerator
If you need to perform changes, edit the $className class instead!
EOF
));
$class->addUse(ResultIterator::class);

$uses = [ResultIterator::class, $classFullName, $beanClassFullName];
sort($uses);
foreach ($uses as $use) {
$class->addUse($use);
}

$class->setName($baseClassName);
$class->setExtendedClass(ResultIterator::class);

$class->setDocBlock((new DocBlockGenerator(
"The $baseClassName class will iterate over results of $beanClassWithoutNameSpace class.",
"The $baseClassName class will iterate over results of $beanClassName class.",
null,
[new Tag\MethodTag('getIterator', ['\\' . $beanClassName . '[]'])]
[
new Tag\MethodTag('first', [$beanClassName]),
new Tag\MethodTag('offsetGet', [$beanClassName]),
new Tag\MethodTag('getIterator', [$beanClassName . '[]']),
new Tag\MethodTag('toArray', [$beanClassName . '[]']),
new Tag\MethodTag('withOrder', [$className]),
new Tag\MethodTag('withParameters', [$className]),
]
))->setWordWrap(false));

$file = $this->codeGeneratorListener->onBaseResultIteratorGenerated($file, $this, $this->configuration);
Expand Down