Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow @see tags to get actual definition #193

Closed
1234ru opened this issue Oct 29, 2021 · 6 comments
Closed

Follow @see tags to get actual definition #193

1234ru opened this issue Oct 29, 2021 · 6 comments
Labels
type: documentation Not an issue, but rather a document describing how something works

Comments

@1234ru
Copy link

1234ru commented Oct 29, 2021

PhpDoc has @see tag, which allows to reference methods and properties of the class.

In it's current implementation it doesn't affect autocompletion.

But it would be great if we could do something like that:

class Declarations {
    /**
     * @var = [
     *     'name' => string,
     *     'email' => string,
     *     'phone' => string
     * ]
     */
    public $user;
}

/**
 * @param $u {@see Declarations::$user}
 */
function do_someting($u) {
    $u['']; // suggests 'name', 'email' or 'phone'
}

This would make PHP much more convenient language, allowing to describe data structures in one particular place and reference to it anywhere we want — the feature native PHP lacks to this day.

P.S. Привет русскоязычным!

@klesun
Copy link
Owner

klesun commented Oct 29, 2021

Hi.
The plugin already has a similar format supported:

/**
 * @param $u = Declarations::$user
 */

image

P.S. Русскоязычные приветствуют в ответ!

@klesun klesun closed this as completed Oct 29, 2021
@klesun klesun added the type: documentation Not an issue, but rather a document describing how something works label Oct 29, 2021
@1234ru
Copy link
Author

1234ru commented Oct 29, 2021

That is just great! Your plugin is very helpful.

@1234ru
Copy link
Author

1234ru commented Oct 29, 2021

One little thing: IDE doesn't suggest autocompletion after = sign:

1

It also does not suggest property names:

2

So, I guess, one way here is to go to property's definition, press Ctrl+Alt+C to get a reference to it:

3

then paste the reference where it should be:

4

@1234ru
Copy link
Author

1234ru commented Oct 29, 2021

Sadly, IDE doesn't treat that as references, and if the class or variable is renamed, it won't affect the definition:

5

@1234ru
Copy link
Author

1234ru commented Oct 29, 2021

Also it does not support nested references like ClassName::property::subproperty:

<?php

class Declarations {
    /**
     * @var = [
     *     'name' => string,
     *     'email' => string,
     *     'phone' => string
     * ]
     */
    public $user;
}

class Another {

    /** @var Declarations */
    public $D;

    /**
     * @param $arg = self::$D::$user
     */
    function foo($arg) {
        $arg['']; // Doesn't suggest here
    }
}

/**
 * @param $u = Another::$D::user
 */
function do_someting($u) {
    $u['']; // Doesn't suggest here as well
}

I apologize for putting comments in such chaotic way. I didn't expect to find all this out. But I want those observations to be kept somewhere.

@klesun
Copy link
Owner

klesun commented Oct 29, 2021

no problem, github will handle it =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation Not an issue, but rather a document describing how something works
Projects
None yet
Development

No branches or pull requests

2 participants