I am reading zend Framework quick start:
There is a function in the Mapper class:
public function save(Application_Model_Guestbook $guestbook)
{
$data = array(
'email' => $guestbook->getEmail(),
'comment' => $guestbook->getComment(),
'created' => date('Y-m-d H:i:s'),
);
if (null === ($id = $guestbook->getId())) {
unset($data['id']);
$this->getDbTable()->insert($data);
} else {
$this->getDbTable()->update($data, array('id = ?' => $id));
}
}
I dont understand the meaning or relevance of having a class name as an argument, nor can I see how such a thing is allowed in php5 since there is no reference in the php.net manual.
This is type hinting in action. The function save
will only accept an instance of Application_Model_Guestbook
as an argument. If you try to pass anything else, PHP will complain.
http://php.net/manual/en/language.oop5.typehinting.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With