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

#170 Strict null check of result message in console output #193

Closed
wants to merge 1 commit into from
Closed

#170 Strict null check of result message in console output #193

wants to merge 1 commit into from

Conversation

meetmatt
Copy link

Sorry for missing unit test, but this class wasn't covered before anyway ¯_(ツ)_/¯

@@ -57,7 +57,8 @@ public function onAfterRun(CheckInterface $check, ResultInterface $result, $chec

$this->output->write(sprintf(' %s', $check->getLabel()));

if ($message = $result->getMessage()) {
$message = $result->getMessage();
if (null !== $message) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in theory null should never be returned
https://github.com/zendframework/zend-diagnostics/blob/master/src/Result/ResultInterface.php#L15

@weierophinney: but I suspect that this is just an incorrect docblock?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at the AbstractResult, and the $message property is never set to a value if no message is passed. We should likely be initializing it as an empty string. (We really need to update that library to PHP 7.1+, as that would make it easier to identify these signature errors!)

Would you be willing to create a PR against zend-diagnostics that would initialize the message to an empty string, please, mentioning this issue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, but even if I modify the docblock in AbstractResult and init the message to empty string by default, then this PR is still needed (empty string evaluates to boolean false).
I can imagine that zend-diagnostics will take forever to merge, but this fix is a quick one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be willing to create a PR against zend-diagnostics that would initialize the message to an empty string, please, mentioning this issue?

Sure: zendframework/zend-diagnostics#94

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess with your PR to zend diagnostic this change would no longer be necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if it’s going to be accepted. Strictly speaking, the proposed PR in zend is a BC-breaking change and with a very slight chance may break someone else code, so I won’t be surprised if it will be declined in such form.

Any way, thank you for review. I will close this PR and open another one to update zend library as soon as it’s merged and tagged.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reviewing it now. 😄

In terms of the potential BC breakage:

  • It's documented as returning a string.
  • None of the shipped result implementations vary from what AbstractResult does.
  • All reporters assume that method returns a string.

As such, I'm treating it as a bugfix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just released the patch as version zend-diagnostics 1.3.1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review. I will check the rest of the issues if I have time. Actually just intended to use your bundle cause it’s cool but found a minute to contribute. Good luck :)

@meetmatt
Copy link
Author

meetmatt commented Sep 18, 2018

I will open another one with updated zend-diagnostics library.

Update: I've just realised that no PR is required because the bundle is not shipped with composer.lock (which is good of course). So it's up to the users of the bundle to update.

@meetmatt meetmatt closed this Sep 18, 2018
@meetmatt meetmatt deleted the bugfix/170-omitted-console-output branch September 18, 2018 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants