-
-
Notifications
You must be signed in to change notification settings - Fork 247
Implement attribute helpers #1400
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
Conversation
I'm currently testing this on one of my production bots, though more eyes are always welcome. I'm hoping to have this released with 10.19.0. |
Updating getter methods to be guaranteed to return a CollectionInterface seems to have introduced some internal BC with serialization. Many jsonSerialize methods only check to see if the property is set before adding the data to the json output without any regard for if the Collection is empty or null. {
"code": 50035,
"errors": {
"components": {
"0": {
"_errors": [
{
"code": "MODEL_TYPE_CONVERT",
"message": "Expected an object\/dictionary."
}
]
}
}
}
} |
This should be resolved now. The issue was originating from Collections being converted to an associative array when used inside of Builders. The fix is to simply convert the Collection to a non-associative array when calling jsonSerialize. |
Tested and confirmed working, but would like a few other people to test it to make sure nothing critical was missed/broken. |
This pull request refactors several builder and part classes to consistently use collection helper classes (
Collection
,ExCollectionInterface
) for managing lists of components, options, and other entities. It also introduces a new trait,DynamicPropertyMutatorTrait
, to simplify dynamic property access and mutator logic. Additionally, several attribute getter methods are refactored to use new helper methods, improving code readability and maintainability.Collection Handling Improvements
CommandBuilder
,MessageBuilder
, andModalBuilder
classes to useCollection
andExCollectionInterface
for managing options and components, replacing raw arrays and ensuring consistent collection handling throughout the codebase. This includes updating property types, getter/setter methods, and internal logic for adding/removing items. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Dynamic Property Access
DynamicPropertyMutatorTrait
and applied it to theComponent
class, enabling dynamic getter and setter methods for properties and reducing boilerplate in property access logic. [1] [2] [3]Attribute Getter Refactoring
Channel
,Invite
, andMessage
parts to use new helper methods (attributeCollectionHelper
,attributePartHelper
,attributeCarbonHelper
), improving code clarity and reducing duplication. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Type Annotation and Documentation Updates
Dependency Imports
Collection
andExCollectionInterface
in relevant files to support the new collection logic. [1] [2]