Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Use intersection types #588

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/PhpPact/Consumer/Matcher/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace PhpPact\Consumer\Matcher;

use PhpPact\Consumer\Matcher\Exception\MatcherException;
use PhpPact\Consumer\Matcher\Exception\MatcherNotSupportedException;
use PhpPact\Consumer\Matcher\Generators\MockServerURL;
use PhpPact\Consumer\Matcher\Generators\ProviderState;
use PhpPact\Consumer\Matcher\Generators\RandomHexadecimal;
Expand Down Expand Up @@ -334,15 +333,9 @@ public function string(?string $value = null): MatcherInterface

/**
* Generates a value that is looked up from the provider state context using the given expression
*
* @throws MatcherNotSupportedException
*/
public function fromProviderState(MatcherInterface $matcher, string $expression): MatcherInterface
public function fromProviderState(MatcherInterface&GeneratorAwareInterface $matcher, string $expression): MatcherInterface
{
if (!$matcher instanceof GeneratorAwareInterface) {
throw new MatcherNotSupportedException(sprintf("Matcher '%s' must be generator aware", $matcher->getType()));
}

$matcher->setGenerator(new ProviderState($expression));

return $matcher;
Expand Down
8 changes: 0 additions & 8 deletions tests/PhpPact/Consumer/Matcher/MatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace PhpPactTest\Consumer\Matcher;

use PhpPact\Consumer\Matcher\Exception\MatcherException;
use PhpPact\Consumer\Matcher\Exception\MatcherNotSupportedException;
use PhpPact\Consumer\Matcher\Formatters\MinimalFormatter;
use PhpPact\Consumer\Matcher\Formatters\ValueOptionalFormatter;
use PhpPact\Consumer\Matcher\Generators\MockServerURL;
Expand Down Expand Up @@ -252,13 +251,6 @@ public function testString(): void
$this->assertInstanceOf(StringValue::class, $this->matcher->string('test string'));
}

public function testFromProviderStateMatcherNotSupport(): void
{
$this->expectException(MatcherNotSupportedException::class);
$this->expectExceptionMessage("Matcher 'type' must be generator aware");
$this->matcher->fromProviderState(new Type('text'), '${text}');
}

public function testFromProviderState(): void
{
$uuid = $this->matcher->uuid();
Expand Down