Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting this Strict Standards message?

I have created a Zend Framework model by extending Zend_Db_Table_Absract as follows (simplified example):

class Foos extends Zend_Db_Table_Abstract
{
    protected $_schema = 'Foo';
    protected $_name = 'Foos';
    protected $_primary = 'id';
    protected $_sequence = true;

    public function insert($data) {
        $db = $this->getAdapter();
        $record = array('field1' => $data['field1'],
                        'field2' => $data['field2'],
                        ...
                );
        return parent::insert($record);
    }
}

The above correctly inserts a record. The problem is, I keep getting the following notice:

Strict Standards: Declaration of Foos::insert() should be compatible with that of Zend_Db_Table_Abstract::insert() in /x/x/x/Foo.php on line XX

As far as I can tell from having read the documentation and API several times, the way I am doing it is correct. I am aware that I can turn off E_STRICT but I would much rather know why I am getting the above notice. Any ideas? (PHP 5.3, Zend Framework 1.10)

like image 746
karim79 Avatar asked Dec 07 '22 00:12

karim79


1 Answers

Mchl is mostly correct but the error you're getting is from the parameter not matching exactly i.e.:

public function insert($data) {

should be:

public function insert(array $data) {

note the array type specifier before $data, the mixed you're seeing is the return type, the argument type is array.

like image 70
Viper_Sb Avatar answered Dec 14 '22 23:12

Viper_Sb