#242 Patch to fix multiline comments in PHP


Bug 1795926 and 1894455 report a problem that the PHP parser matches keywords inside multiline comments. I have written a patch that largely solves this problem by looking at what is in front of the keyword. There should be only whitespace or keywords such as "public", "static" or "abstract" in front of a class or function statement.

The patch does not fix this 100%. It is technically possible to declare classes and functions after another statement on the same line, but nobody ever does that because it makes for very unreadable code. On the other hand, a lot of people do comment their code so this patch should give a large improvement in quality.

Since this patch also looks at PHP5 keywords such as "static" and "abstract", it also adds the .php4 and .php5 extensions to the list of PHP file extensions.


  • Elliott Hughes

    Elliott Hughes - 2008-12-13
    • assigned_to: nobody --> jafl
  • David Mudrak

    David Mudrak - 2009-07-07

    I think the Sander's patches have problems with backward compatibility. They do not seem to tag functions starting on a new line without the visibility scope declaration, like

    function ordinary_function()

    because of the [ \t]+

    I have prepared my own version of patches that should fix this. See http://bugs.gentoo.org/show_bug.cgi?id=276902

  • Sander Marechal

    Sander Marechal - 2009-07-07

    David Mudrak's changes fix the problem with my patch and also solve a similar issue for the "interface" keyword. I'll upload his patch to replace my own.

  • John Lindal

    John Lindal - 2009-07-10
    • status: open --> closed-duplicate
  • John Lindal

    John Lindal - 2009-07-10

    Duplicate of 1795926


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks