「Php/php8」の版間の差分
提供: 初心者エンジニアの簡易メモ
| (同じ利用者による、間の4版が非表示) | |||
| 行1: | 行1: | ||
| + | ==基底クラスのメソッドの引数の数が合わない== | ||
| + | zendのZend_Db_Table_Abstractを使ったクラスで、 | ||
| + | public function fetchRow($where) | ||
| + | を使ってたので、以下エラーがでた。 | ||
| + | <pre> | ||
| + | Method 'AbstractScoreDao::fetchRow()' is not compatible with method 'AbstractDao::fetchRow()'.intelephense(P1038) AbstractScoreDao::fetchRow | ||
| + | </pre> | ||
| + | 対策として、基底クラスのメソッドの引数に、合わせる。 | ||
| + | public function fetchRow($where = null, $order = null, $offset = null) | ||
| + | |||
==クラス名の関数をconstructとして完全に使えなくなった== | ==クラス名の関数をconstructとして完全に使えなくなった== | ||
php7までは非推奨で、php8からは、完全に使えない。 | php7までは非推奨で、php8からは、完全に使えない。 | ||
| 行26: | 行36: | ||
<pre> | <pre> | ||
{{include file="parts/box.tpl" request=$request wordlike=$wordlike|default:''}} | {{include file="parts/box.tpl" request=$request wordlike=$wordlike|default:''}} | ||
| + | </pre> | ||
| + | ===smartyのテンプレのincludeで使ってない配列変数の警告対応=== | ||
| + | エラー詳細 | ||
| + | Warning: Undefined array key "request" | ||
| + | 修正前 | ||
| + | <pre> | ||
| + | {{include file="parts/box.tpl" request=$request}} | ||
| + | </pre> | ||
| + | 修正後 | ||
| + | <pre> | ||
| + | {{include file="parts/box.tpl" request=$request|default:[]}} | ||
</pre> | </pre> | ||
| − | == | + | ===smarty3について、php8だとエラーが出る=== |
| − | + | 2026/4時点の最新smarty3.1.48だと、エラーがでる。 | |
<pre> | <pre> | ||
| − | + | Fatal error: Type of SmartyCompilerException::$line must be int (as in class Exception) in smarty-3.1.48/libs/sysplugins/smartycompilerexception.php on line 8 | |
| + | </pre> | ||
| − | Warning: Undefined array key "start_template_time" in smarty-3.1. | + | ===smarty3について、php8だと警告が出る=== |
| + | smarty3.1.39に落としても、別の箇所で、警告がでる。 | ||
| + | <pre> | ||
| + | Warning: Undefined array key "start_time" in smarty-3.1.48/libs/sysplugins/smarty_internal_debug.php on line 146 | ||
| + | Warning: Undefined array key "start_template_time" in smarty-3.1.48/libs/sysplugins/smarty_internal_debug.php on line 73 | ||
</pre> | </pre> | ||
2026年4月25日 (土) 02:41時点における最新版
目次
基底クラスのメソッドの引数の数が合わない
zendのZend_Db_Table_Abstractを使ったクラスで、
public function fetchRow($where)
を使ってたので、以下エラーがでた。
Method 'AbstractScoreDao::fetchRow()' is not compatible with method 'AbstractDao::fetchRow()'.intelephense(P1038) AbstractScoreDao::fetchRow
対策として、基底クラスのメソッドの引数に、合わせる。
public function fetchRow($where = null, $order = null, $offset = null)
クラス名の関数をconstructとして完全に使えなくなった
php7までは非推奨で、php8からは、完全に使えない。 __construnct()にする。
smartyのテンプレの使ってない変数の警告対応
エラー詳細
Warning: Undefined array key "key"
修正前
{{if $request.key}}
修正後
{{if isset($request.key)}}
smartyのテンプレのincludeで使ってない変数の警告対応
エラー詳細
Warning: Undefined array key "wordlike"
修正前
{{include file="parts/box.tpl" request=$request wordlike=$wordlike|default:''}}
修正後
{{include file="parts/box.tpl" request=$request wordlike=$wordlike|default:''}}
smartyのテンプレのincludeで使ってない配列変数の警告対応
エラー詳細
Warning: Undefined array key "request"
修正前
{{include file="parts/box.tpl" request=$request}}
修正後
{{include file="parts/box.tpl" request=$request|default:[]}}
smarty3について、php8だとエラーが出る
2026/4時点の最新smarty3.1.48だと、エラーがでる。
Fatal error: Type of SmartyCompilerException::$line must be int (as in class Exception) in smarty-3.1.48/libs/sysplugins/smartycompilerexception.php on line 8
smarty3について、php8だと警告が出る
smarty3.1.39に落としても、別の箇所で、警告がでる。
Warning: Undefined array key "start_time" in smarty-3.1.48/libs/sysplugins/smarty_internal_debug.php on line 146 Warning: Undefined array key "start_template_time" in smarty-3.1.48/libs/sysplugins/smarty_internal_debug.php on line 73
Staticがついてないエラー
Staticコールが、できなくなって強制的に、エラー画面がでる。
エラー詳細
Non-static method SessionModel::getInstance() cannot be called statically
対応前
public function getInstance()
対応後
public static function getInstance()
list取得が配列が存在しない警告になる場合
エラー詳細
Warning: Undefined array key 1
修正前
list($dummy, $dummy, $uri_domain) = explode("/", $target);
修正後
$parts = explode("/", $target, 3);
$uri_domain = $parts[2] ?? ;
