How to turn on extended code completion in PhpStorm

Hello,

I sometimes need more informations on what a method, function or class does than just its prototype. Is it possible for instance to hook PHP manual to code completion so that after another Ctrl+Space it would show me method description/details in a floating window?

Thanks :)

0

Hi there,

Ctrl+Q (or whatever you have got there for "View | Quick Documentation")

That will show what PhpStorm knows about this function (info taken from corresponding PHPDoc blocks).

If you need actual full documentation in browser -- use "View | Extrenal Documentation" (URL is taken from @link PHPDoc tags)

P.S.
Check also "Settings (Preferences on Mac) | Editor | Code Completion --> Autopopup documentation in (ms)..." option

0

Great, Thanks a lot :). That's what I needed.

0
Avatar
Permanently deleted user

pressing CTRL-Q only seems to work if the cursor is in the middle of the method name.  Once I've entered the parentheses, I can see the prototype for the parameters (without their @param description) but there doesn't seem to be any way to "see more" i.e. I'd like to see the method's summary description and/or @param details when I'm trying to enter in the parameters.

Am I missing a setting or is it really necessary to finish typing the method and then backspace or select the method with the mouse and then press CTRL-Q?  I like PhpStorm but PHPDoc comments for class methods have become pretty useless since our team switched to it.

0
pressing CTRL-Q only seems to work if the cursor is in the middle of the method name.

That's correct.

Otherwise, when you inside the parentheses .. for which element the quick doc should be shown: function/method name .. or variable under cursor? And what should happen if I have multi-level function calls (result of one function is passed as parameter directly to another)?

Having quick doc working this deterministic way (for element under cursor) removes such problems.

Once I've entered the parentheses, I can see the prototype for the parameters (without their @param description) but there doesn't seem to be any way to "see more" i.e. I'd like to see the method's summary description and/or @param details when I'm trying to enter in the parameters.

Right now I may only suggest one of these:

  • for big screens -- pin the doc window so it's always visible.
  • "Show quick doc on mouse move" option in "Settings | Editor | General" -- could be annoying if you do not like auto popups


Other than that: https://youtrack.jetbrains.com/issue/WI-23913

I like PhpStorm but PHPDoc comments for class methods have become pretty useless since our team switched to it.

Please explain. Why they were "useful" before and "useless" now?

0
Avatar
Permanently deleted user

Bazzik wrote:

Please explain. Why they were "useful" before and "useless" now?


Taking the time to add helpful documentation to a function is a waste of time if developers don't actually see them when they're coding.  PhpStorm not only doesn't show useful information about a function when it's needed, it's actually fairly cumbersome to get at that information if someone does want to see it.

As an example, imagine a function with several parameters and one of them contains helpful text to use an enum:
/**
* @param int $statusId - use the Status enum ex: Status::AWAITING_APPROVAL
* ...
*/

How  is any developer going to  know to use the Status enum when the editor only tells them that  $statusId  is an INT? At the point where they see that the function's parameter is  an INT called StatusId, if they do decide to make the effort to view the function's documentation, they have to do the following:

  1. press LEFT ARROW twice so the cursor is withing the name of the  function or leave the keyboard to grab the mouse and click on the  function name

  2. press CTRL + Q to view the popup description and read the descriptions for the list of parameters

  3. press ESCAPE to close the popup window

  4. press RIGHT ARROW twice to get back inside the parentheses

  5. press CTRL + P to make the parameter intellisense popup (or delete both  parentheses and then type the first parentheses again so the  intellisense will appear)

  6. enter the parameter values and hope you remember the descriptions for the 3rd and 4th parameter

A good editor should help a developer code.  At the point where a developer begins entering a parameter for a function, it's an opportunity for the function's author to guide the consumer with what the function (and the author) expects as input and what the developer should expect as output from the function.

Examples include:

1. What is expected for a "mixed" parameter type
2. A parameter description explaining what enum can be used
2. A better description of the value being returned .. perhaps it's a CSV of Ids or an array with the primaryKey as the index
3. Being able to see the @example text with a snippet showing which enum can be used as a parameter

PhpDOC.gif

I've been trying to get other developers to document their code more but now that we're using PhpStorm, there isn't much point in it if it's not going to be visible when we're coding.

0
Avatar
Permanently deleted user

Hi,

Create an interface file of values like so:

 
<?php
    namespace myutils\dbutils\query;

    /**
     * Created by JetBrains PhpStorm.
     * User: Jim
     * Date: 4/3/12
     * Time: 8:42 PM
     * To change this template use File | Settings | File Templates.
     */
    interface
ColType
    {
        const UNKNOWN = -1;
        const INT
= 0;
        const CHAR
= 1;
        const VARCHAR
= 2;
        const DATE
= 3;
        const TIME
= 4;
        const DATETIME
= 5;
        const NUMERIC
= 6;
        const BOOL
= 7;
        const DOUBLE
= 8;
        const FLOAT
= 9;
        const STRING
= 10;
        const QUERY
= 11;
    
} Then reference that Interface as parameter in your function. See attached screenshot

class Column implements ColType
{
    private $table = null;
    private $name;
    private $type;
    private $alias;
    private $functions;
    private $descending
= false;
    private $isObject
= false;
    private $id;

    function __construct
($name, $alias = "", ColType $type = self::UNKNOWN, $table = null)
    {
        if (! is_object($name)) // If true we are expecting a Select object for this column.
  
Notice reference to ColTypem in the column constructor.  In Storm you get nice list of options for column type: see attached screenshot.
 
Note you dont need to actually implement the interface.  I just do that extra syntax sugar to show the attachment of the types.
  
Jim
 

Attachment(s):
Screen Shot 2014-11-13 at 3.28.33 AM.png
0
Avatar
Permanently deleted user

Yeah, thanks.  I've tried declaring parameters as an enum in the past but, too often, someone will want to pass colType as an INT by passing the querystring value from a dropdown selection or something and the method call fails because the parameter isn't an enum.

0
Avatar
Permanently deleted user

John,
The constants in the interface are ints.  PHP does not support C enum types, but does reserve the keyword. https://wiki.php.net/rfc/enum

Not sure what you are referring to by extending online help then.  But in a user interface you can easily build drop downs that use the numeric values as id's for each drop down value.
I cr5eate the custom types to make coding easier.

Jim

0

请先登录再写评论。