0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Laravel、FormRequestで$thisにアクセスできない

0
Posted at

エラー

Uncaught Error: Call to a member function get() on null__clone method called on non-object {””, "exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): __clone method called on non-object at /var/www/local/vendor/symfony/http-foundation/Request.php:512)

原因

原因は自作FormRequestの中で定義したconstructorの継承忘れミス。
祖先のvendor/symfony/http-foundation/Requestのcloneで引っ掛かっていた。
メンバ変数が定義できていなかったから?なぜcloneが呼び出されたのかわからないが、
エラーと原因が結び付かずはまった。

public function __clone()
{
    $this->query = clone $this->query;
  $this->request = clone $this->request;
  $this->attributes = clone $this->attributes;
  $this->cookies = clone $this->cookies;
  $this->files = clone $this->files;
  $this->server = clone $this->server;
  $this->headers = clone $this->headers;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?