Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge 27f7bfa into 5b34872
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed May 7, 2019
2 parents 5b34872 + 27f7bfa commit a9c0606
Show file tree
Hide file tree
Showing 34 changed files with 105 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -7,7 +7,7 @@ charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,twig,php}]
[*.{yaml,yml,twig,php}]
indent_size = 4

[*.{js,json,scss,css}]
Expand Down
8 changes: 4 additions & 4 deletions .php_cs.dist
Expand Up @@ -43,10 +43,10 @@ $rules = [
'@PHP71Migration:risky' => true,
'compact_nullable_typehint' => true,
'void_return' => null,
// To be tested before insertion:
// 'strict_comparison' => true,
// 'strict_param' => true,
// 'php_unit_strict' => true,
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'php_unit_strict' => true,
];


Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -15,8 +15,7 @@ php:
- '7.3'
- nightly

sudo: false
dist: trusty
dist: xenial

addons:
apt:
Expand All @@ -31,7 +30,7 @@ cache:
env:
global:
- PATH="$HOME/.local/bin:$PATH"
- SYMFONY_DEPRECATIONS_HELPER=weak
- SYMFONY_DEPRECATIONS_HELPER=weak_vendors
- TARGET=test
- UPSTREAM_URL=https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle.git
- PHPUNIT_VERSION=7
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Expand Up @@ -173,7 +173,7 @@ your work, please do another PR for that. In some rare cases, you might be
forced to do it on the same PR. In this kind of situation, please add a comment
on your PR explaining why you feel it is the case.

#### The Change log
#### The Changelog

For each PR, a change log must be provided.

Expand Down Expand Up @@ -271,7 +271,7 @@ For class definitions, methods (or first level functions) and properties, use th

```php
/**
* @deprecated since 42.x, to be removed in 43.0. Use Shiny\New\ClassOfTheMonth instead.
* @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0. Use Shiny\New\ClassOfTheMonth instead.
*/
final class IAmOldAndUseless
{
Expand All @@ -280,12 +280,12 @@ final class IAmOldAndUseless
final class StillUsedClass
{
/**
* @deprecated since 42.x, to be removed in 43.0.
* @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0.
*/
public $butNotThisProperty;

/**
* @deprecated since 42.x, to be removed in 43.0.
* @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0.
*/
public function iAmBatman()
{
Expand All @@ -299,7 +299,7 @@ If the deprecated thing is a service, you **MUST** specify it on the service def
```xml
<service id="sonata.block.old" class="Sonata\Block\Old">
<argument type="service" id="security.token_storage" />
<deprecated>The "%service_id%" service is deprecated since 42.x and will be removed in 43.0.</deprecated>
<deprecated>The "%service_id%" service is deprecated since sonata-project/bar-bundle 42.x and will be removed in 43.0.</deprecated>
</service>
```

Expand All @@ -311,7 +311,7 @@ For everything else, not managed by the `@deprecated` tag, you **MUST** trigger
<?php
if (/* some condition showing the user is using the legacy way */) {
@trigger_error(
'The '.__METHOD__.' method is deprecated since 42.x, to be removed in 43.0. '.
'The '.__METHOD__.' method is deprecated since sonata-project/bar-bundle 42.x, to be removed in 43.0. '.
'Use FooClass::barMethod() instead.',
E_USER_DEPRECATED
);
Expand Down Expand Up @@ -551,7 +551,7 @@ but are encouraged to report release requests on the dedicated private Slack cha
Releasing software is the last step to getting your bugfixes or new features to your user base,
and should be done regularly, so that users are not tempted to use development branches.
To know what you are going to release on branch 42.x, given that the last release on this branch is 42.3.1,
go to `https://github.com/sonata-project/SonataCoreBundle/compare/42.3.1...42.x`.
go to `https://github.com/sonata-project/SonataAdminBundle/compare/42.3.1...42.x`.
You should see a list of commits, some of which should contain links to pull requests.

#### Determining the next release number
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Expand Up @@ -51,8 +51,22 @@ cs-fix-xml:
done
.PHONY: cs-fix-xml

test:
phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
build:
mkdir $@

HAS_XDEBUG=$(shell php --modules|grep --quiet xdebug;echo $$?)

build/xdebug-filter.php: phpunit.xml.dist build
ifeq ($(HAS_XDEBUG), 0)
phpunit --dump-xdebug-filter $@
endif

test: build/xdebug-filter.php
ifeq ($(HAS_XDEBUG), 0)
phpunit --prepend build/xdebug-filter.php -c phpunit.xml.dist --coverage-clover build/logs/clover.xml
else
phpunit -c phpunit.xml.dist
endif
.PHONY: test

docs:
Expand Down
6 changes: 3 additions & 3 deletions src/Block/TreeBlockService.php
Expand Up @@ -67,13 +67,13 @@ public function configureSettings(OptionsResolver $resolver)
// the callables are a workaround to make bundle configuration win over the default values
// see https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle/pull/345
$resolver->setDefaults([
'template' => function (Options $options, $value) {
'template' => static function (Options $options, $value) {
return $value ?: '@SonataDoctrinePHPCRAdmin/Block/tree.html.twig';
},
'id' => function (Options $options, $value) {
'id' => static function (Options $options, $value) {
return $value ?: '/';
},
'selected' => function (Options $options, $value) {
'selected' => static function (Options $options, $value) {
return $value ?: null;
},
'routing_defaults' => function (Options $options, $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/DatagridBuilder.php
Expand Up @@ -103,7 +103,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
if (isset($metadata->mappings[$fieldDescription->getName()])) {
$fieldDescription->setFieldMapping($metadata->mappings[$fieldDescription->getName()]);

if ('string' == $metadata->mappings[$fieldDescription->getName()]['type']) {
if ('string' === $metadata->mappings[$fieldDescription->getName()]['type']) {
$fieldDescription->setOption('global_search', $fieldDescription->getOption('global_search', true)); // always search on string field only
}
}
Expand All @@ -125,7 +125,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
*/
public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if (null == $type) {
if (null === $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$type = $guessType->getType();
$fieldDescription->setType($type);
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/FormContractor.php
Expand Up @@ -79,7 +79,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
'referrers',
];

if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && \in_array($fieldDescription->getMappingType(), $mappingTypes)) {
if ($metadata && $metadata->hasAssociation($fieldDescription->getName()) && \in_array($fieldDescription->getMappingType(), $mappingTypes, true)) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Builder/ListBuilder.php
Expand Up @@ -56,7 +56,7 @@ public function getBaseList(array $options = [])
*/
public function buildField($type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if (null == $type) {
if (null === $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$fieldDescription->setType($guessType instanceof TypeGuess ? $guessType->getType() : null);
} else {
Expand Down Expand Up @@ -84,7 +84,7 @@ public function addField(FieldDescriptionCollection $list, $type, FieldDescripti
*/
public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInterface $fieldDescription)
{
if ('_action' == $fieldDescription->getName() || 'actions' === $fieldDescription->getType()) {
if ('_action' === $fieldDescription->getName() || 'actions' === $fieldDescription->getType()) {
$this->buildActionFieldDescription($fieldDescription);
}

Expand Down Expand Up @@ -163,19 +163,19 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
if (!$fieldDescription->getTemplate()) {
$fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));

if (ClassMetadata::MANY_TO_ONE == $fieldDescription->getMappingType()) {
if (ClassMetadata::MANY_TO_ONE === $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_many_to_one.html.twig');
}

if (ClassMetadata::MANY_TO_MANY == $fieldDescription->getMappingType()) {
if (ClassMetadata::MANY_TO_MANY === $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_many_to_many.html.twig');
}

if ('child' == $fieldDescription->getMappingType() || 'parent' == $fieldDescription->getMappingType()) {
if ('child' === $fieldDescription->getMappingType() || 'parent' === $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_one_to_one.html.twig');
}

if ('children' == $fieldDescription->getMappingType() || 'referrers' == $fieldDescription->getMappingType()) {
if ('children' === $fieldDescription->getMappingType() || 'referrers' === $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/list_one_to_many.html.twig');
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Builder/ShowBuilder.php
Expand Up @@ -55,7 +55,7 @@ public function getBaseList(array $options = [])
*/
public function addField(FieldDescriptionCollection $list, $type, FieldDescriptionInterface $fieldDescription, AdminInterface $admin)
{
if (null == $type) {
if (null === $type) {
$guessType = $this->guesser->guessType($admin->getClass(), $fieldDescription->getName(), $admin->getModelManager());
$fieldDescription->setType($guessType->getType());
} else {
Expand Down Expand Up @@ -105,11 +105,11 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
if (!$fieldDescription->getTemplate()) {
$fieldDescription->setTemplate($this->getTemplate($fieldDescription->getType()));

if (ClassMetadata::MANY_TO_ONE == $fieldDescription->getMappingType()) {
if (ClassMetadata::MANY_TO_ONE === $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/show_many_to_one.html.twig');
}

if (ClassMetadata::MANY_TO_MANY == $fieldDescription->getMappingType()) {
if (ClassMetadata::MANY_TO_MANY === $fieldDescription->getMappingType()) {
$fieldDescription->setTemplate('@SonataAdmin/CRUD/Association/show_many_to_many.html.twig');
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AutocompleteController.php
Expand Up @@ -110,7 +110,7 @@ public function autoCompleteAction(Request $request)
}

//did we max out x+1
$more = (\count($results) == $itemsPerPage + 1);
$more = (\count($results) === $itemsPerPage + 1);
$method = $request->get('_method_name');

$items = [];
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/TreeController.php
Expand Up @@ -104,18 +104,18 @@ public function reorderAction(Request $request)
return new JsonResponse(['Parameters parent, dropped and target has to be set to reorder.'], Response::HTTP_BAD_REQUEST);
}

if (\in_array($position, ['over', 'child'])) {
if (\in_array($position, ['over', 'child'], true)) {
return new JsonResponse(['Can not reorder when dropping into a collection.'], Response::HTTP_BAD_REQUEST);
}

$before = 'before' == $position;
$before = 'before' === $position;
$parentNode = $this->session->getNode($parentPath);
$targetName = PathHelper::getNodeName($targetPath);
if (!$before) {
$nodesIterator = $parentNode->getNodes();
$nodesIterator->rewind();
while ($nodesIterator->valid()) {
if ($nodesIterator->key() == $targetName) {
if ($nodesIterator->key() === $targetName) {
break;
}
$nodesIterator->next();
Expand Down
2 changes: 1 addition & 1 deletion src/Datagrid/Pager.php
Expand Up @@ -61,7 +61,7 @@ public function init()
$this->resetIterator();
$this->setNbResults($this->computeNbResult());

if (0 == $this->getPage() || 0 == $this->getMaxPerPage() || 0 == $this->getNbResults()) {
if (0 === $this->getPage() || 0 === $this->getMaxPerPage() || 0 === $this->getNbResults()) {
$this->setLastPage(0);
$this->getQuery()->setFirstResult(0);
$this->getQuery()->setMaxResults(0);
Expand Down
2 changes: 1 addition & 1 deletion src/Datagrid/ProxyQuery.php
Expand Up @@ -187,7 +187,7 @@ public function getSortBy()
*/
public function setSortOrder($sortOrder)
{
if (!\in_array($sortOrder, ['ASC', 'DESC'])) {
if (!\in_array($sortOrder, ['ASC', 'DESC'], true)) {
throw new \InvalidArgumentException(sprintf('The parameter $sortOrder must be one of "ASC" or "DESC", got "%s"', $sortOrder));
}
$this->sortOrder = $sortOrder;
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/AddTemplatesCompilerPass.php
Expand Up @@ -29,7 +29,7 @@ public function process(ContainerBuilder $container)
{
$settings = $this->fixSettings($container);
foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
if (!isset($attributes[0]['manager_type']) || 'doctrine_phpcr' != $attributes[0]['manager_type']) {
if (!isset($attributes[0]['manager_type']) || 'doctrine_phpcr' !== $attributes[0]['manager_type']) {
continue;
}

Expand Down Expand Up @@ -60,7 +60,7 @@ protected function fixSettings(ContainerBuilder $container)
$settings = false;
$methods = $pool->getMethodCalls();
foreach ($methods as $pos => $calls) {
if ('__hack_doctrine_phpcr__' == $calls[0]) {
if ('__hack_doctrine_phpcr__' === $calls[0]) {
$settings = $calls[1];

break;
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/BooleanFilter.php
Expand Up @@ -33,7 +33,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data)
}

$where = $this->getWhere($proxyQuery);
$where->eq()->field('a.'.$field)->literal(BooleanType::TYPE_YES == $data['value'] ? true : false);
$where->eq()->field('a.'.$field)->literal(BooleanType::TYPE_YES === $data['value'] ? true : false);

// filter is active as we have now modified the query
$this->active = true;
Expand Down
6 changes: 3 additions & 3 deletions src/Filter/ChoiceFilter.php
Expand Up @@ -48,11 +48,11 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data)
$andX = $this->getWhere($proxyQuery)->andX();

foreach ($values as $value) {
if (ChoiceType::TYPE_NOT_CONTAINS == $type) {
if (ChoiceType::TYPE_NOT_CONTAINS === $type) {
$andX->not()->like()->field('a.'.$field)->literal('%'.$value.'%');
} elseif (ChoiceType::TYPE_CONTAINS == $type) {
} elseif (ChoiceType::TYPE_CONTAINS === $type) {
$andX->like()->field('a.'.$field)->literal('%'.$value.'%');
} elseif (ChoiceType::TYPE_EQUAL == $type) {
} elseif (ChoiceType::TYPE_EQUAL === $type) {
$andX->like()->field('a.'.$field)->literal($value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/Filter.php
Expand Up @@ -49,7 +49,7 @@ public function isActive()
protected function getWhere(ProxyQuery $proxy)
{
$queryBuilder = $proxy->getQueryBuilder();
if (self::CONDITION_OR == $this->getCondition()) {
if (self::CONDITION_OR === $this->getCondition()) {
return $queryBuilder->orWhere();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Filter/NodeNameFilter.php
Expand Up @@ -30,7 +30,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data)
$data['value'] = trim((string) $data['value']);
$data['type'] = empty($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type'];

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

Expand Down
2 changes: 1 addition & 1 deletion src/Filter/StringFilter.php
Expand Up @@ -30,7 +30,7 @@ public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data)
$value = trim((string) $data['value']);
$data['type'] = empty($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type'];

if (0 == \strlen($value)) {
if (0 === \strlen($value)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Extension/CollectionTypeExtension.php
Expand Up @@ -29,7 +29,7 @@ class CollectionTypeExtension extends AbstractTypeExtension
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ('doctrine_phpcr' != $options['sonata_field_description']->getAdmin()->getManagerType() || !$options['sonata_field_description']->getOption('sortable')) {
if ('doctrine_phpcr' !== $options['sonata_field_description']->getAdmin()->getManagerType() || !$options['sonata_field_description']->getOption('sortable')) {
return;
}
$listener = new CollectionOrderListener($options['sonata_field_description']->getName());
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/TreeModelType.php
Expand Up @@ -88,7 +88,7 @@ public function configureOptions(OptionsResolver $resolver)
'parent' => 'choice',
'repository_name' => 'default',
'preferred_choices' => [],
'choice_list' => function (Options $options, $previousValue) {
'choice_list' => static function (Options $options, $previousValue) {
return new ModelChoiceList(
$options['model_manager'],
$options['class'],
Expand Down
6 changes: 3 additions & 3 deletions src/Model/ModelManager.php
Expand Up @@ -347,7 +347,7 @@ public function batchDelete($class, ProxyQueryInterface $queryProxy)
foreach ($res as $object) {
$this->dm->remove($object);

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

if ($fieldDescription->getName() == $values['_sort_by']->getName()) {
if ('ASC' == $values['_sort_order']) {
if ($fieldDescription->getName() === $values['_sort_by']->getName()) {
if ('ASC' === $values['_sort_order']) {
$values['_sort_order'] = 'DESC';
} else {
$values['_sort_order'] = 'ASC';
Expand Down

0 comments on commit a9c0606

Please sign in to comment.