DI improvement (simplify debugging)

Currently we need to add everywhere links to created objects like $this->di, $this->view and others. When you try to print ($this) you'll see 2megabytes of some text with recursions or something like that.

Implementing behavior with php magick get method, or just use classic Getters getDI() we dont spam scratch in class scope. That stuff can be implemented via Traits and added... in every class registered in phalcon. Just

public function `__get($name)`
  if in_array($name, $diNames)
    return $this->{'get' . uc_first($name)};

no more



77.7k

you are probably right, i dont know.

i use xdebug and var_dump for that reason, otherwise print_r you cant see sh*t in it ...

edited Apr '18

printing out a variable is not the best of debugging options.

$this will only contain services if it was called through the object context ($this-view->...), $this->getDI()->get('view') will not "pollute" your instance.

What youre proposing would work, but will introduce backwards incompatibility, and also negate the ease with which services can be accessed ($this->view->...)

EDIT: Here's the magic __get logic from the source: https://github.com/phalcon/cphalcon/blob/master/phalcon/di/injectable.zep#L119