Skip to content
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

Fix type hint of @message declaration as the "setWidgetParameters" method allows arrays too #18155

Conversation

avstudnitz
Copy link
Contributor

@avstudnitz avstudnitz commented Sep 20, 2018

Description

The magic setWidgetParameters method of the \Magento\Widget\Model\Widget\Instance class accepts not only strings as its parameter, but also arrays. If it's an array, it gets transformed to a string automatically before saving. This PR adds the corresponding type hint.

Fixed Issues (if relevant)

The IDE shows a warning if you use an array as a parameter:

grafik

This is especially annoying as the getWidgetParameters returns an array. It should be possible to use the same data type for getter and setter of one field.

Manual testing scenarios

Insert the following code into your IDE:

 /** @var WidgetInstance $widget */
$widgetParameters = $widget->getWidgetParameters();
$widget->setWidgetParameters($widgetParameters);

It shouldn't show a warning as displayed in the screenshot above.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @avstudnitz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@rogyar
Copy link
Contributor

rogyar commented Sep 20, 2018

Hi @avstudnitz. Thank you for your collaboration.
That's a good point. I believe there should be 'array' only. Can't figure out a case when we can pass widget parameters as a string

@rogyar rogyar self-assigned this Sep 20, 2018
@avstudnitz
Copy link
Contributor Author

Well, it supports strings, so I think this should be reflected in the docs as well. We might break backwards compatibility otherwise :-)

@magento-engcom-team magento-engcom-team added this to the Release: 2.2.8 milestone Oct 10, 2018
@magento-engcom-team magento-engcom-team merged commit 99f6c1a into magento:2.2-develop Oct 11, 2018
magento-engcom-team pushed a commit that referenced this pull request Oct 11, 2018
@magento-engcom-team
Copy link
Contributor

Hi @avstudnitz. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants