Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Fix accepted stage type in FluentFactoryTrait #71

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion generator/src/FluentStageFactoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Nette\PhpGenerator\PhpNamespace;
use Nette\PhpGenerator\TraitType;
use ReflectionClass;
use stdClass;

use function array_key_last;
use function array_map;
Expand Down Expand Up @@ -45,10 +46,11 @@ private function createFluentFactoryTrait(GeneratorDefinition $definition): PhpN
$namespace->addUse(self::FACTORY_CLASS);
$namespace->addUse(StageInterface::class);
$namespace->addUse(Pipeline::class);
$namespace->addUse(stdClass::class);

$trait->addProperty('pipeline')
->setType('array')
->setComment('@var list<StageInterface>')
->setComment('@var list<StageInterface|array<string,mixed>|stdClass>')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was stdClass added? In https://github.com/mongodb/laravel-mongodb/pull/2738/files#r1536149792, you only needed array<string,mixed>.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that's what is accepted by the Pipeline class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An existing Pipeline object is also accepted by the Pipeline constructor (for appending IIRC). I just assumed this would be as restrictive as possible based on what the trait enables users to do.

Defer to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property is public. The user can append anything to the array.

->setValue([]);
$trait->addMethod('getPipeline')
->setReturnType(Pipeline::class)
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Stage/FluentFactoryTrait.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.