Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh committed Nov 4, 2017
1 parent 2c0b7c6 commit 1376e8b
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Builder/DatagridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
*/
public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if ($type == null) {
if (null == $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());

$type = $guessType->getType();
Expand Down
2 changes: 1 addition & 1 deletion Builder/FormContractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
'Sonata\AdminBundle\Form\Type\ModelType',
'Sonata\AdminBundle\Form\Type\ModelListType',
))) {
if ($fieldDescription->getOption('edit') == 'list') {
if ('list' == $fieldDescription->getOption('edit')) {
throw new \LogicException('The ``sonata_type_model`` type does not accept an ``edit`` option anymore, please review the UPGRADE-2.1.md file from the SonataAdminBundle');
}

Expand Down
16 changes: 8 additions & 8 deletions Builder/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getBaseList(array $options = array())
*/
public function buildField($type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if ($type == null) {
if (null == $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$fieldDescription->setType($guessType->getType());
} else {
Expand All @@ -73,7 +73,7 @@ public function addField(FieldDescriptionCollection $list, $type, FieldDescripti
*/
public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
{
if ($fieldDescription->getName() === '_action' || $fieldDescription->getType() === 'actions') {
if ('_action' === $fieldDescription->getName() || 'actions' === $fieldDescription->getType()) {
$this->buildActionFieldDescription($fieldDescription);
}

Expand All @@ -86,7 +86,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
// set the default field mapping
if (isset($metadata->fieldMappings[$lastPropertyName])) {
$fieldDescription->setFieldMapping($metadata->fieldMappings[$lastPropertyName]);
if ($fieldDescription->getOption('sortable') !== false) {
if (false !== $fieldDescription->getOption('sortable')) {
$fieldDescription->setOption('sortable', $fieldDescription->getOption('sortable', true));
$fieldDescription->setOption('sort_parent_association_mappings', $fieldDescription->getOption('sort_parent_association_mappings', $fieldDescription->getParentAssociationMappings()));
$fieldDescription->setOption('sort_field_mapping', $fieldDescription->getOption('sort_field_mapping', $fieldDescription->getFieldMapping()));
Expand All @@ -109,20 +109,20 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName()));

if (!$fieldDescription->getTemplate()) {
if ($fieldDescription->getType() == 'id') {
if ('id' == $fieldDescription->getType()) {
$fieldDescription->setType('string');
}

if ($fieldDescription->getType() == 'int') {
if ('int' == $fieldDescription->getType()) {
$fieldDescription->setType('integer');
}

$template = $this->getTemplate($fieldDescription->getType());

if ($template === null) {
if ($fieldDescription->getMappingType() == ClassMetadataInfo::ONE) {
if (null === $template) {
if (ClassMetadataInfo::ONE == $fieldDescription->getMappingType()) {
$template = 'SonataDoctrineMongoDBAdminBundle:CRUD:list_mongo_one.html.twig';
} elseif ($fieldDescription->getMappingType() == ClassMetadataInfo::MANY) {
} elseif (ClassMetadataInfo::MANY == $fieldDescription->getMappingType()) {
$template = 'SonataDoctrineMongoDBAdminBundle:CRUD:list_mongo_many.html.twig';
}
}
Expand Down
12 changes: 6 additions & 6 deletions Builder/ShowBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getBaseList(array $options = array())
*/
public function addField(FieldDescriptionCollection $list, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if ($type == null) {
if (null == $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$fieldDescription->setType($guessType->getType());
} else {
Expand Down Expand Up @@ -100,20 +100,20 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setOption('label', $fieldDescription->getOption('label', $fieldDescription->getName()));

if (!$fieldDescription->getTemplate()) {
if ($fieldDescription->getType() == 'id') {
if ('id' == $fieldDescription->getType()) {
$fieldDescription->setType('string');
}

if ($fieldDescription->getType() == 'int') {
if ('int' == $fieldDescription->getType()) {
$fieldDescription->setType('integer');
}

$template = $this->getTemplate($fieldDescription->getType());

if ($template === null) {
if ($fieldDescription->getMappingType() == ClassMetadataInfo::ONE) {
if (null === $template) {
if (ClassMetadataInfo::ONE == $fieldDescription->getMappingType()) {
$template = 'SonataDoctrineMongoDBAdminBundle:CRUD:show_mongo_one.html.twig';
} elseif ($fieldDescription->getMappingType() == ClassMetadataInfo::MANY) {
} elseif (ClassMetadataInfo::MANY == $fieldDescription->getMappingType()) {
$template = 'SonataDoctrineMongoDBAdminBundle:CRUD:show_mongo_many.html.twig';
}
}
Expand Down
2 changes: 1 addition & 1 deletion Filter/AbstractDateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class AbstractDateFilter extends Filter
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
//check data sanity
if (is_array($data) !== true) {
if (true !== is_array($data)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Filter/BooleanFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
continue;
}

$values[] = ($v == BooleanType::TYPE_YES) ? true : false;
$values[] = (BooleanType::TYPE_YES == $v) ? true : false;
}

if (count($values) == 0) {
if (0 == count($values)) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions Filter/ChoiceFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
}

if (is_array($data['value'])) {
if (count($data['value']) == 0) {
if (0 == count($data['value'])) {
return;
}

if (in_array('all', $data['value'])) {
return;
}

if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
if (ChoiceType::TYPE_NOT_CONTAINS == $data['type']) {
$queryBuilder->field($field)->notIn($data['value']);
} else {
$queryBuilder->field($field)->in($data['value']);
}

$this->active = true;
} else {
if ($data['value'] === '' || $data['value'] === null || $data['value'] === false || $data['value'] === 'all') {
if ('' === $data['value'] || null === $data['value'] || false === $data['value'] || 'all' === $data['value']) {
return;
}

if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
if (ChoiceType::TYPE_NOT_CONTAINS == $data['type']) {
$queryBuilder->field($field)->notEqual($data['value']);
} else {
$queryBuilder->field($field)->equals($data['value']);
Expand Down
6 changes: 3 additions & 3 deletions Filter/ModelFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getRenderSettings()
*/
protected function handleMultiple(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (count($data['value']) == 0) {
if (0 == count($data['value'])) {
return;
}

Expand All @@ -84,7 +84,7 @@ protected function handleMultiple(ProxyQueryInterface $queryBuilder, $alias, $fi
$ids[] = self::fixIdentifier($value->getId());
}

if (isset($data['type']) && $data['type'] == EqualType::TYPE_IS_NOT_EQUAL) {
if (isset($data['type']) && EqualType::TYPE_IS_NOT_EQUAL == $data['type']) {
$queryBuilder->field($field)->notIn($ids);
} else {
$queryBuilder->field($field)->in($ids);
Expand All @@ -109,7 +109,7 @@ protected function handleScalar(ProxyQueryInterface $queryBuilder, $alias, $fiel

$id = self::fixIdentifier($data['value']->getId());

if (isset($data['type']) && $data['type'] == EqualType::TYPE_IS_NOT_EQUAL) {
if (isset($data['type']) && EqualType::TYPE_IS_NOT_EQUAL == $data['type']) {
$queryBuilder->field($field)->notEqual($id);
} else {
$queryBuilder->field($field)->equals($id);
Expand Down
12 changes: 6 additions & 6 deletions Filter/StringFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ public function filter(ProxyQueryInterface $queryBuilder, $name, $field, $data)

$data['value'] = trim($data['value']);

if (strlen($data['value']) == 0) {
if (0 == strlen($data['value'])) {
return;
}

$data['type'] = isset($data['type']) && !empty($data['type']) ? $data['type'] : ChoiceType::TYPE_CONTAINS;

$obj = $queryBuilder;
if ($this->condition == self::CONDITION_OR) {
if (self::CONDITION_OR == $this->condition) {
$obj = $queryBuilder->expr();
}

if ($data['type'] == ChoiceType::TYPE_EQUAL) {
if (ChoiceType::TYPE_EQUAL == $data['type']) {
$obj->field($field)->equals($data['value']);
} elseif ($data['type'] == ChoiceType::TYPE_CONTAINS) {
} elseif (ChoiceType::TYPE_CONTAINS == $data['type']) {
$obj->field($field)->equals(new \MongoRegex(sprintf('/%s/i', $data['value'])));
} elseif ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
} elseif (ChoiceType::TYPE_NOT_CONTAINS == $data['type']) {
$obj->field($field)->not(new \MongoRegex(sprintf('/%s/i', $data['value'])));
}

if ($this->condition == self::CONDITION_OR) {
if (self::CONDITION_OR == $this->condition) {
$queryBuilder->addOr($obj);
}

Expand Down
4 changes: 2 additions & 2 deletions Model/ModelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function batchDelete($class, ProxyQueryInterface $queryProxy)
foreach ($queryBuilder->execute() as $object) {
$documentManager->remove($object);

if ((++$i % 20) == 0) {
if (0 == (++$i % 20)) {
$documentManager->flush();
$documentManager->clear();
}
Expand Down Expand Up @@ -371,7 +371,7 @@ public function getSortParameters(FieldDescriptionInterface $fieldDescription, D
$values = $datagrid->getValues();

if ($fieldDescription->getName() == $values['_sort_by']->getName() || $values['_sort_by']->getName() === $fieldDescription->getOption('sortable')) {
if ($values['_sort_order'] == 'ASC') {
if ('ASC' == $values['_sort_order']) {
$values['_sort_order'] = 'DESC';
} else {
$values['_sort_order'] = 'ASC';
Expand Down
4 changes: 2 additions & 2 deletions Tests/Helpers/PHPUnit_Framework_TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function expectException($exception, $message = '', $code = null)
if (is_callable('parent::expectException')) {
parent::expectException($exception);

if ($message !== '') {
if ('' !== $message) {
parent::expectExceptionMessage($message);
}

if ($code !== null) {
if (null !== $code) {
parent::expectExceptionCode($code);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Util/ObjectAclManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public function batchConfigureAcls(OutputInterface $output, AdminInterface $admi

++$count;

if (($count % $batchSize) == 0) {
if (0 == ($count % $batchSize)) {
list($batchAdded, $batchUpdated) = $this->configureAcls($output, $admin, $objectIdIterator, $securityIdentity);
$countAdded += $batchAdded;
$countUpdated += $batchUpdated;
$objectIds = array();
}

if (($count % $batchSizeOutput) == 0) {
if (0 == ($count % $batchSizeOutput)) {
$output->writeln(sprintf(
' - generated class ACEs%s for %s objects (added %s, updated %s)',
$objectOwnersMsg,
Expand Down

0 comments on commit 1376e8b

Please sign in to comment.