<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://community.activestate.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ActiveState Community Site - Getting more from your PHP and JavaScript code - Comments</title>
 <link>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code</link>
 <description>Comments for &quot;Getting more from your PHP and JavaScript code&quot;</description>
 <language>en</language>
<item>
 <title>FYI: added feature request</title>
 <link>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code#comment-5304</link>
 <description>&lt;p&gt;&lt;a href=&quot;http://bugs.activestate.com/show_bug.cgi?id=76676&quot; title=&quot;http://bugs.activestate.com/show_bug.cgi?id=76676&quot;&gt;http://bugs.activestate.com/show_bug.cgi?id=76676&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance! :)&lt;/p&gt;
</description>
 <pubDate>Mon, 05 May 2008 19:33:11 +0100</pubDate>
 <dc:creator>Dmitry Dulepov</dc:creator>
 <guid isPermaLink="false">comment 5304 at http://community.activestate.com</guid>
</item>
<item>
 <title>PHP type hints</title>
 <link>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code#comment-5303</link>
 <description>&lt;p&gt;I discovered Komodo Editor today and I am very impressed with it. I mainly use PHP and Zend Studio to edit/debug PHP code. I have a strong wish to migrate to Komodo IDE now ;) The only thing that keeps me from doing it is one small missing feature.&lt;/p&gt;
&lt;p&gt;Zend Studio and some other IDEs support PHP type hinting through semi-PHPdoc constructs. For example, this code will produce code completion in any PHP IDE:&lt;/p&gt;
&lt;pre class=&quot;geshifilter&quot;&gt;$var = new MyClass;
$var-&amp;gt;...&lt;/pre&gt;&lt;p&gt;
But the following code will not:&lt;/p&gt;
&lt;pre class=&quot;geshifilter&quot;&gt;$class = &#039;MyClass&#039;;
$var = new $class;
$var-&amp;gt;...&lt;/pre&gt;&lt;p&gt;
Zend Studio solves it with the following syntax:&lt;/p&gt;
&lt;pre class=&quot;geshifilter&quot;&gt;$class = &#039;MyClass&#039;;
$var = new $class;
/* @var $var MyClass */
$var-&amp;gt;...&lt;/pre&gt;&lt;p&gt;
In this case Zend Studio will assume $var is of type MyClass and make code completion. I&#039;d love the same to be implemented in Komodo IDE. I work on a large open source project (&lt;a href=&quot;http://typo3.com/&quot; target=&quot;_blank&quot;&gt;TYPO3&lt;/a&gt;) that uses non-direct object creation all the time, so I will miss code completion always.&lt;/p&gt;
&lt;p&gt;Screenshot of image completion in Zend Studio:&lt;br /&gt;
&lt;img src=&quot;http://i31.tinypic.com/1jt7d3.png&quot; border=&quot;0&quot; alt=&quot;Code completion in Zend Studio&quot; /&gt;&lt;/p&gt;
</description>
 <pubDate>Mon, 05 May 2008 19:13:44 +0100</pubDate>
 <dc:creator>Dmitry Dulepov</dc:creator>
 <guid isPermaLink="false">comment 5303 at http://community.activestate.com</guid>
</item>
<item>
 <title>I think we started doing</title>
 <link>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code#comment-5199</link>
 <description>&lt;p&gt;I think we started doing this with 4.2.0, but it got smarter with 4.3. For example, we started parsing @return for PHP functions in 4.3.&lt;/p&gt;
