codefog / contao-haste

Haste is a collection of tools and classes to ease working with Contao
http://codefog.pl/extension/haste.html
MIT License
42 stars 24 forks source link

StringUtil::convertToText() preg_match_all() expects parameter 2 to be string, object given #128

Closed fatcrobat closed 5 years ago

fatcrobat commented 6 years ago

If for example Haste\Util\StringUtil::convertToText(object(stdClass), 3) is called, preg_match_all will throw an error. Can you add an is_string() check?

https://github.com/codefog/contao-haste/blob/4af49bc85b225904bfeafcd776d4bddd74197004/library/Haste/Util/StringUtil.php#L112

qzminski commented 5 years ago

From what I can see in the code the stdClass is not supported at all. Thus I would rather tend to throw an exception if an object is passed. @aschempp ?

aschempp commented 5 years ago

well an error is already thrown by PHP. The argument docs clearly say you should pass a string or array, so not sure if we really need to change anything?

qzminski commented 5 years ago

Hmm true, the result would be the same in the end. I am closing this one then.