我开始为预定义的PHP包编写一个包装类.以下是课程:
原文链接:https://www.f2er.com/php/132102.htmlclass PHPclass1 :: ping() :: __construct(array $options) :: clear() :: addDoc(PHPclass2 $string) ... class PHPclass2 :: __construct() :: update() ...
以下是我为上述2类编写的包装类:
class wrapper1 { private $conn; public function __construct(PHPclass1 $object) { $this->conn = $object; } public function add(wrapper2 $document) { return $this->conn->addDoc($document); } } class wrapper2 extends PHPclass2 { private $doc; public function __construct() { $this->doc = new PHPclass2(); } } Here's how I'm using them: $options = array (...); $object = new PHPclass1($options); $conn = new wrapper1($object); $doc = new wrapper2(); .... .... $conn->add($doc);
一切正常,直到我使用add函数.它给出一个错误:参数1传递给PHPclass1 :: addDoc()必须是一个PHPclass2的实例,wrapper2的实例给定
我失踪了什么我已经尝试了许多事情,但完全失去了这里.