Bug #76398 [Com]: Function `php_strip_whitespace` with multiline array.
| From: | spam2 at rhsoft dot net | Date: | Thu, 31 May 2018 17:24:21 +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-215462@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: spam2 at rhsoft dot net
Reported by: kmvan dot com at gmail dot com
Summary: Function
php_strip_whitespace with multiline
array.
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:
> Because $a = [ 'a', 'b', ]; is a parse
> error
says who?
this is not and was not a parse-error over decades and it#s even what proper codebases for
long-arrays always do when each item is in a seperate line - please verify before you pretend such
false statements
php > $a = [ 'a', 'b', ];
php > print_r($a);
Array
(
[0] => a
[1] => b
)
php >
Previous Comments:
------------------------------------------------------------------------
[2018-05-31 17:14:28] peehaa@php.net
That does not result in a parse error and is perfectly fine PHP code.
------------------------------------------------------------------------
[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