php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53622 CLI -w separate functions of striping whitespace and comments
Submitted: 2010-12-28 17:44 UTC Modified: 2011-01-05 15:50 UTC
From: mnelson at teshy dot com Assigned:
Status: Wont fix Package: CGI/CLI related
PHP Version: 5.3.4 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
19 - 4 = ?
Subscribe to this entry?

 
 [2010-12-28 17:44 UTC] mnelson at teshy dot com
Description:
------------
It would be useful if The Command line option "-w" for stripping comments and 
whitespace was broken down into separate commands. One for striping whitespace and 
one for striping comments, the commands could be combined for users that want 
both. 

In our use case we have code that has become unreadable and needs excessive 
whitespace removed so it can be reformatted properly, we however want to keep all 
code comments.


Patches

strip-comments-whitespace (last revision 2011-01-04 15:01 UTC by aharvey@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-01 01:57 UTC] johannes@php.net
I believe it is better to do this in userland. I'd actually drop the -w flag completely. Keeping the bug open so people can disagree and implement it :-)

btw. a userspace beautifier is on http://pear.php.net/package/PHP_Beautifier
 [2011-01-04 16:01 UTC] aharvey@php.net
The following patch has been added/updated:

Patch Name: strip-comments-whitespace
Revision:   1294153279
URL:        http://bugs.php.net/patch-display.php?bug=53622&patch=strip-comments-whitespace&revision=1294153279
 [2011-01-04 16:01 UTC] aharvey@php.net
I tend to agree, but I implemented it anyway. :)

Quick and dirty patch against trunk attached.
 [2011-01-04 17:50 UTC] johannes@php.net
I didn't test the patch but two comments: The simple one is that the documentation in the man page is missing.

The more complex one is around single line comments. T_COMMENT includes the trailing new line. So I assume that

<?php
foo();
// some comment
bar();
?>

would become

<?php
foo();bar();
?>

Such issues make me believe more and more in specialized tools like mentioned above :-)
 [2011-01-05 15:50 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2011-01-05 15:50 UTC] aharvey@php.net
Won't fix, per discussion on IRC. As Johannes says, it's better left to third 
party tools.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 04:01:29 2024 UTC