Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Applied fixes from FlintCI
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh authored and OskarStark committed Apr 24, 2019
1 parent 0900290 commit 7fb759e
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/CoreBundle/Command/SonataDumpDoctrineMetaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ private function filterMetadata(array $metadata, InputInterface $input, OutputIn
if ($baseEntity) {
$allowedMeta = array_filter(
$metadata,
function ($meta) use ($baseEntity) {
static function ($meta) use ($baseEntity) {
/* @var \Doctrine\ORM\Mapping\ClassMetadata $meta */
return $meta->rootEntityName === $baseEntity;
}
);
} elseif ($regex) {
$allowedMeta = array_filter(
$metadata,
function ($meta) use ($regex) {
static function ($meta) use ($regex) {
/* @var \Doctrine\ORM\Mapping\ClassMetadata $meta */
return preg_match($regex, $meta->rootEntityName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/Exporter/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getResponse($format, $filename, SourceIteratorInterface $source)
throw new \RuntimeException('Invalid format');
}

$callback = function () use ($source, $writer) {
$callback = static function () use ($source, $writer) {
$handler = Handler::create($source, $writer);
$handler->export();
};
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Test/AbstractWidgetTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ final protected function renderWidget(FormView $view, array $vars = [])
*/
final protected function cleanHtmlWhitespace($html)
{
return preg_replace_callback('/\s*>([^<]+)</', function ($value) {
return preg_replace_callback('/\s*>([^<]+)</', static function ($value) {
return '>'.trim($value[1]).'<';
}, $html);
}
Expand All @@ -178,7 +178,7 @@ final protected function cleanHtmlWhitespace($html)
*/
final protected function cleanHtmlAttributeWhitespace($html)
{
return preg_replace_callback('~<([A-Z0-9]+) \K(.*?)>~i', function ($m) {
return preg_replace_callback('~<([A-Z0-9]+) \K(.*?)>~i', static function ($m) {
return preg_replace('~\s*~', '', $m[0]);
}, $html);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/BasePickerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
if (false !== strpos($key, 'dp_')) {
// We remove 'dp_' and camelize the options names
$dpKey = substr($key, 3);
$dpKey = preg_replace_callback('/_([a-z])/', function ($c) {
$dpKey = preg_replace_callback('/_([a-z])/', static function ($c) {
return strtoupper($c[1]);
}, $dpKey);

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/BooleanType.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function configureOptions(OptionsResolver $resolver)
'label_type_no' => self::TYPE_NO,
],
// Use directly translation_domain in SonataCoreBundle 4.0
'translation_domain' => function (Options $options) {
'translation_domain' => static function (Options $options) {
if ($options['catalogue']) {
return $options['catalogue'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/ImmutableArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function configureOptions(OptionsResolver $resolver)
'keys' => [],
]);

$resolver->setAllowedValues('keys', function ($value) {
$resolver->setAllowedValues('keys', static function ($value) {
foreach ($value as $subValue) {
if (!$subValue instanceof FormBuilderInterface && (!\is_array($subValue) || 3 !== \count($subValue))) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Validator/Constraints/InlineConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __wakeup()
return;
}

$this->method = function () {
$this->method = static function () {
};

$this->serializingWarning = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function testPreSubmitDataWithClosure()

$data = ['baz' => 'caz'];

$closure = function () use ($data) {
$closure = static function () use ($data) {
return $data['baz'];
};

Expand Down
2 changes: 1 addition & 1 deletion tests/CoreBundle/Form/Type/BooleanTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testBuildForm()
'catalogue' => 'SonataCoreBundle',

// Use directly translation_domain in SonataCoreBundle 4.0
'translation_domain' => function (Options $options) {
'translation_domain' => static function (Options $options) {
if ($options['catalogue']) {
return $options['catalogue'];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CoreBundle/Form/Type/EqualTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testGetDefaultOptions()

$mock->expects($this->exactly(0))
->method('trans')
->will($this->returnCallback(function ($arg) {
->will($this->returnCallback(static function ($arg) {
return $arg;
})
);
Expand Down
8 changes: 4 additions & 4 deletions tests/CoreBundle/Form/Type/ImmutableArrayTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ public function testCallback()

$builder = $this->createMock(TestFormBuilderInterface::class);
$builder->expects($this->once())->method('add')->with(
$this->callback(function ($name) {
$this->callback(static function ($name) {
return 'ttl' === $name;
}),
$this->callback(function ($name) {
$this->callback(static function ($name) {
return TextType::class === $name;
}),
$this->callback(function ($name) {
$this->callback(static function ($name) {
return $name === [1 => '1'];
})
);

$self = $this;
$optionsCallback = function ($builder, $name, $type, $extra) use ($self) {
$optionsCallback = static function ($builder, $name, $type, $extra) use ($self) {
$self->assertEquals(['foo', 'bar'], $extra);
$self->assertEquals($name, 'ttl');
$self->assertEquals($type, TextType::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public function testIsClosure()
$constraint = new InlineConstraint(['service' => 'foo', 'method' => 'bar']);
$this->assertFalse($constraint->isClosure());

$constraint = new InlineConstraint(['service' => 'foo', 'method' => function () {
$constraint = new InlineConstraint(['service' => 'foo', 'method' => static function () {
}, 'serializingWarning' => true]);
$this->assertTrue($constraint->isClosure());
}

public function testGetClosure()
{
$closure = function () {
$closure = static function () {
return 'FOO';
};

Expand Down Expand Up @@ -75,7 +75,7 @@ public function testGetService()

public function testClosureSerialization()
{
$constraint = new InlineConstraint(['service' => 'foo', 'method' => function () {
$constraint = new InlineConstraint(['service' => 'foo', 'method' => static function () {
}, 'serializingWarning' => true]);

$expected = 'O:50:"Sonata\Form\Validator\Constraints\InlineConstraint":0:{}';
Expand Down
2 changes: 1 addition & 1 deletion tests/CoreBundle/Validator/InlineValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testValidateWithConstraintIsClosure()

$constraint->expects($this->once())
->method('getClosure')
->willReturn(function (ErrorElement $errorElement, $value) {
->willReturn(static function (ErrorElement $errorElement, $value) {
throw new ValidatorException($errorElement->getSubject().' is equal to '.$value);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Form/EventListener/ResizeFormListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function testPreSubmitDataWithClosure()

$data = ['baz' => 'caz'];

$closure = function () use ($data) {
$closure = static function () use ($data) {
return $data['baz'];
};

Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Type/BooleanTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testBuildForm()
'catalogue' => 'SonataCoreBundle',

// Use directly translation_domain in SonataCoreBundle 4.0
'translation_domain' => function (Options $options) {
'translation_domain' => static function (Options $options) {
if ($options['catalogue']) {
return $options['catalogue'];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Type/EqualTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testGetDefaultOptions()

$mock->expects($this->exactly(0))
->method('trans')
->will($this->returnCallback(function ($arg) {
->will($this->returnCallback(static function ($arg) {
return $arg;
})
);
Expand Down
8 changes: 4 additions & 4 deletions tests/Form/Type/ImmutableArrayTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ public function testCallback()

$builder = $this->createMock(TestFormBuilderInterface::class);
$builder->expects($this->once())->method('add')->with(
$this->callback(function ($name) {
$this->callback(static function ($name) {
return 'ttl' === $name;
}),
$this->callback(function ($name) {
$this->callback(static function ($name) {
return TextType::class === $name;
}),
$this->callback(function ($name) {
$this->callback(static function ($name) {
return $name === [1 => '1'];
})
);

$self = $this;
$optionsCallback = function ($builder, $name, $type, $extra) use ($self) {
$optionsCallback = static function ($builder, $name, $type, $extra) use ($self) {
$self->assertEquals(['foo', 'bar'], $extra);
$self->assertEquals($name, 'ttl');
$self->assertEquals($type, TextType::class);
Expand Down
6 changes: 3 additions & 3 deletions tests/Form/Validator/Constraints/InlineConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public function testIsClosure()
$constraint = new InlineConstraint(['service' => 'foo', 'method' => 'bar']);
$this->assertFalse($constraint->isClosure());

$constraint = new InlineConstraint(['service' => 'foo', 'method' => function () {
$constraint = new InlineConstraint(['service' => 'foo', 'method' => static function () {
}, 'serializingWarning' => true]);
$this->assertTrue($constraint->isClosure());
}

public function testGetClosure()
{
$closure = function () {
$closure = static function () {
return 'FOO';
};

Expand Down Expand Up @@ -73,7 +73,7 @@ public function testGetService()

public function testClosureSerialization()
{
$constraint = new InlineConstraint(['service' => 'foo', 'method' => function () {
$constraint = new InlineConstraint(['service' => 'foo', 'method' => static function () {
}, 'serializingWarning' => true]);

$expected = 'O:50:"Sonata\Form\Validator\Constraints\InlineConstraint":0:{}';
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Validator/InlineValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testValidateWithConstraintIsClosure()

$constraint->expects($this->once())
->method('getClosure')
->willReturn(function (ErrorElement $errorElement, $value) {
->willReturn(static function (ErrorElement $errorElement, $value) {
throw new ValidatorException($errorElement->getSubject().' is equal to '.$value);
});

Expand Down

0 comments on commit 7fb759e

Please sign in to comment.