BehatHtmlFormatterPlugin icon indicating copy to clipboard operation
BehatHtmlFormatterPlugin copied to clipboard

Using PHP short array syntax is not compatible with PHP 5.3.x

Open alb404 opened this issue 9 years ago • 3 comments

Hi,

The readme specify a minimum PHP version of 5.3.x but I get the following error when using PHP 5.3.10:

Parse error: syntax error, unexpected '[' in /vagrant/sites/vendor/emuse/behat-html-formatter/src/Renderer/BaseRenderer.php on line 36

The troublemaker: if(in_array($renderer, ['Behat2', 'Twig', 'Minimal'])) {

Short array syntax was introduced in PHP 5.4 (see http://php.net/manual/en/migration54.new-features.php).

Thanks :)

alb404 avatar Nov 02 '15 12:11 alb404

I'm in the same situation.

The fix is just replacing ['Behat2', 'Twig', 'Minimal'] for array('Behat2', 'Twig', 'Minimal')

nahog avatar Jan 18 '16 19:01 nahog

I'm in the same situation.

The fix is just replacing ['Behat2', 'Twig', 'Minimal'] for array('Behat2', 'Twig', 'Minimal')

Thank you, you saved my day!

Edwin1122 avatar Jan 29 '19 05:01 Edwin1122

What is the runtime setting to display this error? I'm using a shared host that uses php5.3.29-pl0-gentoo and I've tried each of the following and neither of them catch the short array syntax error, my server just prints a blank page:

ATTEMPT 1


ini_set("display_errors",1); ini_set("display_startup_errors",1); error_reporting(E_ALL); ini_set("html_errors","On");


ATTEMPT 2


ini_set("display_errors",1); ini_set("display_startup_errors",1); error_reporting(E_ALL & E_STRICT); ini_set("html_errors","On");


ATTEMPT 3


ini_set("display_errors",1); ini_set("display_startup_errors",1); error_reporting(E_ALL & E_STRICT); error_reporting(E_ALL & E_NOTICE & E_STRICT & E_DEPRECATED);


arya108 avatar Nov 12 '20 22:11 arya108