Bug #76398 [Com]: Function `php_strip_whitespace` with multiline array.
| From: | kmvan dot com at gmail dot com | Date: | Thu, 31 May 2018 17:05:49 +0000 |
| Subject: | Bug #76398 [Com]: Function `php_strip_whitespace` with multiline array. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215460@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
Comment by: kmvan dot com at gmail dot com
Reported by: kmvan dot com at gmail dot com
Summary: Function
php_strip_whitespace with multiline
array.
Status: Open
Type: Bug
Package: Arrays related
Operating System: Windows/Linux
PHP Version: 7.1.18
Block user comment: N
Private report: N
New Comment:
Because $a = [ 'a', 'b', ]; is a parse error.
The comma after 'b' should trim in single line or cause parse error.
Previous Comments:
------------------------------------------------------------------------
[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