&lt;p&gt;As for your example, we don&#039;t currently do anything like that. In cases like iterator loops where you can be much more sure what type the iterator is. For example, we have some ideas around supporting something like this:&lt;/p&gt;
&lt;div class=&quot;geshi-block&quot;&gt;
&lt;div class=&quot;geshifilter php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$dir&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; DirectoryIterator&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$path&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$dir&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$item&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// $item is a DirectoryIterator&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$item&lt;/span&gt;-&amp;gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;geshi-plain&quot;&gt;$dir = new DirectoryIterator($path);
foreach ($dir as $item) {
    // $item is a DirectoryIterator
    $item-&amp;gt;
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We&#039;re thinking of extending the standard code intelligence catalog data to add this, but this is currently just an idea.&lt;/p&gt;
&lt;p&gt;--&lt;br /&gt;
JeffG&lt;/p&gt;
</description>
 <pubDate>Sat, 26 Apr 2008 00:06:49 +0100</pubDate>
 <dc:creator>jeffg</dc:creator>
 <guid isPermaLink="false">comment 5199 at http://community.activestate.com</guid>
</item>
<item>
 <title>Hi Jeff</title>
 <link>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code#comment-5191</link>
 <description>&lt;p&gt;This is an awesome feature, something I was missing in Komodo up until now. I was wondering if the following code would work:&lt;/p&gt;
&lt;div class=&quot;geshi-block&quot;&gt;
&lt;div class=&quot;geshifilter php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; SomeClassName&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; SomeMethod&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** @var SomeOtherClass **/&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$someLocalVar&lt;/span&gt; = SomeMethodThatReturnsMixed&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$someLocalVar&lt;/span&gt;-&amp;gt;â€¦&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;geshi-plain&quot;&gt;class SomeClassName
{
  function SomeMethod()
  {
    /** @var SomeOtherClass **/
    $someLocalVar = SomeMethodThatReturnsMixed();
    $someLocalVar-&amp;gt;â€¦
  }
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Will this supply an autocomplete list for $someLocalVar as an instance of SomeOtherClass? It is quite useful when you have foreach loops:&lt;/p&gt;
&lt;div class=&quot;geshi-block&quot;&gt;
&lt;div class=&quot;geshifilter php&quot; style=&quot;font-family: monospace;&quot;&gt;â€¦&lt;br /&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/** @var&amp;nbsp; $listEntry&amp;nbsp; SomeClass **/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$list&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$listEntry&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$listEntry&lt;/span&gt;-&amp;gt;â€¦&lt;/div&gt;
&lt;pre class=&quot;geshi-plain&quot;&gt;â€¦
/** @var  $listEntry  SomeClass **/
foreach ($list as $listEntry) $listEntry-&amp;gt;â€¦&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;BTW, when you say recent releases, which build number are you referring to?&lt;/p&gt;
</description>
 <pubDate>Fri, 25 Apr 2008 08:47:15 +0100</pubDate>
 <dc:creator>Stan</dc:creator>
 <guid isPermaLink="false">comment 5191 at http://community.activestate.com</guid>
</item>
<item>
 <title>Getting more from your PHP and JavaScript code</title>
 <link>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code</link>
 <description>&lt;p&gt;A small but important feature in recent releases of Komodo is the ability to provide the autocomplete system with type hinting through doc comments for PHP and JavaScript code. Using the PHPDoc and JSDoc conventions you can add a lot of smarts to how Komodo parses your code.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;div class=&quot;geshi-block&quot;&gt;
&lt;div class=&quot;geshifilter javascript&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;/**&lt;br /&gt;
&amp;nbsp;* mine&lt;br /&gt;
&amp;nbsp;* @param path {String}&lt;br /&gt;
&amp;nbsp;* @param domtag {element}&lt;br /&gt;
&amp;nbsp;* @returns {String}&lt;br /&gt;
&amp;nbsp;*/&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; mine&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;path, domtag&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;geshi-plain&quot;&gt;/**
 * mine
 * @param path {String}
 * @param domtag {element}
 * @returns {String}
 */

function mine(path, domtag) {
  
}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you paste the above function into a javaScript file in Komodo, you should get appropriate completions for the arguments:&lt;/p&gt;
&lt;div&gt;&lt;img src=&quot;http://community.activestate.com/files/images/js_el_completion.png&quot; alt=&quot;js_arg_ac&quot; title=&quot;js_arg_ac&quot; class=&quot;image _original&quot; height=&quot;274&quot; width=&quot;373&quot;&gt;&lt;/div&gt;
&lt;p&gt;This works similarly in PHP, but instead using the PHPDoc syntax:&lt;/p&gt;
&lt;div class=&quot;geshi-block&quot;&gt;
&lt;div class=&quot;geshifilter php&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/*&lt;br /&gt;
&amp;nbsp;* function Mine&lt;br /&gt;
&amp;nbsp;* @param PDO $model&lt;br /&gt;
&amp;nbsp;* @param DOMDocument $node&lt;br /&gt;
&amp;nbsp;* @return DOMDocument&lt;br /&gt;
&amp;nbsp;*/&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; Mine&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$model&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$node&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #0000ff;&quot;&gt;$model&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;exec&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&amp;nbsp; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$newnode&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$domnode&lt;/span&gt; = Mine&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$x&lt;/span&gt;, &lt;span style=&quot;color: #0000ff;&quot;&gt;$y&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;geshi-plain&quot;&gt;&amp;lt;?php

/*
 * function Mine
 * @param PDO $model
 * @param DOMDocument $node
 * @return DOMDocument
 */

function Mine($model, $node) {
  $model-&amp;gt;exec($sql);
  return $newnode;
}

$domnode = Mine($x, $y);
?&amp;gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A screenshot of autocomplete using this code, this time getting autocompletion on the value returned from the function using the hinting supplied the @return tag in the doc string:&lt;/p&gt;
&lt;div&gt;&lt;img src=&quot;http://community.activestate.com/files/images/php_domdoc_completion.png&quot; alt=&quot;doc_php_ac&quot; title=&quot;doc_php_ac&quot; class=&quot;image _original&quot; height=&quot;418&quot; width=&quot;378&quot;&gt;&lt;/div&gt;
&lt;p&gt;If you get used to using these simple documentation styles for all of your code, you&#039;ll find that Komodo suddenly starts to get a lot smarter when supplying autocomplete lists, and your code is more consistently documented as well =).&lt;/p&gt;
&lt;p&gt;JSDoc manual: &lt;a href=&quot;http://jsdoc.sourceforge.net/&quot; title=&quot;http://jsdoc.sourceforge.net/&quot;&gt;http://jsdoc.sourceforge.net/&lt;/a&gt;&lt;br /&gt;
PHPDoc manual: &lt;a href=&quot;http://manual.phpdoc.org/HTMLframesConverter/default/&quot; title=&quot;http://manual.phpdoc.org/HTMLframesConverter/default/&quot;&gt;http://manual.phpdoc.org/HTMLframesConverter/default/&lt;/a&gt;&lt;/p&gt;
</description>
 <comments>http://community.activestate.com/forum-topic/getting-more-your-php-and-javascript-code#comments</comments>
 <category domain="http://community.activestate.com/forums/komodo-discussion-0">Komodo discussion</category>
 <category domain="http://community.activestate.com/os/all-any">All / Any</category>
 <pubDate>Wed, 23 Apr 2008 21:38:54 +0100</pubDate>
 <dc:creator>jeffg</dc:creator>
 <guid isPermaLink="false">2242 at http://community.activestate.com</guid>
</item>
</channel>
</rss>
