-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat: Adds property typing for an object attribute #336
Conversation
…he get_attribute_type method
…_fields method call.
…ds into the constructor itself.
… array and empty by default
…od with foreach loop.
… type object with typing provided in default.
🦋 Changeset detectedLatest commit: 39293c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@whoami-pwd Can we add some tests for an object to catch any breaking changes going forward. Otherwise the code looks great to me 😄 |
@justlevine thoughts of this proposal? |
Not entirely sure I understand everything that's going on here or the purposes behind these seemingly unrelated things. Two things that jumped out at me:
|
Hey @justlevine, thanks for your feedback! Let me address your concerns: 1. Changing
|
@justlevine Thank you for your insightful comments! @justlevine, you are absolutely correct that the commits prior to 6f0a3fa are largely focused on code refactoring. Beyond reducing nesting and simplifying the code with early returns to improve readability, there is a significant change to the property type. As you’ve astutely noted, this does impact child classes due to the property type modification. However, based on the current implementation, I couldn’t identify any instances where these attributes are used as anything other than arrays. This change will enable us to directly leverage them as arrays, which I believe is a reasonable improvement. Ideally, I would prefer to introduce these changes separately, outside the scope of this feature PR, to adhere to best practices for code retrospectives and refactoring. Unfortunately, we don’t yet have a formalized process for handling these types of changes independently. As a result, I’ve included them in this PR because, while not directly tied to the feature, they are related to the class where the feature changes are applied. The |
It sounds like the refactoring needs to be a separate PR from the immediate feature if it's not required. Based on what @theodesp and @whoami-pwd have said, this breaking change is also not required. If that's the case, let's log an issue, and we can address it in the future. The constant breaking changes on this plugin really need to be addressed and solved. It's a larger issue than this PR, but let's start here by not breaking things that don't need to be. |
Description
This PR introduces refactoring and enhancements and the functionality for creating typed attribute objects by specifying in block.json.
Changes to
Block.php
and Child Classesblock_attributes
directly in the constructor.$block_attributes
and$additional_block_attributes
fromarray|null
toarray
, defaulting to an empty array.$block_attributes
parameter from theget_block_attribute_fields
method in favor of theblock_attributes
property defined in the constructor.get_query_type
tocreate_and_register_inner_object_type
, reflecting its broader functionality.Object Attribute Typing
block.json
for object attributes. Example:Refer to the updated README.md for details on the new functionality.
Readme instructions update