Skip to content

Commit

Permalink
[5.7] Auth/Access/Response::__toString method always should return st…
Browse files Browse the repository at this point in the history
…ring.

 __toString should return string, in other case it will emit the FatalError.
  • Loading branch information
TBlindaruk committed Sep 9, 2018
1 parent a8cf7f4 commit 6e8431d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Access/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function message()
/**
* Get the string representation of the message.
*
* @return string|null
* @return string
*/
public function __toString()
{
return $this->message();
return (string) $this->message();
}
}
21 changes: 21 additions & 0 deletions tests/Auth/AuthAccessResponseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Illuminate\Tests\Auth;

use PHPUnit\Framework\TestCase;
use Illuminate\Auth\Access\Response;

class AuthAccessResponseTest extends TestCase
{
/**
* @return void
*/
public function testStringMethodWillReturnString()
{
$response = new Response('some data');
$this->assertSame('some data', (string) $response);

$response = new Response();
$this->assertSame('', (string) $response);
}
}

0 comments on commit 6e8431d

Please sign in to comment.