Skip to content

Conversation

@norkunas
Copy link
Contributor

@norkunas norkunas commented Dec 9, 2025

ModalBuilder::new has typehint ComponentObject[] so that means array of them, but setComponents accepts variadic param and then after it calls addComponent an error is thrown

TypeError: Discord\Builders\ModalBuilder::addComponent(): Argument #1 ($component) must be of type Discord\Builders\Components\ComponentObject, array given

Also ModalBuilder::setComponents has phpdoc with ComponentObject[] array so it contradicts with php variadic definition

norkunas and others added 2 commits December 9, 2025 13:52
`ModalBuilder::new` has typehint `ComponentObject[]` so that means array of them, but `setComponents` accepts variadic param and then after it calls `addComponent` an error is thrown

> TypeError: Discord\Builders\ModalBuilder::addComponent(): Argument discord-php#1 ($component) must be of type Discord\Builders\Components\ComponentObject, array given

Also `ModalBuilder::setComponents` has phpdoc with `ComponentObject[]` array so it contradicts with php variadic definition
@valzargaming valzargaming changed the title Fix ModalBuilder::setComponents Add tests for ModalBuilder Dec 9, 2025
@valzargaming
Copy link
Member

Made a few relevant changes on dev-master with a7c9113 and a few others, so repurposed this PR to add tests for it

@valzargaming valzargaming merged commit 5f60c8f into discord-php:master Dec 9, 2025
1 check failed
@norkunas norkunas deleted the fix-set-components branch December 9, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants