Skip to content

Commit

Permalink
DevKit updates for 3.x branch (#240)
Browse files Browse the repository at this point in the history
* DevKit updates

* Apply fixes from StyleCI (#241)

* DevKit updates

* DevKit updates

* Remove support for PHP from 5.3 to 5.5

* Phpunit 5

* DevKit updates
  • Loading branch information
SonataCI authored and core23 committed Nov 14, 2017
1 parent 1376e8b commit 14148d1
Show file tree
Hide file tree
Showing 45 changed files with 403 additions and 415 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.* export-ignore
*.md export-ignore
Tests/* export-ignore
Resources/doc/* export-ignore
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

```
$ composer show --latest 'sonata-project/*'
# Put the result here.
```

#### Symfony packages

```
$ composer show --latest 'symfony/*'
# Put the result here.
```

#### PHP version
Expand Down
2 changes: 0 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
-->
I am targeting this branch, because {reason}.

In case of bug fix, `3.x` **MUST** be targeted.

<!--
Specify which issues will be fixed/closed.
Remove it if this is not related.
Expand Down
4 changes: 2 additions & 2 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
preset: symfony

enabled:
- class_keyword_remove
- combine_consecutive_unsets
- long_array_syntax
- short_array_syntax
- newline_after_open_tag
- no_php4_constructor
- no_useless_else
Expand All @@ -24,6 +23,7 @@ enabled:
finder:
exclude:
- 'Tests/Fixtures'
- 'tests/Fixtures'
# ecommerce special case:
- 'Resources/skeleton'
# ignore vendor assets
Expand Down
42 changes: 17 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ branches:
language: php

php:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- nightly

services:
- mongodb

sudo: false
dist: precise
dist: trusty

cache:
pip: true
Expand All @@ -38,38 +37,31 @@ env:
matrix:
fast_finish: true
include:
- php: '5.6'
- php: '7.1'
env: TARGET=docs
- php: '5.6'
- php: '7.1'
env: TARGET=lint
- php: '5.3'
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '5.6'
env: SYMFONY=2.3.*
- php: '5.6'
env: SYMFONY=2.7.*
- php: '5.6'
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '7.1'
env: SYMFONY=2.8.*
- php: '5.6'
- php: '7.1'
env: SYMFONY=3.2.*
- php: '5.6'
- php: '7.1'
env: SYMFONY=3.3.*
- php: '5.6'
env: SYMFONY=dev-master@dev
- php: '5.6'
- php: '7.1'
env: SYMFONY='dev-master as 3.3'
- php: '7.1'
env: SONATA_ADMIN=3.*
- php: '5.6'
env: SONATA_ADMIN=dev-master@dev
- php: '5.6'
- php: '7.1'
env: SONATA_ADMIN='dev-master as 3'
- php: '7.1'
env: SYMFONY_DEPRECATIONS_HELPER=0
- php: hhvm
dist: trusty
allow_failures:
- php: nightly
- php: hhvm
- env: SYMFONY_DEPRECATIONS_HELPER=0
- env: SYMFONY=dev-master@dev
- env: SONATA_ADMIN=dev-master@dev
- env: SYMFONY='dev-master as 3.3'
- env: SONATA_ADMIN='dev-master as 3'

before_install:
- git remote add upstream ${UPSTREAM_URL} && git fetch --all
Expand Down
30 changes: 11 additions & 19 deletions .travis/before_install_test.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
#!/usr/bin/env sh
set -ev

if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ]; then
PHP_INI_DIR="$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/"
TRAVIS_INI_FILE="$PHP_INI_DIR/travis.ini"
echo "memory_limit=3072M" >> "$TRAVIS_INI_FILE"
PHP_INI_DIR="$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/"
TRAVIS_INI_FILE="$PHP_INI_DIR/travis.ini"
echo "memory_limit=3072M" >> "$TRAVIS_INI_FILE"

if [ "$TRAVIS_PHP_VERSION" '<' '5.4' ]; then
XDEBUG_INI_FILE="$PHP_INI_DIR/xdebug.ini"
if [ -f "$XDEBUG_INI_FILE" ]; then
mv "$XDEBUG_INI_FILE" /tmp
fi
fi

if [ "$TRAVIS_PHP_VERSION" '<' '7.0' ]; then
echo "extension=mongo.so" >> "$TRAVIS_INI_FILE"
else
echo "extension=mongodb.so" >> "$TRAVIS_INI_FILE"

# Backwards compatibility with old mongo extension
composer require "alcaeus/mongo-php-adapter" --no-update
fi
fi
if [ "$TRAVIS_PHP_VERSION" '<' '7.0' ]; then
echo "extension=mongo.so" >> "$TRAVIS_INI_FILE"
else
echo "extension=mongodb.so" >> "$TRAVIS_INI_FILE"

# Backwards compatibility with old mongo extension
composer require "alcaeus/mongo-php-adapter" --ignore-platform-reqs
fi

sed --in-place "s/\"dev-master\":/\"dev-${TRAVIS_COMMIT}\":/" composer.json

Expand Down
7 changes: 0 additions & 7 deletions .travis/before_script_test.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#!/usr/bin/env bash
set -ev

if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ "$TRAVIS_PHP_VERSION" '<' '5.4' ]; then
PHP_INI_DIR="$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/"
XDEBUG_INI_FILE="/tmp/xdebug.ini"
if [ -f "$XDEBUG_INI_FILE" ]; then
mv "$XDEBUG_INI_FILE" "$PHP_INI_DIR"
fi
fi
11 changes: 4 additions & 7 deletions .travis/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ set -ev
mkdir --parents "${HOME}/bin"

# PHPUnit install
if [ ${TRAVIS_PHP_VERSION} '<' '5.6' ]; then
PHPUNIT_PHAR=phpunit-4.8.phar
else
PHPUNIT_PHAR=phpunit-5.7.phar
fi
wget "https://phar.phpunit.de/${PHPUNIT_PHAR}" --output-document="${HOME}/bin/phpunit"
wget "https://phar.phpunit.de/phpunit-5.7.phar" --output-document="${HOME}/bin/phpunit"
chmod u+x "${HOME}/bin/phpunit"

# Coveralls client install
Expand All @@ -19,6 +14,8 @@ chmod u+x "${HOME}/bin/coveralls"
# To be removed when these issues are resolved:
# https://github.com/composer/composer/issues/5355
# https://github.com/composer/composer/issues/5030
composer update --prefer-dist --no-interaction --prefer-stable --quiet --ignore-platform-reqs
if [ "${COMPOSER_FLAGS}" = '--prefer-lowest' ]; then
composer update --prefer-dist --no-interaction --prefer-stable --quiet --ignore-platform-reqs
fi

composer update --prefer-dist --no-interaction --prefer-stable ${COMPOSER_FLAGS}
2 changes: 1 addition & 1 deletion Admin/FieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FieldDescription extends BaseFieldDescription
*/
public function __construct()
{
$this->parentAssociationMappings = array();
$this->parentAssociationMappings = [];
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Builder/DatagridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn

foreach ($options as $name => $value) {
if (is_array($value)) {
$fieldDescription->setOption($name, array_merge($value, $fieldDescription->getOption($name, array())));
$fieldDescription->setOption($name, array_merge($value, $fieldDescription->getOption($name, [])));
} else {
$fieldDescription->setOption($name, $fieldDescription->getOption($name, $value));
}
Expand All @@ -114,7 +114,7 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn
$this->fixFieldDescription($admin, $fieldDescription);
$admin->addFilterFieldDescription($fieldDescription->getName(), $fieldDescription);

$fieldDescription->mergeOption('field_options', array('required' => false));
$fieldDescription->mergeOption('field_options', ['required' => false]);
$filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions());

if (false !== $filter->getLabel() && !$filter->getLabel()) {
Expand All @@ -130,17 +130,17 @@ public function addFilter(DatagridInterface $datagrid, $type, FieldDescriptionIn
*
* @return \Sonata\AdminBundle\Datagrid\DatagridInterface
*/
public function getBaseDatagrid(AdminInterface $admin, array $values = array())
public function getBaseDatagrid(AdminInterface $admin, array $values = [])
{
$pager = new Pager();
$pager->setCountColumn($admin->getModelManager()->getIdentifierFieldNames($admin->getClass()));

$defaultOptions = array();
$defaultOptions = [];
if ($this->csrfTokenEnabled) {
$defaultOptions['csrf_protection'] = false;
}

$formBuilder = $this->formFactory->createNamedBuilder('filter', 'form', array(), $defaultOptions);
$formBuilder = $this->formFactory->createNamedBuilder('filter', 'form', [], $defaultOptions);

return new Datagrid($admin->createQuery(), $admin->getList(), $pager, $formBuilder, $values);
}
Expand Down
20 changes: 10 additions & 10 deletions Builder/FormContractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setAdmin($admin);
$fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'standard'));

if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
if (in_array($fieldDescription->getMappingType(), [ClassMetadataInfo::ONE, ClassMetadataInfo::MANY])) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand All @@ -76,7 +76,7 @@ public function getFormFactory()
/**
* {@inheritdoc}
*/
public function getFormBuilder($name, array $options = array())
public function getFormBuilder($name, array $options = [])
{
return $this->getFormFactory()->createNamedBuilder($name, 'form', null, $options);
}
Expand All @@ -86,33 +86,33 @@ public function getFormBuilder($name, array $options = array())
*/
public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescription)
{
$options = array();
$options = [];
$options['sonata_field_description'] = $fieldDescription;

// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony <2.8
if ($this->checkFormType($type, array(
if ($this->checkFormType($type, [
'sonata_type_model',
'sonata_type_model_list',
)) || $this->checkFormClass($type, array(
]) || $this->checkFormClass($type, [
'Sonata\AdminBundle\Form\Type\ModelType',
'Sonata\AdminBundle\Form\Type\ModelListType',
))) {
])) {
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');
}

$options['class'] = $fieldDescription->getTargetEntity();
$options['model_manager'] = $fieldDescription->getAdmin()->getModelManager();
// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony <2.8
} elseif ($this->checkFormType($type, array('sonata_type_admin')) || $this->checkFormClass($type, array('Sonata\AdminBundle\Form\Type\AdminType'))) {
} elseif ($this->checkFormType($type, ['sonata_type_admin']) || $this->checkFormClass($type, ['Sonata\AdminBundle\Form\Type\AdminType'])) {
if (!$fieldDescription->getAssociationAdmin()) {
throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
}

$options['data_class'] = $fieldDescription->getAssociationAdmin()->getClass();
$fieldDescription->setOption('edit', $fieldDescription->getOption('edit', 'admin'));
// NEXT_MAJOR: Check only against FQCNs when dropping support for Symfony <2.8
} elseif ($this->checkFormType($type, array('sonata_type_collection')) || $this->checkFormClass($type, array('Sonata\CoreBundle\Form\Type\CollectionType'))) {
} elseif ($this->checkFormType($type, ['sonata_type_collection']) || $this->checkFormClass($type, ['Sonata\CoreBundle\Form\Type\CollectionType'])) {
if (!$fieldDescription->getAssociationAdmin()) {
throw new \RuntimeException(sprintf('The current field `%s` is not linked to an admin. Please create one for the target entity : `%s`', $fieldDescription->getName(), $fieldDescription->getTargetEntity()));
}
Expand All @@ -123,10 +123,10 @@ public function getDefaultOptions($type, FieldDescriptionInterface $fieldDescrip
'Sonata\AdminBundle\Form\Type\AdminType'
;
$options['modifiable'] = true;
$options['type_options'] = array(
$options['type_options'] = [
'sonata_field_description' => $fieldDescription,
'data_class' => $fieldDescription->getAssociationAdmin()->getClass(),
);
];
}

return $options;
Expand Down
8 changes: 4 additions & 4 deletions Builder/ListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ListBuilder implements ListBuilderInterface
{
protected $guesser;

protected $templates = array();
protected $templates = [];

/**
* @param \Sonata\AdminBundle\Guesser\TypeGuesserInterface $guesser
* @param array $templates
*/
public function __construct(TypeGuesserInterface $guesser, array $templates = array())
public function __construct(TypeGuesserInterface $guesser, array $templates = [])
{
$this->guesser = $guesser;
$this->templates = $templates;
Expand All @@ -37,7 +37,7 @@ public function __construct(TypeGuesserInterface $guesser, array $templates = ar
/**
* {@inheritdoc}
*/
public function getBaseList(array $options = array())
public function getBaseList(array $options = [])
{
return new FieldDescriptionCollection();
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setTemplate($template);
}

if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
if (in_array($fieldDescription->getMappingType(), [ClassMetadataInfo::ONE, ClassMetadataInfo::MANY])) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Builder/ShowBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(TypeGuesserInterface $guesser, array $templates)
*
* @return \Sonata\AdminBundle\Admin\FieldDescriptionCollection
*/
public function getBaseList(array $options = array())
public function getBaseList(array $options = [])
{
return new FieldDescriptionCollection();
}
Expand Down Expand Up @@ -121,7 +121,7 @@ public function fixFieldDescription(AdminInterface $admin, FieldDescriptionInter
$fieldDescription->setTemplate($template);
}

if (in_array($fieldDescription->getMappingType(), array(ClassMetadataInfo::ONE, ClassMetadataInfo::MANY))) {
if (in_array($fieldDescription->getMappingType(), [ClassMetadataInfo::ONE, ClassMetadataInfo::MANY])) {
$admin->attachAdminClass($fieldDescription);
}
}
Expand Down

0 comments on commit 14148d1

Please sign in to comment.