tkuchikiの日記

新ブログ https://blog.tkuchiki.net

Zend_Gdata で Declaration of ... should be compatible with that of ... が出る問題

PHP 5 で、Zend_Gdata(1.12.3) を使っていたら以下の様なエラーが。

Declaration of Zend_Gdata::import() should be compatible with Zend_Gdata_App::import($uri, $client = NULL, $className = 'Zend_Gdata...', $useObjectMapping = true)

なんだこれと思って、ぐぐってみたら
PHP E_STRICTで表示されるエラーメッセージを調べてみた - Shin x blog にまとめられていた。

継承によりメソッドをオーバーライドする場合は、継承元と同じメソッド定義にする。

Zend_Gdata と Zend_Gdata_App を見てみると、

# Zend_Gdata_App
public static function import($uri, $client = null,
          $className='Zend_Gdata_App_Feed', $useObjectMapping = true)
# Zend_Gdata_App
public static function import($uri, $client = null,
          $className='Zend_Gdata_Feed')

メソッドの定義が違う。。。

仕方なく E_STRICT 切った。
どういう経過は知らないけれど、Zend のライブラリが E_STRICT で動かないとかいいの。。。