Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#531 Geany 0.19: PHP functions with multiline argument list

closed-fixed
nobody
Interface (176)
5
2014-02-12
2010-08-01
Vince C.
No

Platform: Gentoo Linux.

I was browsing PEAR files when I spotted this. Functions that return references in PEAR are written:

function &func_name(...)

These functions don't appear in the symbols list.

Discussion

  • Enrico Tröger
    Enrico Tröger
    2010-08-01

    Can you provide an example file?

    When I put the line
    function &func_name(...)
    into a PHP file, func_name is detected properly.

     
  • Vince C.
    Vince C.
    2010-08-01

    PEAR MDB2 where function raiseError is not listed

     
    Attachments
  • Vince C.
    Vince C.
    2010-08-01

    My bad... Indeed, most functions beginning with an ampersand do appear. With the file I appended (MDB2.php) functions raiseError don't appear. I early deduced this was because of the ampersand but there now must be another reason.

     
  • Enrico Tröger
    Enrico Tröger
    2010-08-01

    Thanks for example.
    The problem actually is that the list of arguments of that function is continued on the next line. The parser for PHP files is based on regular expressions which work line by line. And the used regular expression expects a final closing bracket on the same line as the function definition.
    I tried to improve the used regex but i'm not so good with regular expressions and failed :(.

    If anyone is interested, here is the used regular expression:

    "^[ \t]*[(public|protected|private|static)[ \t]*]*[ \t]*function[ \t]+&?[ \t]*([" ALPHA "_][" ALNUM "_]*)[[:space:]]*(\\(.*\\))",

    At the end of the regex, there should be something like "until the final closing ) OR a comma followed by zero or more whitespace until line end". I tried with: (\\(.*(\\)|(,[ \t]*$)) but this failed.
    The relevant code is: http://geany.svn.sf.net/viewvc/geany/trunk/tagmanager/php.c

     
  • Vince C.
    Vince C.
    2010-08-01

    Have you tried with \r and \n ? I'm not sure but I also expect the regular expression engine uses new lines as a delimiter.

     
  • Enrico Tröger
    Enrico Tröger
    2010-08-05

    No, I didn't. I doubt that would work because the line which is parsed is most probably arelady stripped from trailing new line characters.

     
  • Nick Treleaven
    Nick Treleaven
    2012-01-01

    • summary: Geany 0.19: PHP functions returning reference not in symbols --> Geany 0.19: PHP functions with multiline argument list
    • status: open --> closed-fixed
     
  • Nick Treleaven
    Nick Treleaven
    2012-01-01

    Should be fixed now in Git, thanks for reporting.

     
  • kartoffelheinz
    kartoffelheinz
    2014-02-12

    I reopen this because the underlying bug does not seem to be fixed properly. The parser recognizes the functions, but not the arguments. Consider this example:

    function foobar($verylongargument, $secondlongarg,
    $longargafterbreak)
    {
    return true;
    }

    This will only list me "foobar($verylongargument, $secondlongarg," for autocompletion, omitting the remaining arguments on the next line.

     
  • @kartoffelheinz it wasn't completely fixed at the time (more like a workaround), but it's really fixed in the current development version for some time now.

    If you could test with the development version next time it'd be great :)

     
  • kartoffelheinz
    kartoffelheinz
    2014-02-12

    Thank you for letting me know.

    I just verified it works like intended using the latest nightly build.