-
Notifications
You must be signed in to change notification settings - Fork 280
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
Objects with __toString() can be asserted. #760
Conversation
It converts it to int ? WTF. The function expects a string, not an int. |
The This was already discussed in #743 (comment), where |
@aik099 A little backstory on how I found this issue. I was developing tests for a Drupal module that we are developing internally. The test called traits from the Drupal core, and those traits asserted translated strings (which are objects). I looked around and it seems that the Drupal core does this in a lot of places. Drupal core also depends on the master branch of mink for some reason. The easier fix would be to make Drupal depend on the last stable version, however that is a temporary fix, because a new mink version going to be released eventually. I think adding a cast is much simplier than requiring bigger projects to go through bigger refactorings. And since many PHP functions convert object with Also, PHP 7 does this conversion automatically in case when a function parameter is type hinted. See here: https://3v4l.org/vthrq |
97f0d08
to
dd19ac3
Compare
In a recent change, some regex matches changed to stripos() calls. The problem is that stripos() converts the needle parameter to int if it is not a string. While objects having __toString() can be converted into string by most of the internal PHP functions, they cannot be converted to int, resulting in an error.
@aik099 Could you please take a look at this PR. I am not sure whether the failed test on Travis is actually a blocker of the merge or not. |
@mxr576 , checked. All issues have been resolved now. Failing build is related to some Packagist/GitHub issue and can be ignored. |
🆒, so when this will be merged? |
In a recent change, some regex matches changed to stripos() calls.
The problem is that stripos() converts the needle parameter to int
if it is not a string. While objects having __toString() can be
converted into string by most of the internal PHP functions, they
cannot be converted to int, resulting in an error.
I found this issue when running Drupal tests. Drupal passes objects to these assert functions (most notable
TranslatableMarkup
.