IntelliSense not working in some files.

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

IntelliSense not working in some files.

Postby codeowl » February 11th, 2013, 6:28 am

Hi there,

I am working on a CakePHP project and there seems to be no IntelliSense in some files. For example I have the following file:
index.ctp (I have mapped the .ctp file extension to PHP Editor in the VS options)

Code: Select all
<h1>Blog posts</h1>
<table>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Created</th>
    </tr>

    <!-- Here is where we loop through our $posts array, printing out post info -->

    <?php foreach ($posts as $post): ?>
        <tr>
            <td><?php echo $post['Post']['id']; ?></td>
            <td>
                <?php echo $this->Html->link(
                    $post['Post']['title'],
                    array(
                        'controller' => 'posts',
                        'action' => 'view',
                        $post['Post']['id']
                    )
                ); ?>
            </td>
            <td><?php echo $post['Post']['created']; ?></td>
        </tr>
    <?php endforeach; ?>
    <?php unset($post); ?>
</table>


I can't goto definition on the link method. How can I get this to work?
Do I have to add a reference to the file that has the class with this method to the index.ctp somehow?

Some info regarding CakePHP:
You might have noticed the use of an object called $this->Html. This is an instance of the CakePHP HtmlHelper class. CakePHP comes with a set of view helpers that make things like linking, form output, JavaScript and Ajax a snap. You can learn more about how to use them in Helpers.
http://book.cakephp.org/2.0/en/views/helpers.html

I am using VS2012, on Windows 7 and all the above code is rendering correctly in the browser.

Regards,

Scott
codeowl
 
Posts: 51
Joined: February 10th, 2013, 10:05 am

Re: IntelliSense not working in some files.

Postby CFI » February 11th, 2013, 9:08 am

I am also working with CakePHP, but as this is nothing "generic" I did not complain about this...
In the controller I got my helpers/components via PHPDoc tags, which works fine.

Maybee something "generic" could be implemented to support "generic template engines", like a "/* @baseclass BaseController */" at the top of a PHP file, to tell IntelliSense, that the file is in the "class context of BaseController".
CFI
 
Posts: 66
Joined: December 13th, 2012, 1:29 pm

Re: IntelliSense not working in some files.

Postby Jakub Misek » February 11th, 2013, 1:42 pm

Hi,

Please check whether the script file with non-.php extension has highlighted PHP syntax (close it and reopen is probably needed).

Once scripts are highlighted, they should be visible for IntelliSense too.

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: IntelliSense not working in some files.

Postby CFI » February 11th, 2013, 1:56 pm

IntelliSense in general works.
It just does not know "what $this is" - and this is the problem, as there is no "generic way" to find out.
For example in CakePHP in the file "ROOT/View/Home/index.ctp" $this would be an instance of HomeController from "ROOT/Controller/HomeController.php".
As this is something "framework dependant" I suggested the somehow generic approach of e.g. adding a comment at the top of "index.ctp" like "/* @baseclass HomeController */" to tell IntelliSense what to use for $this.
CFI
 
Posts: 66
Joined: December 13th, 2012, 1:29 pm

Re: IntelliSense not working in some files.

Postby Jakub Misek » February 11th, 2013, 2:10 pm

Yes, $this is known issue ... it is very special variable name, and in case of global code, it is very difficult to find out what type it is ... we are ignoring $this for now, but we are open to any suggestions, eventually we can make it working for certain frameworks.

Thanks!
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: IntelliSense not working in some files.

Postby codeowl » February 11th, 2013, 9:50 pm

Jakub,

Thanks for quick the response again. Yes mate the highlighted PHP syntax is working, as I have set-up the .ctp extension in the File Extension options, and IntelliSense for standard PHP functions is working.

The issue is described well by CFI (thanks for your input mate ;-), and his suggestion is a good one:

"As this is something "framework dependant" I suggested the somehow generic approach of e.g. adding a comment at the top of "index.ctp" like "/* @baseclass HomeController */" to tell IntelliSense what to use for $this."

Is there anything like this in PHP Tools?

BTW: Great to see an active forum here, and good support. Thanks to all participating ;-)

Regards,

Scott
codeowl
 
Posts: 51
Joined: February 10th, 2013, 10:05 am

Re: IntelliSense not working in some files.

Postby Jakub Misek » February 12th, 2013, 11:02 am

Thank you!

We are planning new release soon, following PHPDoc syntax can be supported for this case?
Code: Select all
/**
 * @global TypeName $this
 */
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: IntelliSense not working in some files.

Postby CFI » February 12th, 2013, 11:40 am

The PHPDoc syntax is also great and would fullfill all needs.
CFI
 
Posts: 66
Joined: December 13th, 2012, 1:29 pm


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 51 guests

cron

User Control Panel

Login

Who is online

In total there are 51 users online :: 0 registered, 0 hidden and 51 guests (based on users active over the past 5 minutes)
Most users ever online was 297 on March 29th, 2024, 7:06 am

Users browsing this forum: No registered users and 51 guests