NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Show optional parameters for a function in the PHPdoc displa
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
Hi.

If I define optional parameters like this

/**
* @DESC A function that returns a name
* @param String $firstname - The firstname
* @param String $lastname - The sirname
*/
public function name($firstname, $lastname='')
{
return $firstname . ' ' . $lastname;
}

Then I have an optional parameter (the $lastname)

but if I use this function and PHPed displayes the function description, it does not show the $lastname to be an optional parameter.
It would be nice to have some kind of identification that a parameter is optional like this.

name(String $firstname, [String $lastname =''])

That way you can see that the second parameter is optional and is set to '' if you do not use it.
View user's profileFind all posts by hgrSend private message


Joined: 24 Oct 2006
Posts: 98
Location: Melbourne, AU
Reply with quote
Good suggestion, as it now only shows a default value if lastname="smith" or something non-blank.
View user's profileFind all posts by LatsSend private message
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
Yep, it works on basic PHP funcitions, but not on those you declare.
View user's profileFind all posts by hgrSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
it works for me:


_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Veteran

Joined: 30 Nov 2006
Posts: 186
Reply with quote
Hi Dmitri.

I tried your example (modified it a bit) and you are right.

However, if you use a BLANK default string, it stops working, and the parameter is not shown as optional. And in my opinion a blank is just as valid as '33'

See example below.


View user's profileFind all posts by hgrSend private message


Joined: 24 Oct 2006
Posts: 98
Location: Melbourne, AU
Reply with quote
dmitri wrote:
it works for me:
Yes, and if you had typed in a comma to highlight the next varible, it would have shown 'default = 44', but if the variable is set to nothing ( 2 single quotes ), it won't show that.
View user's profileFind all posts by LatsSend private message
Show optional parameters for a function in the PHPdoc displa
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic