php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65344 Script source commenting, add syntax which allows nesting
Submitted: 2013-07-26 14:12 UTC Modified: 2013-07-30 15:45 UTC
From: marshall dot sorenson at gmail dot com Assigned: ab (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marshall dot sorenson at gmail dot com
New email:
PHP Version: OS:

 

 [2013-07-26 14:12 UTC] marshall dot sorenson at gmail dot com
Description:
------------
It would be AMAZING if there was an additional extended comment syntax which 
allowed nesting and overrode C-style comments. The idea would be to only match 
the last comment closure per file to allow commenting out large blocks of 
functions which are PHPdoc'd or where a developer used C-style comments for 
multi-line comments.

This would only be useful during development since scripts would have to be 
backwards compatible with older PHP versions. I have been a PHP developer for 12 
years and this would help immensely when debugging code "inherited" from another 
developer!

Even if it could only be enabled with a run time INI setting, that would be 
fantastic just to have it available. Perhaps even the tokens could be customized 
via INI setting.

I am imagining something like this...

/*===
foo
// bar
# baz
/* fu */
===*/
man
/* chu */
===*/

If there is any interest in this I would be willing to work on the patch but 
would need some mentoring.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-29 18:17 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2013-07-29 18:17 UTC] ab@php.net
The functionality you're looking for is already there,

if ($cond1) {
   function hello() { /* version 1 */ }
} else if ($cond2) {
   function hello() { /* version 2 */ }
} else ....
 [2013-07-30 13:35 UTC] marshall dot sorenson at gmail dot com
-Status: Closed +Status: Assigned
 [2013-07-30 13:35 UTC] marshall dot sorenson at gmail dot com
The functionality you gave an example of definitely does NOT work in all cases. 
For instance, that can't be used to "comment" out class methods.
 [2013-07-30 15:45 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2013-07-30 15:45 UTC] ab@php.net
That's the solution you've asked for. Your approach wouldn't work with class 
methods as well "to only match the last comment closure per file". However you 
can put the whole classes into the if blocks. 

But other technics like including another file to rewrite methods one by one 
would work too. Things like having index_dev.php in symfony or using mock 
objects are still around.

Anyway, I wasn't intended to discourage you. If you still believe such a feature 
is necessary, please discuss this on internals first. Once you've a positive 
feedback, feel free to go on with RFC, patch and reopening this ticket.

Thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 14:01:30 2025 UTC