Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP in Aptana - function declarations?

I was wondering if there is an easier (or just any) way to declare functions in PHP files. For example, let's say we have following function:

function myfunc($parama = '', $paramb = 0) {}

Would it be possible to add (as part of PHP bundle) a snippet to create:

  /***
   * 
   * 
   * @param     $parama String
   * @param     $paramb Integer
   * @return   
   * @author   
   * @copyright {current_date}
   */

In case it's doable, the bundle would auto-add it just by typing /*** above function.

Any thoughts are warmly welcome. I managed to do that in TextMate a while ago, but can't figure out how to do it in Aptana.

FYI: I'm referring to Aptana 3.0.6.

Thanks! :)

...

(an hour later)

Actually, I figured it out - created a snippet for this:

snippet 'Declare Function' do |s|
  s.trigger = 'docf'
  s.scope = 'source.php'
  s.expansion = '/***
 * 
 *
 * @param   
 * @return  
 * @author  $6
 * @copyright ' + Time.now.strftime('%Y-%m-%d') + '
 */
function ${1:functionName}($2) 
{
  $0
}'
end

Hope it's useful for other devs. :)

like image 639
Dimitar Avatar asked Oct 27 '11 07:10

Dimitar


1 Answers

This is a feature of PHPed (http://www.nusphere.com/). This has been my IDE of choice for the past 4 years. After a function has been defined, you start the comment block with:

/**

And press enter. It reads the function signature and generates some nice javadoc comments, much like the ones you've provided above.

like image 134
Homer6 Avatar answered Sep 28 '22 16:09

Homer6