Q:

Confused about abstract classes in php

I am building my own small framework to learn MVC. I have Controllers like this
Controller.php 
namespace Controller;

    use Latte\Engine;
    use Model\Json;

    abstract class Controller
    {
        protected $model;
        protected $latte;
        protected $json;
        protected $args = array();

        public function __construct(Engine $latte, Json $json, $model, array $args)
        {
            $this->latte = $latte;
            $this->model = $model;
            $this->args = $args;
        }
    }

and ApiController.php 
namespace Controller;

class CoinflipApiController extends Controller
{
    function index()
    {
    }

    public function getGames()
    {
        try {
            $games = $this->model->getGames();
            $this->json->generate($games);
        } catch (Exception $e) {
            $this->json->generate(array('error'=>$e->errorInfo[2]), Json::ERROR);
        }
    }
}

Why calling $this->json->generate() not work and IDE showing 'Method not found'? What I am doing wrong?

A:

Constructor of the Controller class does not make use of Json $json. It should look like that.
    public function __construct(Engine $latte, Json $json, $model, array $args)
    {
        $this->latte = $latte;
        $this->model = $model;
        $this->json  = $json;
        $this->args  = $args;
    }

