10000 Remove eval trick · symfony/symfony@072684c · GitHub
[go: up one dir, main page]

Skip to content

Commit 072684c

Browse files
committed
Remove eval trick
1 parent 1355464 commit 072684c

38 files changed

+96
-121
lines changed

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function provideUniquenessConstraints(): iterable
193193
'em' => self::EM_NAME,
194194
])];
195195

196-
yield 'Named arguments' => [eval('return new \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity(message: "myMessage", fields: ["name"], em: "foo");')];
196+
yield 'Named arguments' => [new UniqueEntity(message: 'myMessage', fields: ['name'], em: 'foo')];
< F438 /td>
197197
}
198198

199199
/**
@@ -227,7 +227,7 @@ public function provideConstraintsWithCustomErrorPath(): iterable
227227
'errorPath' => 'bar',
228228
])];
229229

230-
yield 'Named arguments' => [eval('return new \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity(message: "myMessage", fields: ["name"], em: "foo", errorPath: "bar");')];
230+
yield 'Named arguments' => [new UniqueEntity(message: 'myMessage', fields: ['name'], em: 'foo', errorPath: 'bar')];
231231
}
232232

233233
/**
@@ -286,7 +286,7 @@ public function provideConstraintsWithIgnoreNullDisabled(): iterable
286286
'ignoreNull' => false,
287287
])];
288288

289-
yield 'Named arguments' => [eval('return new \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity(message: "myMessage", fields: ["name", "name2"], em: "foo", ignoreNull: false);')];
289+
yield 'Named arguments' => [new UniqueEntity(message: 'myMessage', fields: ['name', 'name2'], em: 'foo', ignoreNull: false)];
290290
}
291291

292292
/**
@@ -333,7 +333,7 @@ public function provideConstraintsWithIgnoreNullEnabled(): iterable
333333
'ignoreNull' => true,
334334
])];
335335

336-
yield 'Named arguments' => [eval('return new \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity(message: "myMessage", fields: ["name", "name2"], em: "foo", ignoreNull: true);')];
336+
yield 'Named arguments' => [new UniqueEntity(message: 'myMessage', fields: ['name', 'name2'], em: 'foo', ignoreNull: true)];
337337
}
338338

339339
public function testValidateUniquenessWithValidCustomErrorPath()
@@ -432,7 +432,7 @@ public function provideConstraintsWithCustomRepositoryMethod(): iterable
432432
'repositoryMethod' => 'findByCustom',
433433
])];
434434

435-
yield 'Named arguments' => [eval('return new \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity(message: "myMessage", fields: ["name"], em: "foo", repositoryMethod: "findByCustom");')];
435+
yield 'Named arguments' => [new UniqueEntity(message: 'myMessage', fields: ['name'], em: 'foo', repositoryMethod: 'findByCustom')];
436436
}
437437

438438
/**

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
192192
return (string) $env;
193193
}
194194

195-
if (in_array($prefix, ['bool', 'not'], true)) {
195+
if (\in_array($prefix, ['bool', 'not'], true)) {
196196
$env = (bool) (filter_var($env, \FILTER_VALIDATE_BOOLEAN) ?: filter_var($env, \FILTER_VALIDATE_INT) ?: filter_var($env, \FILTER_VALIDATE_FLOAT));
197197

198198
return 'not' === $prefix ? !$env : $env;

src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.expected

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_max_age.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ public static function tearDownAfterClass(): void
4242
*/
4343
public function testCookie($fixture)
4444
{
45-
if ('cookie_max_age' === $fixture) {
46-
$this->markTestSkipped('This fixture produces a fatal error on PHP 8.');
47-
}
48-
4945
$result = file_get_contents(sprintf('http://localhost:8054/%s.php', $fixture));
5046
$this->assertStringMatchesFormatFile(__DIR__.sprintf('/Fixtures/response-functional/%s.expected', $fixture), $result);
5147
}

