Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Apr 26, 2019
2 parents 3fd2dd4 + 851ca44 commit aba624a
Show file tree
Hide file tree
Showing 41 changed files with 110 additions and 109 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Expand Up @@ -43,6 +43,7 @@ $rules = [
'@PHP71Migration:risky' => true,
'compact_nullable_typehint' => true,
'void_return' => null,
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'php_unit_strict' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/AbstractAdmin.php
Expand Up @@ -2811,7 +2811,7 @@ protected function attachInlineValidator(): void

$metadata->addConstraint(new InlineConstraint([
'service' => $this,
'method' => function (ErrorElement $errorElement, $object) use ($admin): void {
'method' => static function (ErrorElement $errorElement, $object) use ($admin): void {
/* @var \Sonata\AdminBundle\Admin\AdminInterface $admin */

// This avoid the main validation to be cascaded to children
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/Admin.php
Expand Up @@ -123,7 +123,7 @@ public function processMetadata(ClassMetadata $metadata): void
'on_top' => $this->onTop,
];

$tag = array_filter($tag, function ($v) {
$tag = array_filter($tag, static function ($v) {
return null !== $v;
});

Expand Down
4 changes: 2 additions & 2 deletions src/Datagrid/Datagrid.php
Expand Up @@ -120,10 +120,10 @@ public function buildPager(): void

$this->formBuilder->add('_sort_by', $hiddenType);
$this->formBuilder->get('_sort_by')->addViewTransformer(new CallbackTransformer(
function ($value) {
static function ($value) {
return $value;
},
function ($value) {
static function ($value) {
return $value instanceof FieldDescriptionInterface ? $value->getName() : $value;
}
));
Expand Down
Expand Up @@ -181,10 +181,10 @@ public function process(ContainerBuilder $container): void
} elseif ($container->getParameter('sonata.admin.configuration.sort_admins')) {
$groups = $groupDefaults;

$elementSort = function (&$element): void {
$elementSort = static function (&$element): void {
usort(
$element['items'],
function ($a, $b) {
static function ($a, $b) {
$a = !empty($a['label']) ? $a['label'] : $a['admin'];
$b = !empty($b['label']) ? $b['label'] : $b['admin'];

Expand Down
10 changes: 5 additions & 5 deletions src/DependencyInjection/Configuration.php
Expand Up @@ -66,7 +66,7 @@ public function getConfigTreeBuilder()
->performNoDeepMerging()
->beforeNormalization()
->ifString()
->then(function ($v) {
->then(static function ($v) {
return [$v];
})
->end()
Expand Down Expand Up @@ -106,7 +106,7 @@ public function getConfigTreeBuilder()
->defaultValue('show')
->info('Perhaps one of the three options: show, fade, hide.')
->validate()
->ifTrue(function ($v) {
->ifTrue(static function ($v) {
return !\in_array($v, ['show', 'fade', 'hide'], true);
})
->thenInvalid('Configuration value of "global_search.empty_boxes" must be one of show, fade or hide.')
Expand Down Expand Up @@ -183,7 +183,7 @@ public function getConfigTreeBuilder()
->prototype('array')
->beforeNormalization()
->ifArray()
->then(function ($items) {
->then(static function ($items) {
if (isset($items['provider'])) {
$disallowedItems = ['items', 'label'];
foreach ($disallowedItems as $item) {
Expand All @@ -208,7 +208,7 @@ public function getConfigTreeBuilder()
->arrayNode('items')
->beforeNormalization()
->ifArray()
->then(function ($items) {
->then(static function ($items) {
foreach ($items as $key => $item) {
if (\is_array($item)) {
if (!\array_key_exists('label', $item) || !\array_key_exists('route', $item)) {
Expand Down Expand Up @@ -490,7 +490,7 @@ public function getConfigTreeBuilder()
->arrayNode('uses')
->prototype('scalar')->end()
->validate()
->ifTrue(function ($v) {
->ifTrue(static function ($v) {
return !empty($v) && version_compare(PHP_VERSION, '5.4.0', '<');
})
->thenInvalid('PHP >= 5.4.0 is required to use traits.')
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/AdminType.php
Expand Up @@ -100,7 +100,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver): void
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'delete' => function (Options $options) {
'delete' => static function (Options $options) {
return false !== $options['btn_delete'];
},
'delete_options' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/ModelAutocompleteType.php
Expand Up @@ -106,7 +106,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver): void

public function configureOptions(OptionsResolver $resolver): void
{
$compound = function (Options $options) {
$compound = static function (Options $options) {
return $options['multiple'];
};

Expand Down
4 changes: 2 additions & 2 deletions src/Form/Type/ModelType.php
Expand Up @@ -85,7 +85,7 @@ public function configureOptions(OptionsResolver $resolver): void
{
$options = [];
$propertyAccessor = $this->propertyAccessor;
$options['choice_loader'] = function (Options $options, $previousValue) use ($propertyAccessor) {
$options['choice_loader'] = static function (Options $options, $previousValue) use ($propertyAccessor) {
if ($previousValue && \count($choices = $previousValue->getChoices())) {
return $choices;
}
Expand All @@ -105,7 +105,7 @@ public function configureOptions(OptionsResolver $resolver): void
}

$resolver->setDefaults(array_merge($options, [
'compound' => function (Options $options) {
'compound' => static function (Options $options) {
if (isset($options['multiple']) && $options['multiple']) {
if (isset($options['expanded']) && $options['expanded']) {
//checkboxes
Expand Down
2 changes: 1 addition & 1 deletion src/Guesser/TypeGuesserChain.php
Expand Up @@ -47,7 +47,7 @@ public function __construct(array $guessers)

public function guessType($class, $property, ModelManagerInterface $modelManager)
{
return $this->guess(function ($guesser) use ($class, $property, $modelManager) {
return $this->guess(static function ($guesser) use ($class, $property, $modelManager) {
return $guesser->guessType($class, $property, $modelManager);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Route/RouteCollection.php
Expand Up @@ -99,7 +99,7 @@ public function add(

$defaults['_sonata_name'] = $routeName;

$this->elements[$this->getCode($name)] = function () use (
$this->elements[$this->getCode($name)] = static function () use (
$pattern, $defaults, $requirements, $options, $host, $schemes, $methods, $condition) {
return new Route($pattern, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
};
Expand Down
8 changes: 4 additions & 4 deletions tests/Action/DashboardActionTest.php
Expand Up @@ -61,13 +61,13 @@ public function testdashboardActionStandardRequest(): void
];
$dashboardAction->setContainer($container);

$container->expects($this->any())->method('get')->will($this->returnCallback(function ($id) use ($values) {
$container->expects($this->any())->method('get')->will($this->returnCallback(static function ($id) use ($values) {
return $values[$id];
}));

$container->expects($this->any())
->method('has')
->will($this->returnCallback(function ($id) {
->will($this->returnCallback(static function ($id) {
return 'templating' === $id;
}));

Expand Down Expand Up @@ -110,13 +110,13 @@ public function testDashboardActionAjaxLayout(): void
];
$dashboardAction->setContainer($container);

$container->expects($this->any())->method('get')->will($this->returnCallback(function ($id) use ($values) {
$container->expects($this->any())->method('get')->will($this->returnCallback(static function ($id) use ($values) {
return $values[$id];
}));

$container->expects($this->any())
->method('has')
->will($this->returnCallback(function ($id) {
->will($this->returnCallback(static function ($id) {
return 'templating' === $id;
}));

Expand Down
4 changes: 2 additions & 2 deletions tests/Action/SetObjectFieldValueActionTest.php
Expand Up @@ -245,7 +245,7 @@ private function configureFormRenderer()

$this->twig->addRuntimeLoader(new FactoryRuntimeLoader(
FormRenderer::class,
function () use ($runtime) {
static function () use ($runtime) {
return $runtime;
}
));
Expand All @@ -257,7 +257,7 @@ function () use ($runtime) {

$this->twig->addRuntimeLoader(new FactoryRuntimeLoader(
FormRenderer::class,
function () use ($runtime) {
static function () use ($runtime) {
return $runtime;
}
));
Expand Down
20 changes: 10 additions & 10 deletions tests/Admin/AdminTest.php
Expand Up @@ -1289,7 +1289,7 @@ public function testIsGranted(): void
$securityHandler = $this->createMock(AclSecurityHandlerInterface::class);
$securityHandler->expects($this->any())
->method('isGranted')
->will($this->returnCallback(function (AdminInterface $adminIn, $attributes, $object = null) use ($admin, $entity) {
->will($this->returnCallback(static function (AdminInterface $adminIn, $attributes, $object = null) use ($admin, $entity) {
if ($admin === $adminIn && 'FOO' === $attributes) {
if (($object === $admin) || ($object === $entity)) {
return true;
Expand Down Expand Up @@ -1330,7 +1330,7 @@ public function testShowIn(): void
$securityHandler = $this->createMock(AclSecurityHandlerInterface::class);
$securityHandler->expects($this->any())
->method('isGranted')
->will($this->returnCallback(function (AdminInterface $adminIn, $attributes, $object = null) use ($admin) {
->will($this->returnCallback(static function (AdminInterface $adminIn, $attributes, $object = null) use ($admin) {
if ($admin === $adminIn && $attributes === ['LIST']) {
return true;
}
Expand Down Expand Up @@ -1606,7 +1606,7 @@ public function testFormAddPostSubmitEventForPreValidation(): void
$formBuild->expects($this->once())
->method('addEventListener')
->with($this->identicalTo(FormEvents::POST_SUBMIT),
$this->callback(function ($callback) use ($testAdminPreValidate, $event) {
$this->callback(static function ($callback) use ($testAdminPreValidate, $event) {
if (\is_callable($callback)) {
$closure = $callback->bindTo($testAdminPreValidate);
$closure($event);
Expand Down Expand Up @@ -1711,7 +1711,7 @@ public function testGetFilterFieldDescription(): void
$modelManager = $this->createMock(ModelManagerInterface::class);
$modelManager->expects($this->exactly(3))
->method('getNewFieldDescriptionInstance')
->will($this->returnCallback(function ($adminClass, $name, $filterOptions) use ($fooFieldDescription, $barFieldDescription, $bazFieldDescription) {
->will($this->returnCallback(static function ($adminClass, $name, $filterOptions) use ($fooFieldDescription, $barFieldDescription, $bazFieldDescription) {
switch ($name) {
case 'foo':
$fieldDescription = $fooFieldDescription;
Expand Down Expand Up @@ -1755,7 +1755,7 @@ public function testGetFilterFieldDescription(): void

$datagridBuilder->expects($this->exactly(3))
->method('addFilter')
->will($this->returnCallback(function ($datagrid, $type, $fieldDescription, AdminInterface $admin): void {
->will($this->returnCallback(static function ($datagrid, $type, $fieldDescription, AdminInterface $admin): void {
$admin->addFilterFieldDescription($fieldDescription->getName(), $fieldDescription);
$fieldDescription->mergeOption('field_options', ['required' => false]);
}));
Expand Down Expand Up @@ -1980,7 +1980,7 @@ public function testGetBatchActions(): void
$labelTranslatorStrategy = $this->createMock(LabelTranslatorStrategyInterface::class);
$labelTranslatorStrategy->expects($this->any())
->method('getLabel')
->will($this->returnCallback(function ($label, $context = '', $type = '') {
->will($this->returnCallback(static function ($label, $context = '', $type = '') {
return $context.'.'.$type.'_'.$label;
}));

Expand All @@ -2000,7 +2000,7 @@ public function testGetBatchActions(): void
$securityHandler = $this->createMock(SecurityHandlerInterface::class);
$securityHandler->expects($this->any())
->method('isGranted')
->will($this->returnCallback(function (AdminInterface $adminIn, $attributes, $object = null) use ($admin) {
->will($this->returnCallback(static function (AdminInterface $adminIn, $attributes, $object = null) use ($admin) {
if ($admin === $adminIn && 'DELETE' === $attributes) {
return true;
}
Expand Down Expand Up @@ -2065,7 +2065,7 @@ public function testDefaultDashboardActionsArePresent($objFqn, $expected): void
$securityHandler = $this->createMock(SecurityHandlerInterface::class);
$securityHandler->expects($this->any())
->method('isGranted')
->will($this->returnCallback(function (AdminInterface $adminIn, $attributes, $object = null) use ($admin) {
->will($this->returnCallback(static function (AdminInterface $adminIn, $attributes, $object = null) use ($admin) {
if ($admin === $adminIn && ('CREATE' === $attributes || 'LIST' === $attributes)) {
return true;
}
Expand Down Expand Up @@ -2186,12 +2186,12 @@ public function testGetDataSourceIterator(): void

$admin->expects($this->any())
->method('getTranslationLabel')
->will($this->returnCallback(function ($label, $context = '', $type = '') {
->will($this->returnCallback(static function ($label, $context = '', $type = '') {
return $context.'.'.$type.'_'.$label;
}));
$admin->expects($this->any())
->method('trans')
->will($this->returnCallback(function ($label) {
->will($this->returnCallback(static function ($label) {
if ('export.label_field' === $label) {
return 'Feld';
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Admin/BaseAdminModelManagerTest.php
Expand Up @@ -42,7 +42,7 @@ public function testHook(): void
public function testObject(): void
{
$modelManager = $this->getMockForAbstractClass(ModelManagerInterface::class);
$modelManager->expects($this->once())->method('find')->will($this->returnCallback(function ($class, $id): void {
$modelManager->expects($this->once())->method('find')->will($this->returnCallback(static function ($class, $id): void {
if ('class' !== $class) {
throw new \RuntimeException('Invalid class argument');
}
Expand All @@ -60,7 +60,7 @@ public function testObject(): void
public function testCreateQuery(): void
{
$modelManager = $this->getMockForAbstractClass(ModelManagerInterface::class);
$modelManager->expects($this->once())->method('createQuery')->will($this->returnCallback(function ($class): void {
$modelManager->expects($this->once())->method('createQuery')->will($this->returnCallback(static function ($class): void {
if ('class' !== $class) {
throw new \RuntimeException('Invalid class argument');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/CreateClassCacheCommandTest.php
Expand Up @@ -69,7 +69,7 @@ protected function setUp(): void

$container->expects($this->any())
->method('get')
->will($this->returnCallback(function ($id) use ($kernel) {
->will($this->returnCallback(static function ($id) use ($kernel) {
if ('kernel' === $id) {
return $kernel;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/GenerateAdminCommandTest.php
Expand Up @@ -210,7 +210,7 @@ public function testExecuteInteractive($modelEntity): void

$questionHelper->expects($this->any())
->method('ask')
->will($this->returnCallback(function (InputInterface $input, OutputInterface $output, Question $question) use ($modelEntity) {
->will($this->returnCallback(static function (InputInterface $input, OutputInterface $output, Question $question) use ($modelEntity) {
$questionClean = substr($question->getQuestion(), 6, strpos($question->getQuestion(), '</info>') - 6);

switch ($questionClean) {
Expand Down Expand Up @@ -353,7 +353,7 @@ public function testAnswerUpdateServicesWithNo(): void

$questionHelper->expects($this->any())
->method('ask')
->will($this->returnCallback(function (InputInterface $input, OutputInterface $output, Question $question) use ($modelEntity) {
->will($this->returnCallback(static function (InputInterface $input, OutputInterface $output, Question $question) use ($modelEntity) {
$questionClean = substr($question->getQuestion(), 6, strpos($question->getQuestion(), '</info>') - 6);

switch ($questionClean) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/ListAdminCommandTest.php
Expand Up @@ -45,7 +45,7 @@ public function testExecute(): void

$container->expects($this->any())
->method('get')
->will($this->returnCallback(function ($id) use ($container, $admin1, $admin2) {
->will($this->returnCallback(static function ($id) use ($container, $admin1, $admin2) {
switch ($id) {
case 'sonata.admin.pool':
$pool = new Pool($container, '', '');
Expand Down
6 changes: 3 additions & 3 deletions tests/Command/SetupAclCommandTest.php
Expand Up @@ -38,7 +38,7 @@ public function testExecute(): void

$container->expects($this->any())
->method('get')
->will($this->returnCallback(function ($id) use ($container, $admin, $aclManipulator) {
->will($this->returnCallback(static function ($id) use ($container, $admin, $aclManipulator) {
switch ($id) {
case 'sonata.admin.pool':
$pool = new Pool($container, '', '');
Expand Down Expand Up @@ -74,7 +74,7 @@ public function testExecuteWithException1(): void

$container->expects($this->any())
->method('get')
->will($this->returnCallback(function ($id) use ($container) {
->will($this->returnCallback(static function ($id) use ($container) {
if ('sonata.admin.pool' === $id) {
$pool = new Pool($container, '', '');
$pool->setAdminServiceIds(['acme.admin.foo']);
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testExecuteWithException2(): void

$container->expects($this->any())
->method('get')
->will($this->returnCallback(function ($id) use ($container, $admin) {
->will($this->returnCallback(static function ($id) use ($container, $admin) {
switch ($id) {
case 'sonata.admin.pool':
$pool = new Pool($container, '', '');
Expand Down

0 comments on commit aba624a

Please sign in to comment.