构造函数类型提示中的依赖注入不起作用


Dependency injection in constructor - type hinting not working

我有这样的代码:

<?php
namespace Http'Models;
class DbModel {
    private $dbh;
    public function __construct( 'Ilib'Database'Database $dbh ) { 
        $this->dbh = $dbh;     
    }
    public function select(){
        $this->dbh->query( "SELECT * from prednasky ORDER by mesic ASC" );  }
    } 
}

我看到错误:

Catchable fatal error: Argument 1 passed to Http'Models'DbModel::__construct() must be an instance of Ilib'Database'Database, none given, where Ilib'Database'Database is the connection into the pdo db.

但是我的问题是,我在哪里可以创建一个新的实例?这个例子看起来怎么样?

$database = new 'Ilib'Database'Database();
$model = new DbModel($database);