Bug #76398 [Opn->Nab]: Function `php_strip_whitespace` with multiline array.

From: Date: Thu, 31 May 2018 17:14:28 +0000
Subject: Bug #76398 [Opn->Nab]: Function `php_strip_whitespace` with multiline array.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215461@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76398&edit=1 ID: 76398 Updated by: peehaa@php.net Reported by: kmvan dot com at gmail dot com Summary: Function php_strip_whitespace with multiline array. -Status: Open +Status: Not a bug Type: Bug Package: Arrays related Operating System: Windows/Linux PHP Version: 7.1.18 Block user comment: N Private report: N New Comment: That does not result in a parse error and is perfectly fine PHP code. Previous Comments: ------------------------------------------------------------------------ [2018-05-31 17:05:48] kmvan dot com at gmail dot com Because $a = [ 'a', 'b', ]; is a parse error. The comma after 'b' should trim in single line or cause parse error. ------------------------------------------------------------------------ [2018-05-31 16:50:02] peehaa@php.net Why would it strip commas? And why would it result in a parse error? Feels like there is something else wrong. ------------------------------------------------------------------------ [2018-05-31 16:43:54] kmvan dot com at gmail dot com Description: ------------ If a two-dimensional multiline array ends with a comma. The function php_strip_whitespace can not trim the last comma in single line, so cause parse error. File a.php: <?php $a = [ 'a', 'b', ]; Test script: --------------- <?php \var_dump(\php_strip_whitespace(__DIR__ . '/a.php')); // output: string(26) "<?php $a = [ 'a', 'b', ]; " Expected result: ---------------- // output: string(25) "<?php $a = [ 'a', 'b' ]; " Actual result: -------------- // output: string(26) "<?php $a = [ 'a', 'b', ]; " ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76398&edit=1

« previous php.bugs (#215461) next »