B
B
bio2016-05-20 09:23:50
PHP
bio, 2016-05-20 09:23:50

Is it possible to make my own auto-substitution depending on the context in PhpStorm?

Good afternoon!
Is it possible to do, for example, in this case, 891c83cd4e.pngauto-substitution of certain classes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Ninazu, 2016-05-23
@Ninazu

I think you need to use not an array but an object. Then everything will fly)

/**
 * @property string $key;
 * @property string $foreign_key;
 * @property string $repository;
 */
class Helper {

  private $data;
  
  public function __construct($data) {
    $this->data = $data;
  }

  public function __set($name, $value) {
    $this->data[$name] = $value;
  }

  public function __get($name) {
    return isset($this->data[$name]) ? $this->data[$name] : null;
  }
}

$test = new Helper(array(
  'key'=>12,
  'foreign_key'=>'id',
  'repository'=>'',
));

echo $test->key;
$test->key = '23';
echo $test->key;

Well, or explicitly list the classes in the dock
class C1 {

  public $name;
}

class C2 {

  public $age;
}

class Helper {
  /**
   * @var C1|C2
   */
  public static $app;
}


Helper::$app->age

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question