views:

1261

answers:

2

I have the following model :

class Model extends BaseModel
{
   public function save($conn = null)
   {
      if(!$this->getId())
      {

        //do stuff

     }
     return parent::save($conn);

    }
}

I feel like I am follwing the API description of Doctrine_Record::save() signature (Except the weird parenthesis I would give me a syntax error...).

When I run this code, it works well but I get the following warning :

Strict Standards: Declaration of Model::save() should be compatible with that of Doctrine_Record::save() in $ROOT/lib/model/doctrine/Model.class.php on line 6

I usually turn error reporting to ERROR_ALL, and try to stick with a warning free code. This bother me. I checkout all the Doctrine source code and greped "save(", on it, trying one signature after an other. Nothing. First time PHP got me for being too permissive, strange hu :-) ?

+7  A: 

The correct signature for the save method should be:

public function save(Doctrine_Connection $conn = null)
bb
Thanks ! Of course, I should have got that. Now you can use an object in PHP to enforce a type (but not a basic type like an integer if I remember). Feels like PHP is trying to catch up with Java :-p
e-satis
A: 

On a side note: On other functions you may get this error but you will need to use function($event) in place of the above.