src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function provideServiceValidatedConstraints(): iterable
3737
{
3838
yield 'Doctrine style' => [new UserPassword(['service' => 'my_service'])];
3939

40-
yield 'named arguments' => [eval('return new \Symfony\Component\Security\Core\Validator\Constraints\UserPassword(service: "my_service");')];
40+
yield 'named arguments' => [new UserPassword(service: "my_service")];
4141

4242
$metadata = new ClassMetadata(UserPasswordDummy::class);
4343
self::assertTrue((new AnnotationLoader())->loadClassMetadata($metadata));

src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function provideConstraints(): iterable
9595
{
9696
yield 'Doctrine style' => [new UserPassword(['message' => 'myMessage'])];
9797

98-
yield 'named arguments' => [eval('return new \Symfony\Component\Security\Core\Validator\Constraints\UserPassword(message: "myMessage");')];
98+
yield 'named arguments' => [new UserPassword(message: "myMessage")];
9999
}
100100

101101
/**

src/Symfony/Component/Validator/Tests/Constraints/BicValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function testInvalidBics($bic, $code)
223223
*/
224224
public function testInvalidBicsNamed($bic, $code)
225225
{
226-
$constraint = eval('return new \Symfony\Component\Validator\Constraints\Bic(message: "myMessage");');
226+
$constraint = new Bic(message: "myMessage");
227227

228228
$this->validator->validate($bic, $constraint);
229229

src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function testPayloadIsPassedToCallback()
243243
$this->assertEquals('Hello world!', $payloadCopy);
244244

245245
$payloadCopy = 'Replace me!';
246-
$constraint = eval('return new \Symfony\Component\Validator\Constraints\Callback(callback: $callback, payload: "Hello world!");');
246+
$constraint = new Callback(callback: $callback, payload: "Hello world!");
247247
$this->validator->validate($object, $constraint);
248248
$this->assertEquals('Hello world!', $payloadCopy);
249249
$payloadCopy = 'Replace me!';

src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function provideConstraintsWithChoicesArray(): iterable
8989
yield 'Doctrine style' => [new Choice(['choices' => ['foo', 'bar']])];
9090
yield 'Doctrine default option' => [new Choice(['value' => ['foo', 'bar']])];
9191
yield 'first argument' => [new Choice(['foo', 'bar'])];
92-
yield 'named arguments' => [eval('return new \Symfony\Component\Validator\Constraints\Choice(choices: ["foo", "bar"]);')];
92+
yield 'named arguments' => [new Choice(choices: ["foo", "bar"])];
9393
}
9494

9595
/**
@@ -111,9 +111,9 @@ public function provideConstraintsWithCallbackFunction(): iterable
111111
},
112112
])];
113113
yield 'doctrine style, static method' => [new Choice(['callback' => [__CLASS__, 'staticCallback']])];
114-
yield 'named arguments, namespaced function' => [eval("return new \Symfony\Component\Validator\Constraints\Choice(callback: 'Symfony\Component\Validator\Tests\Constraints\choice_callback');")];
115-
yield 'named arguments, closure' => [eval('return new \Symfony\Component\Validator\Constraints\Choice(callback: fn () => ["foo", "bar"]);')];
116-
yield 'named arguments, static method' => [eval('return new \Symfony\Component\Validator\Constraints\Choice(callback: ["Symfony\Component\Validator\Tests\Constraints\ChoiceValidatorTest", "staticCallback"]);')];
114+
yield 'named arguments, namespaced function' => [new Choice(callback: 'Symfony\Component\Validator\Tests\Constraints\choice_callback')];
115+
yield 'named arguments, closure' => [new Choice(callback: fn () => ["foo", "bar"])];
116+
yield 'named arguments, static method' => [new Choice(callback: ["Symfony\Component\Validator\Tests\Constraints\ChoiceValidatorTest", "staticCallback"])];
117117
}
118118

119119
public function testValidChoiceCallbackContextMethod()
@@ -156,10 +156,10 @@ public function provideConstraintsWithMultipleTrue(): iterable
156156
'choices' => ['foo', 'bar', 'baz'],
157157
'multiple' => true,
158158
])];
159-
yield 'named arguments' => [eval("return new \Symfony\Component\Validator\Constraints\Choice(
159+
yield 'named arguments' => [new Choice(
160160
choices: ['foo', 'bar', 'baz'],
161161
multiple: true,
162-
);")];
162+
)];
163163
}
164164

165165
/**
@@ -179,7 +179,7 @@ public function testInvalidChoice(Choice $constraint)
179179
public function provideConstraintsWithMessage(): iterable
180180
{
181181
yield 'Doctrine style' => [new Choice(['choices' => ['foo', 'bar'], 'message' => 'myMessage'])];
182-
yield 'named arguments' => [eval('return new \Symfony\Component\Validator\Constraints\Choice(choices: ["foo", "bar"], message: "myMessage");')];
182+
yield 'named arguments' => [new Choice(choices: ["foo", "bar"], message: "myMessage")];
183183
}
184184

185185
public function testInvalidChoiceEmptyChoices()
@@ -222,11 +222,11 @@ public function provideConstraintsWithMultipleMessage(): iterable
222222
'multipleMessage' => 'myMessage',
223223
'multiple' => true,
224224
])];
225-
yield 'named arguments' => [eval("return new \Symfony\Component\Validator\Constraints\Choice(
225+
yield 'named arguments' => [new Choice(
226226
choices: ['foo', 'bar'],
227227
multipleMessage: 'myMessage',
228228
multiple: true,
229-
);")];
229+
)];
230230
}
231231

232232
/**
@@ -256,12 +256,12 @@ public function provideConstraintsWithMin(): iterable
256256
'min' => 2,
257257
'minMessage' => 'myMessage',
258258
])];
259-
yield 'named arguments' => [eval("return new \Symfony\Component\Validator\Constraints\Choice(
259+
yield 'named arguments' => [new Choice(
260260
choices: ['foo', 'bar', 'moo', 'maa'],
261261
multiple: true,
262262
min: 2,
263263
minMessage: 'myMessage',
264-
);")];
264+
)];
265265
}
266266

267267
/**
< 846B code class="diff-text-cell hunk">
@@ -291,12 +291,12 @@ public function provideConstraintsWithMax(): iterable
291291
'max' => 2,
292292
'maxMessage' => 'myMessage',
293293
])];
294-
yield 'named arguments' => [eval("return new \Symfony\Component\Validator\Constraints\Choice(
294+
yield 'named arguments' => [new Choice(
295295
choices: ['foo', 'bar', 'moo', 'maa'],
296296
multiple: true,
297297
max: 2,
298298
maxMessage: 'myMessage',
299-
);")];
299+
)];
300300
}
301301

302302
public function testStrictAllowsExactValue()

0 commit comments

Comments
 (0)
0