N
N
Nurlan2015-01-29 18:14:43
PHP
Nurlan, 2015-01-29 18:14:43

PHPDoc for autocompletion with a crooked autoloader?

A long time ago I came to a project in which all classes are called through a singleton manager. Everything would be fine, but because of this it is difficult with auto-completion.
Roughly everything is like this:

class ClassManager {

  private $objects;

  function __get($name) {
    if (isset($this->objects[$name])) {
      return $this->objects[$name];
    } else {
      $file = $this->getFileName($name);
      $file_path = $_SERVER['DOCUMENT_ROOT'] . '/' .$file;
      if ($file AND file_exists($file_path)) {
        require_once($file_path);
        $this->objects[$name] = new $name();
        return $this->objects[$name];
      }
      return (object) $temp;
    }
  }

  private function getFileName($name) {
    return $name;
  }
}

class CM {
  static $init = NULL;
  static function init() {
    self::$init = new ClassManager();
  }
}

And the classes are called like this:
CM::$init->Shab->и_название_метода_вспоминай_сам
What can you advise? There is no time to rewrite all this now ...
Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Supme, 2015-01-29
@daager

I remember when I looked at Phalcon, there are configs for different IDEs with lists of classes and functions, you can see how it was done and do it yourself. In Phpstorm the plugin worked.

O
OnYourLips, 2015-01-29
@OnYourLips

@method, @property
But it's like a dead poultice.

B
Boris Benkovsky, 2015-01-30
@benbor

/** @var $instance MyMegaShabClass */
$instance = CM::$init->Shab;
$instance->и_название_метода_подскажет_IDEA

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question