44
55use PHPUnit \Framework \Constraint \Constraint ;
66use PHPUnit \Framework \Constraint \IsEqual ;
7- use SebastianBergmann \Exporter \Exporter ;
87use Symfony \Component \DependencyInjection \Definition ;
98use Symfony \Component \DependencyInjection \Exception \OutOfBoundsException ;
109
@@ -16,7 +15,6 @@ final class DefinitionHasArgumentConstraint extends Constraint
1615 private string |int $ argumentIndex ;
1716 private mixed $ expectedValue ;
1817 private bool $ checkExpectedValue ;
19- private Exporter $ exporter ;
2018
2119 public function __construct ($ argumentIndex , $ expectedValue , bool $ checkExpectedValue = true )
2220 {
@@ -39,7 +37,6 @@ public function __construct($argumentIndex, $expectedValue, bool $checkExpectedV
3937 $ this ->argumentIndex = $ argumentIndex ;
4038 $ this ->expectedValue = $ expectedValue ;
4139 $ this ->checkExpectedValue = $ checkExpectedValue ;
42- $ this ->exporter = new Exporter ();
4340 }
4441
4542 public function toString (): string
@@ -100,15 +97,16 @@ private function evaluateArgumentIndex(Definition $definition, bool $returnResul
10097 private function evaluateArgumentValue (Definition $ definition , bool $ returnResult ): bool
10198 {
10299 $ actualValue = $ definition ->getArgument ($ this ->argumentIndex );
100+ $ exporter = $ this ->exporter ();
103101
104102 if (gettype ($ actualValue ) !== gettype ($ this ->expectedValue )) {
105103 $ this ->fail (
106104 $ definition ,
107105 sprintf (
108106 'The value of argument named "%s" (%s) is not equal to the expected value (%s) ' ,
109107 $ this ->argumentIndex ,
110- $ this -> exporter ->export ($ actualValue ),
111- $ this -> exporter ->export ($ this ->expectedValue )
108+ $ exporter ->export ($ actualValue ),
109+ $ exporter ->export ($ this ->expectedValue )
112110 )
113111 );
114112 }
@@ -124,15 +122,15 @@ private function evaluateArgumentValue(Definition $definition, bool $returnResul
124122 $ message = sprintf (
125123 'The value of argument named "%s" (%s) is not equal to the expected value (%s) ' ,
126124 $ this ->argumentIndex ,
127- $ this -> exporter ->export ($ actualValue ),
128- $ this -> exporter ->export ($ this ->expectedValue )
125+ $ exporter ->export ($ actualValue ),
126+ $ exporter ->export ($ this ->expectedValue )
129127 );
130128 } else {
131129 $ message = sprintf (
132130 'The value of argument with index %d (%s) is not equal to the expected value (%s) ' ,
133131 $ this ->argumentIndex ,
134- $ this -> exporter ->export ($ actualValue ),
135- $ this -> exporter ->export ($ this ->expectedValue )
132+ $ exporter ->export ($ actualValue ),
133+ $ exporter ->export ($ this ->expectedValue )
136134 );
137135 }
138136
0 commit comments