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

Allow to pass a thunk as a message factory to assertions #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Oct 29, 2020

It is useful in order to delay generating a message.

At the moment the assertion does not pass the message is generated. Otherwise the thunk is not executed.

@simPod simPod force-pushed the lazy branch 2 times, most recently from f1379a5 to 48fb067 Compare October 29, 2020 10:27
* @param mixed $value
* @param string $message
* @param mixed $value
* @param string|callable():string $message
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not implement it to all assertions. If RFC is accepted, I'll add it everywhere

@zerkms
Copy link
Contributor

zerkms commented Oct 29, 2020

What would be the real life use case scenario for this?

@simPod
Copy link
Contributor Author

simPod commented Oct 29, 2020

Sometimes my error messages are

  1. heavy to compute
  2. touch object properties that are not initialised and are not needed to be initialised except for the error message

so I'd rather skip that for happy path.

It is useful in order to delay generating a message.

At the moment the assertion does not pass the message is generated. Otherwise the thunk is not executed.
@simPod
Copy link
Contributor Author

simPod commented Apr 29, 2022

@BackEndTea Hi, is there a will to add lazy messages?

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.

None yet

2 participants