4
4
5
5
use PHPUnit \Framework \Constraint \Constraint ;
6
6
use PHPUnit \Framework \Constraint \IsEqual ;
7
- use SebastianBergmann \Exporter \Exporter ;
8
7
use Symfony \Component \DependencyInjection \Definition ;
9
8
use Symfony \Component \DependencyInjection \Exception \OutOfBoundsException ;
10
9
@@ -16,7 +15,6 @@ final class DefinitionHasArgumentConstraint extends Constraint
16
15
private string |int $ argumentIndex ;
17
16
private mixed $ expectedValue ;
18
17
private bool $ checkExpectedValue ;
19
- private Exporter $ exporter ;
20
18
21
19
public function __construct ($ argumentIndex , $ expectedValue , bool $ checkExpectedValue = true )
22
20
{
@@ -39,7 +37,6 @@ public function __construct($argumentIndex, $expectedValue, bool $checkExpectedV
39
37
$ this ->argumentIndex = $ argumentIndex ;
40
38
$ this ->expectedValue = $ expectedValue ;
41
39
$ this ->checkExpectedValue = $ checkExpectedValue ;
42
- $ this ->exporter = new Exporter ();
43
40
}
44
41
45
42
public function toString (): string
@@ -100,15 +97,16 @@ private function evaluateArgumentIndex(Definition $definition, bool $returnResul
100
97
private function evaluateArgumentValue (Definition $ definition , bool $ returnResult ): bool
101
98
{
102
99
$ actualValue = $ definition ->getArgument ($ this ->argumentIndex );
100
+ $ exporter = $ this ->exporter ();
103
101
104
102
if (gettype ($ actualValue ) !== gettype ($ this ->expectedValue )) {
105
103
$ this ->fail (
106
104
$ definition ,
107
105
sprintf (
108
106
'The value of argument named "%s" (%s) is not equal to the expected value (%s) ' ,
109
107
$ this ->argumentIndex ,
110
- $ this -> exporter ->export ($ actualValue ),
111
- $ this -> exporter ->export ($ this ->expectedValue )
108
+ $ exporter ->export ($ actualValue ),
109
+ $ exporter ->export ($ this ->expectedValue )
112
110
)
113
111
);
114
112
}
@@ -124,15 +122,15 @@ private function evaluateArgumentValue(Definition $definition, bool $returnResul
124
122
$ message = sprintf (
125
123
'The value of argument named "%s" (%s) is not equal to the expected value (%s) ' ,
126
124
$ this ->argumentIndex ,
127
- $ this -> exporter ->export ($ actualValue ),
128
- $ this -> exporter ->export ($ this ->expectedValue )
125
+ $ exporter ->export ($ actualValue ),
126
+ $ exporter ->export ($ this ->expectedValue )
129
127
);
130
128
} else {
131
129
$ message = sprintf (
132
130
'The value of argument with index %d (%s) is not equal to the expected value (%s) ' ,
133
131
$ this ->argumentIndex ,
134
- $ this -> exporter ->export ($ actualValue ),
135
- $ this -> exporter ->export ($ this ->expectedValue )
132
+ $ exporter ->export ($ actualValue ),
133
+ $ exporter ->export ($ this ->expectedValue )
136
134
);
137
135
}
138
136
0 commit comments