H
H
hesy2021-02-20 16:38:37
PHP
hesy, 2021-02-20 16:38:37

How to show hints in IDE for dynamically added methods (magic methods)?

Is it possible for dynamically added methods to display tooltips in the IDE?

Here is an example:

$class = new Mapper;

/**
 * @method int sum()
 */
$class->map('sum', fn(...$args) => array_sum($args));

echo $class->sum(1000, 300, 30, 5, 2);


Mapperthis is a conditional class that has an array with added methods and __callcalls to them.

How to make it so that when hovering over a method sum, a tooltip taken from docblock is displayed in the last line?
This example is not working, at least not in VS Code.

If you Mapperspecify in advance itself @method int sum(), then the tooltip is displayed, but it is not known in advance which methods will be added, so this option is not suitable.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question