Answer the question
In order to leave comments, you need to log in
How to teach PhpStorm to understand that fields and methods are used dynamically?
If a variable, field or method in a class is used dynamically ( how is that? ), then PhpStorm will not be able to determine this in any way, as a result, for example, functions such as Find usages for a field in a class do not work.
Sample code snippet:
<?php
class Example {
public $property1;
public $property2;
public $property3;
}
$obj = new Example();
// Случайным образом зададим значение
// в одном из трех полей (property1 / property2 / property3)
$name = 'property' . rand(1, 3);
$obj->{$name} = 'value';
Answer the question
In order to leave comments, you need to log in
Option 1 . List all properties in a @see
comment
<?php
class Example {
public $property1;
public $property2;
public $property3;
}
$obj = new Example();
/** @see Example::property1 */
/** @see Example::property2 */
/** @see Example::property3 */
$name = 'property' . rand(1, 3);
$obj->{$name} = 'value';
<?php
function ide_usage(...$args) {
// Функция ничего не делает, используется для тех редких случаев,
// когда нужно показать IDE, что тут неявно используется переменная, свойство или метод
}
class Example {
public $property1;
public $property2;
public $property3;
}
$obj = new Example();
ide_usage($obj->property1, $obj->property2, $obj->property3);
$name = 'property' . rand(1, 3);
$obj->{$name} = 'value';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question