You are here: PSPad forum > Bug report / Hlášení chyb > PHP function() declarations not always listed in Code Explorer?

PHP function() declarations not always listed in Code Explorer?

#1 PHP function() declarations not always listed in Code Explorer?

Posted by: Stratadrake | Date: 03/08/2009 08:45 | IP: IP Logged

Using PSPad 4.5.4 (2320) on WinXP.

I've noticed a few oddities where PSPad's Code Explorer doesn't correctly recognize where a function is defined (even after refreshing the Code Explorer).

I notice this mostly in the HTML Multihilighter, but it also occurs with straight PHP highlighting.

Example - Conditional function declarations (www.php.net)

PHP allows you to conditionally define a function in the middle of a control structure (if-then, switch, etc.).

For example:

Quote:
<?php

// Declare myfunc() one way...
if ($foo) function myfunc()
{
// something
}

// ...or another
else function myfunc()
{
// something different
}
myfunc(); // Call myfunc()

?>

In the above, the Code Explorer doesn't recognize myfunc() as being declared because the declarations don't begin with newlines.

By comparison...

Quote:
<?php

if ($foo)
{ // Declare myfunc() one way
function myfunc()
{
// something
}
}
else
{ // Declare myfunc() differently
function myfunc()
{
// something different
}
}
myfunc(); // Call myfunc()

?>

Here, the Code Explorer correctly recognizes and lists myfunc() -- twice in fact! If the same function declaration is found more than once the Code Explorer should group the declarations together like it already does with variables (e.g., [+] icon, expanding with line numbers of the declarations).

Another semi-related oddity....

Quote:
<?php

// Let's output some Javascript for the client-side
echo "<script type='text/javascript'><!--
function myJavaScript()
{
// Do something in Javascript
}
--></script>";

?>

This causes the Code Explorer to list myJavaScript() as a PHP function declaration -- it's not! In the PHP sense this is just a string literal, not a function declaration. The fact that it contains a Javascript declaration isn't necessarily important. (This can actually be useful in some cases, but a bug is a bug)

Options: Reply | Quote | Up ^


#2 Re: PHP function() declarations not always listed in Code Explorer?

Posted by: pspad | Date: 03/08/2009 12:07 | IP: IP Logged

You are right. PSpad doesn't count with such code.
Is any reason to write your code on one line?

Use CTAGS:
forum.pspad.com

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2013 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák