Comments (11)
There is support for this in phpdoc. It's called @method
. Documentation: https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#711-method
Looks like intelephense already supports it and works fine.
Would look like this:
/**
* @method string getString()
* @method void setInteger(int $integer)
* @method setString(int $integer)
*/
class Child
{
<...>
}
from vscode-intelephense.
That somewhat works, maybe I am doing it wrong, but it doesn't go to the function, just where the comment is. Is there a way to use it so it goes to the method?
/**
* @method void DefaultSelect()
*/
class GameCache extends BaseGameModel{
public function scopeDefaultSelect($query, $filters){
// Do stuff
}
}
from vscode-intelephense.
Oh, I see. So in the __call you end up funneling it to the scopeDefaultSelect (as an example)? Yeah, I don't think that phpdoc allows you to mark that at least...
from vscode-intelephense.
Yeah, that is a Laravel feature for doing database queries:
https://laravel.com/docs/5.5/eloquent#local-scopes
Other frameworks may do something differently
from vscode-intelephense.
I don't think this could be really helpful as code should not depend on an editor. Adding random (and non-sense for others) phpdoc tags will 'couple' the code to one editor plugin, not even an editor, but a plugin feature, ending on dirty code. I'm in a project where some people use Atom, others Sublime or even PhpStorm. I see no reason to have code with custom stuff so each ones editor works, and I cannot imagine my self tagging a scope with @called
for me, tagging whatever method with @forwarded
so it works on some random Atom plugin and @scopedMethod
for my mate using a Sublime plugin. However, suggesting this tag to the phpDoc team may be helpful, some kind of mix between @method
and @see
from vscode-intelephense.
I did submit something after. No reply yet though
from vscode-intelephense.
I did submit something after.
Cheers mate!
I'd love to have this feature supported on phpDoc blocks
from vscode-intelephense.
Good discussion, I don't think introducing a new phpdoc tag is appropriate, I'd rather stick with current standards. @arturock mentions @see
. I wonder if this would be suitable in itself. Document _call
with @see
tags and then go to definition can provide multiple locations. It wouldn't distinguish between scopeMethodA
and scopeMethodB
but would at least provide useful information to the user to make a decision rather than just going to the @method
in the class docblock.
from vscode-intelephense.
I think the way to go here would be to use inline @see
in the @method
description.
/**
* @method void DefaultSelect() {@see GameCache::scopeDefaultSelect}
*/
class GameCache extends BaseGameModel{
public function scopeDefaultSelect($query, $filters){
// Do stuff
}
}
from vscode-intelephense.
would this also work with, as an example, laravel facades:
https://github.com/laravel/framework/blob/5.5/src/Illuminate/Support/Facades/DB.php
the @see
directive is class level and not method level. Currently when using a facade no intellisense is provided.
from vscode-intelephense.
A part of the implementation works with "barryvdh/laravel-ide-helper".
It generates descriptions for classes like as @method void DefaultSelect() {@see GameCache::scopeDefaultSelect}
.
But it doesn't work to go to the definitionm only to the class definition. Also it needs to duplicate a description of the method.
The @called
tag doesn't work with other editors. May be better to use known cases.
Laravel works with scopes as static and class methods: MyModel::myScope($var)
. But @called
and :alias:
don't change a type of the method.
I could be implemented with :alias:
as @see number_of() :alias:
to except duplicated descriptions.
https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc-tags.md#512-see
In the other case it could be implemented with the class definition and jump to the original definition (optional) though the description with ClassName::method() :alias:
or @see ClassName::method()
or @uses ClassName::method()
(they can have priorities). Also for class properties: @see self::$variable
, @uses self::$variable
.
/**
* @method static SomeType someMethod() My description. @uses ClassName::originalMethod()
* @method void someMethod2() My description. @see ClassName::originalMethod2()
* @property mixed $someProperty My description. @uses self::getProperty()
* @property mixed $someProperty2 My description. @see self::$originalProperty @see http://somedescription.com
*/
class ClassName
{
protected $originalProperty;
public function originalMethod(): SomeType
{
//
}
public function originalMethod2(): void
{
//
}
public function getProperty()
{
return someChanges($this->originalProperty);
}
/**
* @see self::getName() :alias:
*/
public function getTitle(): string
{
return $this->getName();
}
/**
* Returns a name.
*/
public function getName(): string
{
return $this->name;
}
}
from vscode-intelephense.
Related Issues (20)
- Intelephense indicates PHP SSH2 functions and constant undefined HOT 1
- `autoload-dev` seems to be ignored when renaming namespaces
- Recognizing defined constants for being objects has still an another bug
- erroneous expect type 'string' found 'void' HOT 2
- Constant marked "Undefined" in if-clause which checks if constant is defined. HOT 1
- Navigate to classes from yaml files
- Wrong type on dynamic object with string|null
- Enhance type recognition for values in SplDoublyLinkedList
- assert diagnostics
- Syntax error with dynamic enum access in PHP 8.3
- Unexpected P1010 Undefined function error for oci_set_prefetch_lob
- Process Itelephense filters on folders
- Autocomplete functions and attributes of variables in debug console
- Invalid Namespace definition
- I can't go to the method definition HOT 2
- PHP open and close brackets always seem to be misaligned when with HTML HOT 1
- Undefined method 'createToken'. P1013 HOT 1
- Add references HOT 1
- Laravel No definition found for .... HOT 1
- intelephense indexing take too long time HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-intelephense.