-
-
Notifications
You must be signed in to change notification settings - Fork 28
[MCP SDK] Use foreach instead of array_map
because array_map
does not accept generators
#143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[MCP SDK] Use foreach instead of array_map
because array_map
does not accept generators
#143
Conversation
… accept generators
44750cc
to
35c6c5b
Compare
array_map
because array_map
does not accept generators
array_map
because array_map
does not accept generatorsarray_map
because array_map
does not accept generators
$collection = $this->getMockBuilder(CollectionInterface::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['getMetadata']) | ||
->getMock(); | ||
$collection->expects($this->once())->method('getMetadata')->willReturn([]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it would be totally fine to go with a real instance instead:
$collection = $this->getMockBuilder(CollectionInterface::class) | |
->disableOriginalConstructor() | |
->onlyMethods(['getMetadata']) | |
->getMock(); | |
$collection->expects($this->once())->method('getMetadata')->willReturn([]); | |
$collection = new PromptChain([]); |
$collection = $this->getMockBuilder(CollectionInterface::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['getMetadata']) | ||
->getMock(); | ||
$collection->expects($this->once())->method('getMetadata')->willReturn($metadataList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
$collection = $this->getMockBuilder(CollectionInterface::class) | |
->disableOriginalConstructor() | |
->onlyMethods(['getMetadata']) | |
->getMock(); | |
$collection->expects($this->once())->method('getMetadata')->willReturn($metadataList); | |
$collection = new PromptChain($metadataList); |
$collection = $this->getMockBuilder(CollectionInterface::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['getMetadata']) | ||
->getMock(); | ||
$collection->expects($this->once())->method('getMetadata')->willReturn([$item, $item]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here:
$collection = $this->getMockBuilder(CollectionInterface::class) | |
->disableOriginalConstructor() | |
->onlyMethods(['getMetadata']) | |
->getMock(); | |
$collection->expects($this->once())->method('getMetadata')->willReturn([$item, $item]); | |
$collection = new PromptChain([$item, $item]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use foreach instead of array_map because array_map does not accept generators and add test coverage.