1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

StateBearer must be constructable from State

This commit is contained in:
Aidan Woods 2021-10-15 23:18:08 +01:00
parent 4af22ec41a
commit 421a2393d0
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
3 changed files with 20 additions and 0 deletions

View File

@ -107,6 +107,12 @@ final class State implements StateBearer
return $this;
}
/** @return self */
public static function fromState(State $State)
{
return $State;
}
public function isolatedCopy(): self
{
return new self(\array_map(

View File

@ -5,4 +5,6 @@ namespace Erusev\Parsedown;
interface StateBearer
{
public function state(): State;
/** @return static */
public static function fromState(State $State);
}

View File

@ -39,4 +39,16 @@ final class StateTest extends TestCase
{
$this->assertInstanceOf(State::class, clone(new State));
}
/**
* @return void
* @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function testStateFromStateIdentical()
{
$State = new State;
$this->assertSame($State, State::fromState($State));
}
}