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

Commit

Permalink
Merge 732269e into 5b34872
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Sep 14, 2019
2 parents 5b34872 + 732269e commit 35c5d1e
Show file tree
Hide file tree
Showing 47 changed files with 149 additions and 199 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
9 changes: 5 additions & 4 deletions .php_cs.dist
Expand Up @@ -28,6 +28,7 @@ $rules = [
],
'no_extra_blank_lines' => true,
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
Expand All @@ -43,10 +44,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=max[self]=0
- TARGET=test
- UPSTREAM_URL=https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle.git
- PHPUNIT_VERSION=7
Expand Down
2 changes: 1 addition & 1 deletion .travis/before_install_test.sh
Expand Up @@ -11,4 +11,4 @@ sed --in-place "s/\"dev-master\":/\"dev-${TRAVIS_COMMIT}\":/" composer.json
if [ "$SYMFONY" != "" ]; then composer require "symfony/symfony:$SYMFONY" --no-update; fi;
if [ "$SONATA_ADMIN" != "" ]; then composer require "sonata-project/admin-bundle:$SONATA_ADMIN" --no-update; fi;
if [ "$SONATA_BLOCK" != "" ]; then composer require "sonata-project/block-bundle:$SONATA_BLOCK" --no-update; fi;


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
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -52,8 +52,8 @@
"sonata-project/core-bundle": "^3.8",
"symfony-cmf/resource": "^1.0",
"symfony-cmf/resource-bundle": "^1.0",
"symfony-cmf/testing": "^2.1.11",
"symfony/phpunit-bridge": "^4.2",
"symfony-cmf/testing": "^2.1.12",
"symfony/phpunit-bridge": "^4.3",
"symfony/routing": "^2.8 || ^3.2 || ^4.0",
"symfony/security-acl": "^2.8 || ^3.0"
},
Expand Down
3 changes: 0 additions & 3 deletions src/Admin/Admin.php
Expand Up @@ -130,9 +130,6 @@ public function toString($object)
return parent::toString($object);
}

/**
* @param RouteCollection $collection
*/
protected function configureRoutes(RouteCollection $collection)
{
foreach (['edit', 'create', 'delete'] as $name) {
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
12 changes: 3 additions & 9 deletions src/Builder/DatagridBuilder.php
Expand Up @@ -55,10 +55,7 @@ class DatagridBuilder implements DatagridBuilderInterface
protected $pager;

/**
* @param FormFactory $formFactory
* @param FilterFactoryInterface $filterFactory
* @param TypeGuesserInterface $guesser
* @param bool $csrfTokenEnabled
* @param bool $csrfTokenEnabled
*/
public function __construct(FormFactory $formFactory, FilterFactoryInterface $filterFactory, TypeGuesserInterface $guesser, $csrfTokenEnabled = true)
{
Expand All @@ -68,9 +65,6 @@ public function __construct(FormFactory $formFactory, FilterFactoryInterface $fi
$this->csrfTokenEnabled = $csrfTokenEnabled;
}

/**
* @param PagerInterface $pager
*/
public function setPager(PagerInterface $pager)
{
$this->pager = $pager;
Expand Down Expand Up @@ -103,7 +97,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 +119,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
7 changes: 1 addition & 6 deletions src/Builder/FormContractor.php
Expand Up @@ -26,9 +26,6 @@ class FormContractor implements FormContractorInterface
*/
protected $formFactory;

/**
* @param FormFactoryInterface $formFactory
*/
public function __construct(FormFactoryInterface $formFactory)
{
$this->formFactory = $formFactory;
Expand Down Expand Up @@ -79,7 +76,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 Expand Up @@ -168,8 +165,6 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
}

/**
* @param FieldDescriptionInterface $fieldDescription
*
* @return \LogicException
*/
protected function getAssociationAdminException(FieldDescriptionInterface $fieldDescription)
Expand Down
18 changes: 6 additions & 12 deletions src/Builder/ListBuilder.php
Expand Up @@ -33,10 +33,6 @@ class ListBuilder implements ListBuilderInterface
*/
protected $templates;

/**
* @param TypeGuesserInterface $guesser
* @param array $templates
*/
public function __construct(TypeGuesserInterface $guesser, array $templates = [])
{
$this->guesser = $guesser;
Expand All @@ -56,7 +52,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 +80,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 +159,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 All @@ -198,8 +194,6 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
}

/**
* @param FieldDescriptionInterface $fieldDescription
*
* @return FieldDescriptionInterface
*/
public function buildActionFieldDescription(FieldDescriptionInterface $fieldDescription)
Expand Down
9 changes: 4 additions & 5 deletions src/Builder/ShowBuilder.php
Expand Up @@ -33,8 +33,7 @@ class ShowBuilder implements ShowBuilderInterface
protected $templates;

/**
* @param TypeGuesserInterface $guesser
* @param array $templates Indexed by field type
* @param array $templates Indexed by field type
*/
public function __construct(TypeGuesserInterface $guesser, array $templates)
{
Expand All @@ -55,7 +54,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 +104,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
10 changes: 2 additions & 8 deletions src/Controller/AutocompleteController.php
Expand Up @@ -31,17 +31,12 @@ class AutocompleteController
*/
protected $pool;

/**
* @param \Sonata\AdminBundle\Admin\Pool $pool
*/
public function __construct(Pool $pool)
{
$this->pool = $pool;
}

/**
* @param Request $request
*
* @throws AccessDeniedException
*
* @return Response
Expand Down Expand Up @@ -110,7 +105,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 Expand Up @@ -149,8 +144,7 @@ public function autoCompleteAction(Request $request)
/**
* Retrieve the field description given by field name.
*
* @param AdminInterface $admin
* @param string $field
* @param string $field
*
* @throws \RuntimeException
*
Expand Down

0 comments on commit 35c5d1e

Please sign in to comment.