1

I am using CakePHP 2.2.4 and Mongodb 2.2.2

I have worked through a couple of issues but am getting the following errors on my cakephp homepage

Strict (2048): Declaration of MongodbSource::execute() should be compatible with DboSource::execute($sql, $options = Array, $params = Array) [APP/Plugin/Mongodb/Model/Datasource/MongodbSource.php, line 36]

I get a similar error for these function declarations

  • MongodbSource::query()
  • MongodbSource::create()
  • MongodbSource::read()
  • MongodbSource::update()
  • MongodbSource::delete()
  • MongodbSource::calculate()
  • MongodbSource::group()
  • MongodbSource::dropSchema()
  • MongodbSource::describe()

MongodbSource extends DbSource

in DbSource:

public function execute($sql, $options = array(), $params = array()) { <code here> }

in MongodbSource:

public function execute($query, $params = array()) { <code here> }

I kind of understand whats going on but I am not sure how to fix it.

dogmatic69
  • 7,574
  • 4
  • 31
  • 49
zkent
  • 980
  • 1
  • 10
  • 22
  • Ok I have gotten past the error by updating cakephp, /app/Config/core.php and adding `& ~E_STRICT` to the ErrorHandler. I realize that this isn't Best Practices and doesn't fix the problem. I still want to know how I can fix it. – zkent Dec 16 '12 at 04:32

1 Answers1

1

Methods that override parent methods should implement the same arguments, ie your execute methods signature in MongodbSource should be:

public function execute($sql, $options = array(), $params = array())

See also:

Declaration of Methods should be Compatible with Parent Methods in PHP

https://www.google.com/search?q=php+Declaration+of+should+be+compatible+with

http://php.net/manual/en/migration51.oop.php#migration51.oop-inheritance

Community
  • 1
  • 1
ndm
  • 59,784
  • 9
  • 71
  • 110
  • 1
    Spot on. We also found some code changes that were submitted at the github site that addressed most of the issues. https://github.com/ichikaway/cakephp-mongodb/pull/65 – zkent Dec 17 '12 at 14:53