「Php/php7」の版間の差分
提供: 初心者エンジニアの簡易メモ
| 行25: | 行25: | ||
return $a + $b; | return $a + $b; | ||
} | } | ||
| + | |||
| + | ==継承クラスの親子でデフォルト設定も厳格に== | ||
| + | エラー詳細 | ||
| + | Warning: Declaration of ChildDao::findAllByMatchName($name, $flag) should be compatible with ParentDao::findAllByMatchName($name, $flag = NULL) | ||
| + | |||
| + | <pre> | ||
| + | ChildDao::findAllByMatchName($name, $flag) | ||
| + | ParentDao::findAllByMatchName($name, $flag = NULL) | ||
| + | </pre> | ||
| + | の2つを一致させる必要がある。 | ||
2026年4月3日 (金) 15:17時点における版
php7はスカラー型を指定できる
public function modUser(array $user): array
{
return $user;
}
型一覧
スカラー
- bool
- int
- float
- double
- string
オブジェクト
- array
- object
- callable
- resource
- null
null許容
function sum(int $a, int $b): ?int
{
return $a + $b;
}
継承クラスの親子でデフォルト設定も厳格に
エラー詳細
Warning: Declaration of ChildDao::findAllByMatchName($name, $flag) should be compatible with ParentDao::findAllByMatchName($name, $flag = NULL)
ChildDao::findAllByMatchName($name, $flag) ParentDao::findAllByMatchName($name, $flag = NULL)
の2つを一致させる必要がある。
