Skip to content

Commit 0e73963

Browse files
More short closures + isset instead of null checks + etc.
1 parent a93e8e6 commit 0e73963

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

ChoiceList/ArrayChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct(iterable $choices, callable $value = null)
6969

7070
if (null !== $value) {
7171
// If a deterministic value generator was passed, use it later
72-
$this->valueCallback = $value;
72+
$this->valueCallback = $value(...);
7373
} else {
7474
// Otherwise generate incrementing integers as values
7575
$value = static function () {

Test/TypeTestCase.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ protected function setUp(): void
3535
$this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory);
3636
}
3737

38-
protected function tearDown(): void
39-
{
40-
if (\in_array(ValidatorExtensionTrait::class, class_uses($this))) {
41-
$this->validator = null;
42-
}
43-
}
44-
4538
protected function getExtensions()
4639
{
4740
$extensions = [];

Tests/Extension/Validator/Constraints/FormValidatorTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ public function testDontValidateIfNotSynchronized()
264264
])
265265
->setData($object)
266266
->addViewTransformer(new CallbackTransformer(
267-
fn ($data) => $data,
268-
function () { throw new TransformationFailedException(); }
267+
static fn ($data) => $data,
268+
static fn () => throw new TransformationFailedException()
269269
))
270270
->getForm();
271271

@@ -301,8 +301,8 @@ public function testAddInvalidErrorEvenIfNoValidationGroups()
301301
])
302302
->setData($object)
303303
->addViewTransformer(new CallbackTransformer(
304-
fn ($data) => $data,
305-
function () { throw new TransformationFailedException(); }
304+
static fn ($data) => $data,
305+
static fn () => throw new TransformationFailedException()
306306
))
307307
->getForm();
308308

@@ -336,8 +336,8 @@ public function testDontValidateConstraintsIfNotSynchronized()
336336
$form = $this->getBuilder('name', '\stdClass', $options)
337337
->setData($object)
338338
->addViewTransformer(new CallbackTransformer(
339-
fn ($data) => $data,
340-
function () { throw new TransformationFailedException(); }
339+
static fn ($data) => $data,
340+
static fn () => throw new TransformationFailedException()
341341
))
342342
->getForm();
343343

@@ -367,8 +367,8 @@ public function testTransformationFailedExceptionInvalidMessageIsUsed()
367367
])
368368
->setData($object)
369369
->addViewTransformer(new CallbackTransformer(
370-
fn ($data) => $data,
371-
function () {
370+
static fn ($data) => $data,
371+
static function () {
372372
$failure = new TransformationFailedException();
373373
$failure->setInvalidMessage('safe message to be used', ['{{ bar }}' => 'bar']);
374374

Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ protected function getForm($name = 'name', $propertyPath = null, $dataClass = nu
7272

7373
if (!$synchronized) {
7474
$config->addViewTransformer(new CallbackTransformer(
75-
fn ($normData) => $normData,
76-
function () { throw new TransformationFailedException(); }
75+
static fn ($normData) => $normData,
76+
static fn () => throw new TransformationFailedException()
7777
));
7878
}
7979

0 commit comments

Comments
 (0)