Issue with overriding MongoCollection::update

2019-08-09 02:03发布

I'm running the following version of PHP: PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 28 2012 18:19:13).

I have a class which inherits from \MongoGridFS:

class PdfGrid extends \MongoGridFS {
// ...

public function update( array $criteria , array $new_object, array $options = array()){
    $options['safe'] = true;
    if ( isset($criteria['_id']) && ! $criteria['_id'] instanceof \MongoId){
        $criteria['_id'] = new \MongoId($criteria['_id']);
    }
    return parent::update($criteria, $new_object, $options);
}
} 

Whenever I run a script that uses this class, I get the following error:

PHP Strict Standards: Declaration of YS\MongoCollection\PdfGrid::update() should be compatible with that of MongoCollection::update() in /Users/js/dev/YsInv/lib/YS/MongoCollection/PdfGrid.php on line 68

But alas, the definition matches precisely with what appears on php.net for \MongoCollection::update:

public bool|array MongoCollection::update ( array $criteria , array $new_object [, array $options = array() ] )

0条回答
登录 后发表回答