Problem/Motivation
#2244447: Translation of low-level info/annotations leads to circular dependencies introduced \Drupal\Core\StringTranslation\TranslationWrapper
, which implements __toString()
in order to be usable with code that expects strings. However, strpos()
doesn't cast values to strings, but does a type check first and if the needle is not a string, it casts it to an integer. This causes some web tests to fail, as WebTestBase::assertText()
uses strpos()
internally.
Proposed resolution
Explicitly cast the needle to a string in WebTestBase::assertText()
, as the $text
parameter is documented as being text anyway.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#6 | drupal_2282453_6.patch | 766 bytes | Xano |
#1 | drupal_2282453_1.patch | 1.45 KB | Xano |
Comments
Comment #1
XanoComment #2
sunThe type-cast makes sense to me, but the phpDoc adjustment slightly seems to contradict the functional change? ;)
Comment #3
XanoThe argument was supposed to be a string anyway, so the patch also makes that clear on top of the actual change, just so people don't figure they can use integers, because the code uses
strpos()
internally anyway.Comment #4
alexpottI agree with @sun the phpDoc does not make sense - now it is a string or and object the implements __toString().
Comment #5
XanoIf we follow that reasoning, we would never be allowed to type hint on strings, as any object can implement
__toString()
and pretend to be a string.Comment #6
XanoI just want to see this fixed, as this breaks my tests. I won't block this on documentation changes.
Comment #7
realityloopthis is straighforward, logical, and passes tests.
Comment #8
catchCommitted/pushed to 8.x, thanks!