From 67fbaaa64e0e431472da24976d2811eb86548d17 Mon Sep 17 00:00:00 2001 From: ju1ius Date: Thu, 15 Feb 2024 14:00:41 +0100 Subject: [PATCH] removes implicit dependency on sebastian/exporter Closes #158 --- PhpUnit/DefinitionHasArgumentConstraint.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/PhpUnit/DefinitionHasArgumentConstraint.php b/PhpUnit/DefinitionHasArgumentConstraint.php index 5e58d68..894164a 100644 --- a/PhpUnit/DefinitionHasArgumentConstraint.php +++ b/PhpUnit/DefinitionHasArgumentConstraint.php @@ -4,7 +4,6 @@ use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\Constraint\IsEqual; -use SebastianBergmann\Exporter\Exporter; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException; @@ -16,7 +15,6 @@ final class DefinitionHasArgumentConstraint extends Constraint private string|int $argumentIndex; private mixed $expectedValue; private bool $checkExpectedValue; - private Exporter $exporter; public function __construct($argumentIndex, $expectedValue, bool $checkExpectedValue = true) { @@ -39,7 +37,6 @@ public function __construct($argumentIndex, $expectedValue, bool $checkExpectedV $this->argumentIndex = $argumentIndex; $this->expectedValue = $expectedValue; $this->checkExpectedValue = $checkExpectedValue; - $this->exporter = new Exporter(); } public function toString(): string @@ -100,6 +97,7 @@ private function evaluateArgumentIndex(Definition $definition, bool $returnResul private function evaluateArgumentValue(Definition $definition, bool $returnResult): bool { $actualValue = $definition->getArgument($this->argumentIndex); + $exporter = $this->exporter(); if (gettype($actualValue) !== gettype($this->expectedValue)) { $this->fail( @@ -107,8 +105,8 @@ private function evaluateArgumentValue(Definition $definition, bool $returnResul sprintf( 'The value of argument named "%s" (%s) is not equal to the expected value (%s)', $this->argumentIndex, - $this->exporter->export($actualValue), - $this->exporter->export($this->expectedValue) + $exporter->export($actualValue), + $exporter->export($this->expectedValue) ) ); } @@ -124,15 +122,15 @@ private function evaluateArgumentValue(Definition $definition, bool $returnResul $message = sprintf( 'The value of argument named "%s" (%s) is not equal to the expected value (%s)', $this->argumentIndex, - $this->exporter->export($actualValue), - $this->exporter->export($this->expectedValue) + $exporter->export($actualValue), + $exporter->export($this->expectedValue) ); } else { $message = sprintf( 'The value of argument with index %d (%s) is not equal to the expected value (%s)', $this->argumentIndex, - $this->exporter->export($actualValue), - $this->exporter->export($this->expectedValue) + $exporter->export($actualValue), + $exporter->export($this->expectedValue) ); }