NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Automatic phpDoc code creation for classes and functions?


Joined: 21 Aug 2007
Posts: 14
Reply with quote
Hi,

I have been using PhpEd for quite a while now, and have found it to be overall one of the best solutions out there for PHP development.

Nice one!

However, one of the very few issues I have with the IDE is apparently you have to do a lot of manual typing when it comes to phpDoc comments, when it could just as well be done by the IDE (via PHP5 reflection or something).

I checked out Zend Studio yesterday and was astounded to see the following behaviour:

1. Create your class and functions, eg:

Code:

<?php
 
 class MyClass {
 
  function __construct(array $arrIDs, $blnSwitch=false) {
   return true;   
  }
 
  function getStuff(MyClass $objMyClass,$intNumber,$strTitle,array $arrVals,$strOptional=null) {
   return 'message';
  }
 }
 
?>
?>


2. Type the following above your class and function definitions and hit enter: /**

3. You get this:

Code:

<?php
 
 /**
  * Enter description here...
  *
  */
 class MyClass {
 
  /**
   * Enter description here...
   *
   * @param array $arrIDs
   * @param unknown_type $blnSwitch
   * @return unknown
   */
  function __construct(array $arrIDs, $blnSwitch=false) {
   return true;   
  }
 
  /**
   * Enter description here...
   *
   * @param MyClass $objMyClass
   * @param unknown_type $intNumber
   * @param unknown_type $strTitle
   * @param array $arrVals
   * @param unknown_type $strOptional
   * @return unknown
   */
  function getStuff(MyClass $objMyClass,$intNumber,$strTitle,array $arrVals,$strOptional=null) {
   return 'message';
  }
 }
 
?>


This is obviously a big time saver! As far as I can tell, PhpEd can not do this (unless I am missing something?).

Would it be possible to implement this?

I would also go one further and suggest that where a type hint is not available for a function parameter, try and see if there is a naming convention going on. For example, you can see that I begin all my string variables $str, integers as $int, and so on. You could then automatically work out the type of the variable and stick that in the phpDoc comments. That would probably have to be to be an option somewhere though.

Thanks for all your hard work!

Matthew
View user's profileFind all posts by binarymonkeySend private message


Joined: 21 Aug 2007
Posts: 14
Reply with quote
anybody?
View user's profileFind all posts by binarymonkeySend private message


Joined: 15 Sep 2004
Posts: 9
Reply with quote
Look at this thread: http://forum.nusphere.com/some-useful-scripts-for-phped-t1989.html

The 2nd script does what you want.

That said, it really should be a built-in feature of PhpEd.
View user's profileFind all posts by amagrudeSend private message
Automatic phpDoc code creation for classes and functions?
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