環境
PHP7.2
Laravel5.8
実現したいこと
関数の返り値が2種類の場合の型指定の書き方
コード
use Illuminate\View\View; use namespace Illuminate\Http\RedirectResponse; ... ... public function hoge() { if($hoge === 'first') { return view('first'); //返り値はView } else { return redirect()->action('HogeController@index');//返り値はRedirectResponse } }
public function hoge(Request $request): View || RedirectResponse {
↑的な意味合いの型指定を書きたいが、ググっても出てこずここで質問させて頂きました。
よろしくお願いいたします。

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/11 23:59
2019/06/12 00:04
2019/06/12 05:44
2024/01/12 03:48