Skip to content

Commit

Permalink
Applied fixes from StyleCI (sonata-project#3892)
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh committed May 29, 2016
1 parent c46a46a commit 37e3514
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Annotation/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public function processMetadata(ClassMetadata $metadata)
'persist_filters' => $this->persistFilters,
);

$tag = array_filter($tag, function ($v) { return !is_null($v); });
$tag = array_filter($tag, function ($v) {
return !is_null($v);
});
$metadata->tags['sonata.admin'][] = $tag;
$metadata->arguments = array($this->id, $this->class, $this->baseControllerName);

Expand Down
8 changes: 6 additions & 2 deletions Datagrid/Datagrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ public function buildPager()

$this->formBuilder->add('_sort_by', 'hidden');
$this->formBuilder->get('_sort_by')->addViewTransformer(new CallbackTransformer(
function ($value) { return $value; },
function ($value) { return $value instanceof FieldDescriptionInterface ? $value->getName() : $value; }
function ($value) {
return $value;
},
function ($value) {
return $value instanceof FieldDescriptionInterface ? $value->getName() : $value;
}
));

$this->formBuilder->add('_sort_order', 'hidden');
Expand Down
4 changes: 3 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public function getConfigTreeBuilder()
->performNoDeepMerging()
->beforeNormalization()
->ifString()
->then(function ($v) { return array($v); })
->then(function ($v) {
return array($v);
})
->end()
->prototype('scalar')->end()
->end()
Expand Down
1 change: 0 additions & 1 deletion Form/Type/ModelType.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public function configureOptions(OptionsResolver $resolver)
$options['choices'],
$propertyAccessor
);

};
} else {
$options['choice_list'] = function (Options $options, $previousValue) use ($propertyAccessor) {
Expand Down
1 change: 0 additions & 1 deletion Tests/Command/GenerateAdminCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public function testExecuteInteractive($modelEntity)
$dialog->expects($this->any())
->method('askAndValidate')
->will($this->returnCallback(function (OutputInterface $output, $question, $validator, $attempts = false, $default = null) use ($modelEntity) {

$questionClean = substr($question, 6, strpos($question, '</info>') - 6);

switch ($questionClean) {
Expand Down
13 changes: 6 additions & 7 deletions Tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ protected function setUp()
$this->csrfProvider->expects($this->any())
->method('isTokenValid')
->will($this->returnCallback(function (CsrfToken $token) {

if ($token->getValue() == 'csrf-token-123_'.$token->getId()) {
return true;
}
Expand Down Expand Up @@ -774,8 +773,8 @@ public function testBatchActionDeleteWithModelManagerExceptionInDebugMode()
$modelManager->expects($this->once())
->method('batchDelete')
->will($this->returnCallback(function () {
throw new ModelManagerException();
}));
throw new ModelManagerException();
}));

$this->admin->expects($this->once())
->method('getModelManager')
Expand Down Expand Up @@ -1145,8 +1144,8 @@ public function testDeleteActionWithModelManagerExceptionInDebugMode()
$this->admin->expects($this->once())
->method('delete')
->will($this->returnCallback(function () {
throw new ModelManagerException();
}));
throw new ModelManagerException();
}));

$this->kernel->expects($this->once())
->method('isDebug')
Expand Down Expand Up @@ -3680,8 +3679,8 @@ private function assertLoggerLogsModelManagerException($subject, $method)
$subject->expects($this->once())
->method($method)
->will($this->returnCallback(function () use ($exception) {
throw $exception;
}));
throw $exception;
}));

$this->logger->expects($this->once())
->method('error')
Expand Down
10 changes: 5 additions & 5 deletions Tests/Controller/HelperControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,12 @@ public function testRetrieveAutocompleteItemsActionNotGranted()
$this->admin->expects($this->exactly(2))
->method('isGranted')
->will($this->returnCallback(function ($operation) {
if ($operation == 'CREATE' || $operation == 'EDIT') {
return false;
}
if ($operation == 'CREATE' || $operation == 'EDIT') {
return false;
}

return;
}));
return;
}));

$request = new Request(array(
'admin_code' => 'foo.admin',
Expand Down
2 changes: 1 addition & 1 deletion Tests/Datagrid/DatagridMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function testAddDuplicateNameException()
$tmpNames[$name] = $name;

return false;
}));
}));

try {
$this->datagridMapper->add('fooName');
Expand Down
4 changes: 3 additions & 1 deletion Tests/Form/Widget/FormSonataFilterChoiceWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ protected function getExtensions()

$mock->expects($this->exactly(3))
->method('trans')
->will($this->returnCallback(function ($arg) { return $arg; })
->will($this->returnCallback(function ($arg) {
return $arg;
})
);

$extensions = parent::getExtensions();
Expand Down
1 change: 0 additions & 1 deletion Tests/Security/Handler/RoleSecurityHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function testIsGranted($expected, array $superAdminRoles, $adminCode, $op
$this->authorizationChecker->expects($this->any())
->method('isGranted')
->will($this->returnCallback(function (array $attributes, $object) {

if (in_array('ROLE_BATMAN', $attributes)) {
return true;
}
Expand Down

0 comments on commit 37e3514

Please sign in to comment.