Reading the documentation of phalcon https://docs.phalconphp.com/en/3.0.0/reference/views.html I found that it's possible to pass variables from the controller to the view in 2 different ways:
Using setVar()
$this->view->setVar("username", $user->username);
$this->view->setVar("posts", $posts;
Using the magic setter
$this->view->username = $user->username;
$this->view->posts = $posts;
What's the difference between the two and what is the magic setter really, I couldn't find what it is.
Only difference is return value.
Method setVar return $this, magic setter return void.
Check this: https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/view.zep#L1373 and compare with this: https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/view.zep#L450
The difference is performance. Better to use setVar
method. Of course in real world the difference will be none with setting two variables.