textile/php-textile

Fix usage of $style in Parser::parseAttribsToArray

Closed this issue · 3 comments

In a PHP7-environment, I got the Error

[] operator not supported for strings

whenever Parser::parseAttribsToArray() tried to write into its local variable $style. I assume this is because $style is initialized as a string but then used as an array (and later as string again).

I suggest fixing this by initializing $style as an array in the first place.

An uncaught Exception was encountered
Type: Error
Message: [] operator not supported for strings
Filename: ......../vendor/netcarver/textile/src/Netcarver/Textile/Parser.php
Line Number: 2062

v3.6.0
PHP 7.1.5

This: h1=. Centered headline produces a fatal error since PHP 7.1.0:
Applying the empty index operator to a string (e.g. $str[] = $x) throws a fatal error instead of converting silently to array.
Please merge the above PR or change the initialization of $style here to array(). I'm monkeypatching that line since 6 months - and I'm for sure not the only one. Thank you :)

This should be fixed in the master branch. The travis test failure shown next to the commit sha1 above was due to the need to drop the PHP5.3 tests from the travis-ci config file. Please re-open if the error persists for you.