Laravel9 エラーチェックにPHP-Stanを利用しています。
PHP-Stan実行後にファイル(ContactsSendmail.php)以下の箇所で、「has no type specified. とエラーが出ます。
しかし、このエラーの解決方法がわかりません。
エラーが出ている変数に型を定義してあげれば良いのだと思うのですが、いろんなサイト参考にいろんな書き方をしてもだめでした。
PHPStaのエラー内容によってはignoreしても良い。という記事も見受けられるのですが、拙い知識のため今回のPHPStanのエラーはどうしようもないのか、解決できるのか。の判断もわかりません。。。
解決方法があれば、教えてください。
ContactsSendmail.php
1<?php 2 3namespace App\Mail; 4 5use Illuminate\Bus\Queueable; 6use Illuminate\Contracts\Queue\ShouldQueue; 7use Illuminate\Mail\Mailable; 8use Illuminate\Queue\SerializesModels; 9class ContactsSendmail extends Mailable 10{ 11 use Queueable, SerializesModels; 12 13 // プロパティを定義 14 private $radio; 15 private $company_name; 16 private $contact_name_form; 17 private $kana; 18 private $tell; 19 private $zip; 20 private $add; 21 private $contact_body;
PHPStan
1------ ------------------------------------------------------------------------------- 2 Line app/Mail/ContactsSendmail.php 3 ------ ------------------------------------------------------------------------------- 4 13 Property App\Mail\ContactsSendmail::$radio has no type specified. 5 14 Property App\Mail\ContactsSendmail::$company_name has no type specified. 6 15 Property App\Mail\ContactsSendmail::$contact_name_form has no type specified. 7 16 Property App\Mail\ContactsSendmail::$kana has no type specified. 8 17 Property App\Mail\ContactsSendmail::$tell has no type specified. 9 18 Property App\Mail\ContactsSendmail::$zip has no type specified. 10 19 Property App\Mail\ContactsSendmail::$add has no type specified. 11 20 Property App\Mail\ContactsSendmail::$contact_body has no type specified. 12 ------ -------------------------------------------------------------------------------
ファイル全体は以下です。
ContactsSendmail.php
1<?php 2 3namespace App\Mail; 4 5use Illuminate\Bus\Queueable; 6use Illuminate\Contracts\Queue\ShouldQueue; 7use Illuminate\Mail\Mailable; 8use Illuminate\Queue\SerializesModels; 9class ContactsSendmail extends Mailable 10{ 11 use Queueable, SerializesModels; 12 // プロパティを定義 13 private $radio; 14 private $company_name; 15 private $contact_name_form; 16 private $kana; 17 private $tell; 18 private $zip; 19 private $add; 20 private $contact_body; 21 22 /** 23 * Create a new message instance. 24 * 25 * @return void 26 *@param array $inputs 27 */ 28 public function __construct($inputs) 29 { 30 // コンストラクタでプロパティに値を格納 31 $this->radio = $inputs['radio']; 32 $this->company_name = $inputs['company_name']; 33 $this->contact_name_form = $inputs['contact_name_form']; 34 $this->kana = $inputs['kana']; 35 $this->tell = $inputs['tell']; 36 $this->zip = $inputs['zip']; 37 $this->add = $inputs['add']; 38 $this->email = $inputs['email']; 39 $this->contact_body = $inputs['contact_body']; 40 } 41 42 /** 43 * Build the message. 44 * 45 * @return $this 46 */ 47 public function build() 48 { 49 // メールの設定 50 return $this 51 ->from('hello@example.com') 52 ->subject('自動送信メール') 53 ->view('contact.mail') 54 ->with([ 55 'radio' => $this->radio, 56 'company_name' => $this->company_name, 57 'contact_name_form' => $this->contact_name_form, 58 'kana' => $this->kana, 59 'tell' => $this->tell, 60 'zip' => $this->zip, 61 'add' => $this->add, 62 'email' => $this->email, 63 'contact_body' => $this->contact_body, 64 ]); 65 } 66} 67

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/10/29 01:51
2022/10/29 02:03 編集
2022/10/29 02:54
2022/10/29 03:42