4

我有以下模型:

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

        //do stuff

     }
     return parent::save($conn);

    }
}

我觉得我正在遵循Doctrine_Record::save()签名的 API 描述(除了奇怪的括号,我会给我一个语法错误......)。

当我运行此代码时,它运行良好 ,但我收到以下警告:

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

我通常将错误报告转为 ERROR_ALL,并尝试坚持使用无警告代码。这让我很困扰。我检查了所有的 Doctrine 源代码并用 greped “保存(”,在它上面,一个接一个地尝试一个签名。什么都没有。PHP 第一次让我太宽容了,奇怪 hu :-) ?

4

2 回答 2

16

保存方法的正确签名应该是:

public function save(Doctrine_Connection $conn = null)
于 2009-06-03T07:09:15.037 回答
0

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.

于 2010-02-08T18:39:20.660 回答