Skip to content

Commit

Permalink
[Composer] Bump Symfony to 2.7 + PHP to 5.6 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs committed Feb 19, 2017
1 parent a8faafd commit 37ee2c9
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Expand Up @@ -11,4 +11,4 @@ checks:
tools:
external_code_coverage:
timeout: 3600
runs: 16
runs: 9
28 changes: 9 additions & 19 deletions .travis.yml
@@ -1,8 +1,6 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
Expand All @@ -15,8 +13,8 @@ env:
global:
- COMPOSER_PREFER_LOWEST=false
- DOCKER_BUILD=false
- SYMFONY_DEPRECATIONS_HELPER=weak
- SYMFONY_VERSION=2.3.*
- SYMFONY_DEPRECATIONS_HELPER=strict
- SYMFONY_VERSION=2.7.*

install: travis/install.sh
script: travis/script.sh
Expand All @@ -28,30 +26,22 @@ matrix:
services: [docker]
env: DOCKER_BUILD=true
- php: 5.6
env: SYMFONY_VERSION=2.3.* COMPOSER_PREFER_LOWEST=true
env: SYMFONY_VERSION=2.7.* COMPOSER_PREFER_LOWEST=true
- php: 5.6
env: SYMFONY_VERSION=3.0.* COMPOSER_PREFER_LOWEST=true
- php: 5.6
env: SYMFONY_VERSION=2.4.*
env: SYMFONY_VERSION=2.8.*
- php: 5.6
env: SYMFONY_VERSION=2.5.*
env: SYMFONY_VERSION=3.0.*
- php: 5.6
env: SYMFONY_VERSION=2.6.*
env: SYMFONY_VERSION=3.1.*
- php: 5.6
env: SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=strict
env: SYMFONY_VERSION=3.2.*
- php: 5.6
env: SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 5.6
env: SYMFONY_VERSION=3.0.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 5.6
env: SYMFONY_VERSION=3.1.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 5.6
env: SYMFONY_VERSION=3.2.* SYMFONY_DEPRECATIONS_HELPER=strict
- php: 5.6
env: SYMFONY_VERSION=3.3.*@dev SYMFONY_DEPRECATIONS_HELPER=strict
env: SYMFONY_VERSION=3.3.*@dev
allow_failures:
- php: hhvm
- env: SYMFONY_VERSION=3.3.*@dev SYMFONY_DEPRECATIONS_HELPER=strict
- env: SYMFONY_VERSION=3.3.*@dev

notifications:
email: geloen.eric@gmail.com
4 changes: 2 additions & 2 deletions DependencyInjection/IvoryBase64FileExtension.php
Expand Up @@ -14,8 +14,8 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
use Symfony\Component\HttpKernel\Kernel;

/**
* @author GeLo <geloen.eric@gmail.com>
Expand All @@ -37,7 +37,7 @@ protected function loadInternal(array $config, ContainerBuilder $container)
->getDefinition($formExtension = 'ivory.base64_file.form.extension')
->addArgument($config['default']);

if (Kernel::VERSION_ID < 20800) {
if (!method_exists(AbstractType::class, 'getBlockPrefix')) {
$container
->getDefinition($formExtension)
->clearTag('form.type_extension')
Expand Down
3 changes: 2 additions & 1 deletion Form/DataTransformer/Base64FileTransformer.php
Expand Up @@ -37,7 +37,8 @@ public function transform($value)

if (!$value instanceof Base64FileInterface) {
throw new TransformationFailedException(sprintf(
'Expected an "Ivory\Base64Bundle\Model\Base64FileInterface", got "%s".',
'Expected an "%s", got "%s".',
Base64FileInterface::class,
$this->getVariableType($value)
));
}
Expand Down
37 changes: 11 additions & 26 deletions Form/Extension/Base64FileExtension.php
Expand Up @@ -12,11 +12,12 @@
namespace Ivory\Base64FileBundle\Form\Extension;

use Ivory\Base64FileBundle\Form\DataTransformer\Base64FileTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
* @author GeLo <geloen.eric@gmail.com>
Expand Down Expand Up @@ -46,42 +47,26 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
}

/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'base64' => $this->base64,
'data_class' => function (Options $options, $value) {
return !$options['base64'] ? $value : null;
},
]);

if (method_exists($resolver, 'setDefault')) {
$resolver->setAllowedTypes('base64', 'bool');
} else {
$resolver->setAllowedTypes(['base64' => 'bool']);
}
$resolver
->setDefaults([
'base64' => $this->base64,
'data_class' => function (Options $options, $value) {
return !$options['base64'] ? $value : null;
},
])
->setAllowedTypes('base64', 'bool');
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) {
return 'Symfony\Component\Form\Extension\Core\Type\FileType';
}

return 'file';
return method_exists(AbstractType::class, 'getBlockPrefix') ? FileType::class : 'file';
}
}
2 changes: 1 addition & 1 deletion Model/Base64FileTrait.php
Expand Up @@ -93,7 +93,7 @@ private function load($value, $encoded = true)
} else {
throw new \InvalidArgumentException(sprintf(
'The base64 file value must be a string or a resource, got "%s".',
gettype($value)
is_object($value) ? get_class($value) : gettype($value)
));
}
} catch (\Exception $e) {
Expand Down
Expand Up @@ -12,8 +12,10 @@
namespace Ivory\Base64FileBundle\Tests\DependencyInjection;

use Ivory\Base64FileBundle\DependencyInjection\IvoryBase64FileExtension;
use Ivory\Base64FileBundle\Form\Extension\Base64FileExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;

/**
* @author GeLo <geloen.eric@gmail.com>
Expand Down Expand Up @@ -65,17 +67,13 @@ private function assertForm($enabled)
$this->assertTrue($this->container->has($extension = 'ivory.base64_file.form.extension'));
$this->assertSame($enabled, $this->container->getDefinition($extension)->getArgument(0));

$this->assertInstanceOf(
'Ivory\Base64FileBundle\Form\Extension\Base64FileExtension',
$this->container->get($extension)
);

$this->assertInstanceOf(Base64FileExtension::class, $this->container->get($extension));
$tag = $this->container->getDefinition($extension)->getTag('form.type_extension');

if (Kernel::VERSION_ID >= 20800) {
if (method_exists(AbstractType::class, 'getBlockPrefix')) {
$this->assertSame([[
'extended_type' => 'Symfony\Component\Form\Extension\Core\Type\FileType',
'extended-type' => 'Symfony\Component\Form\Extension\Core\Type\FileType',
'extended_type' => FileType::class,
'extended-type' => FileType::class,
]], $tag);
} else {
$this->assertSame([['alias' => 'file']], $tag);
Expand Down
13 changes: 7 additions & 6 deletions Tests/Form/Extension/Base64FileExtensionTest.php
Expand Up @@ -13,6 +13,9 @@

use Ivory\Base64FileBundle\Form\Extension\Base64FileExtension;
use Ivory\Base64FileBundle\Model\Base64File;
use Ivory\Base64FileBundle\Model\UploadedBase64File;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\Forms;
Expand Down Expand Up @@ -44,9 +47,7 @@ protected function setUp()
->addExtension(new ValidatorExtension(Validation::createValidator()))
->getFormFactory();

$this->formType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\FileType'
: 'file';
$this->formType = method_exists(AbstractType::class, 'getBlockPrefix') ? FileType::class : 'file';
}

public function testSubmitFile()
Expand Down Expand Up @@ -76,7 +77,7 @@ public function testSubmitMinimalValidBase64()
->submit($submitData = $this->getMinimalSubmitData());

$this->assertTrue($form->isValid());
$this->assertInstanceOf('Ivory\Base64FileBundle\Model\UploadedBase64File', $data = $form->getData());
$this->assertInstanceOf(UploadedBase64File::class, $data = $form->getData());

$this->assertSame($submitData['value'], $data->getData(true, false));
$this->assertSame($submitData['name'], $data->getClientOriginalName());
Expand All @@ -91,7 +92,7 @@ public function testSubmitMaximalValidBase64()
->submit($submitData = $this->getMaximalSubmitData());

$this->assertTrue($form->isValid());
$this->assertInstanceOf('Ivory\Base64FileBundle\Model\UploadedBase64File', $data = $form->getData());
$this->assertInstanceOf(UploadedBase64File::class, $data = $form->getData());

$this->assertSame($submitData['value'], $data->getData(true, false));
$this->assertSame($submitData['name'], $data->getClientOriginalName());
Expand Down Expand Up @@ -161,7 +162,7 @@ public function testValidInitialData()

/**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
* @expectedExceptionMessage Expected an "Ivory\Base64Bundle\Model\Base64FileInterface", got "stdClass".
* @expectedExceptionMessage Expected an "Ivory\Base64FileBundle\Model\Base64FileInterface", got "stdClass".
*/
public function testInvalidInitialData()
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/IvoryBase64FileBundleTest.php
Expand Up @@ -12,6 +12,7 @@
namespace Ivory\Base64FileBundle\Tests;

use Ivory\Base64FileBundle\IvoryBase64FileBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @author GeLo <geloen.eric@gmail.com>
Expand All @@ -33,6 +34,6 @@ protected function setUp()

public function testInheritance()
{
$this->assertInstanceOf('Symfony\Component\HttpKernel\Bundle\Bundle', $this->bundle);
$this->assertInstanceOf(Bundle::class, $this->bundle);
}
}
6 changes: 4 additions & 2 deletions Tests/Model/Base64FileTest.php
Expand Up @@ -12,6 +12,8 @@
namespace Ivory\Base64FileBundle\Tests\Model;

use Ivory\Base64FileBundle\Model\Base64File;
use Ivory\Base64FileBundle\Model\Base64FileInterface;
use Symfony\Component\HttpFoundation\File\File;

/**
* @author GeLo <geloen.eric@gmail.com>
Expand Down Expand Up @@ -55,8 +57,8 @@ public function testInheritance()
{
$file = new Base64File($this->base64);

$this->assertInstanceOf('Ivory\Base64FileBundle\Model\Base64FileInterface', $file);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $file);
$this->assertInstanceOf(Base64FileInterface::class, $file);
$this->assertInstanceOf(File::class, $file);
}

public function testFromBase64ResourceToBase64Resource()
Expand Down
6 changes: 4 additions & 2 deletions Tests/Model/UploadedBase64FileTest.php
Expand Up @@ -11,7 +11,9 @@

namespace Ivory\Base64FileBundle\Tests\Model;

use Ivory\Base64FileBundle\Model\Base64FileInterface;
use Ivory\Base64FileBundle\Model\UploadedBase64File;
use Symfony\Component\HttpFoundation\File\UploadedFile;

/**
* @author GeLo <geloen.eric@gmail.com>
Expand Down Expand Up @@ -61,8 +63,8 @@ public function testInheritance()
{
$file = new UploadedBase64File($this->base64, $this->name);

$this->assertInstanceOf('Ivory\Base64FileBundle\Model\Base64FileInterface', $file);
$this->assertInstanceOf('Symfony\Component\HttpFoundation\File\UploadedFile', $file);
$this->assertInstanceOf(Base64FileInterface::class, $file);
$this->assertInstanceOf(UploadedFile::class, $file);
}

public function testValidity()
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -11,16 +11,16 @@
}
],
"require": {
"php": "^5.4|^7.0",
"symfony/framework-bundle": "^2.3|^3.0",
"symfony/form": "^2.3|^3.0"
"php": "^5.6|^7.0",
"symfony/framework-bundle": "^2.7|^3.0",
"symfony/form": "^2.7|^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"phpunit/phpunit": "^4.0|^5.0",
"phpunit/phpunit": "^5.0",
"symfony/phpunit-bridge": "^2.7|^3.0",
"symfony/validator": "^2.3|^3.0",
"symfony/yaml": "^2.3|^3.0"
"symfony/validator": "^2.7|^3.0",
"symfony/yaml": "^2.7|^3.0"
},
"autoload": {
"psr-4": { "Ivory\\Base64FileBundle\\": "" }
Expand Down
2 changes: 1 addition & 1 deletion travis/install.sh
Expand Up @@ -2,7 +2,7 @@

set -e

SYMFONY_VERSION=${SYMFONY_VERSION-2.3.*}
SYMFONY_VERSION=${SYMFONY_VERSION-2.7.*}
COMPOSER_PREFER_LOWEST=${COMPOSER_PREFER_LOWEST-false}
DOCKER_BUILD=${DOCKER_BUILD-false}

Expand Down
3 changes: 2 additions & 1 deletion travis/script.sh
Expand Up @@ -2,10 +2,11 @@

set -e

TRAVIS_PHP_VERSION=${TRAVIS_PHP_VERSION-5.6}
DOCKER_BUILD=${DOCKER_BUILD-false}

if [ "$DOCKER_BUILD" = false ]; then
vendor/bin/phpunit --coverage-clover build/clover.xml
vendor/bin/phpunit `if [ ! "$TRAVIS_PHP_VERSION" = "hhvm" ]; then echo "--coverage-clover build/clover.xml"; fi`
fi

if [ "$DOCKER_BUILD" = true ]; then
Expand Down
3 changes: 2 additions & 1 deletion travis/success.sh
Expand Up @@ -2,9 +2,10 @@

set -e

TRAVIS_PHP_VERSION=${TRAVIS_PHP_VERSION-5.6}
DOCKER_BUILD=${DOCKER_BUILD-false}

if [ "$DOCKER_BUILD" = false ]; then
if [ "$DOCKER_BUILD" = false ] && [ ! "$TRAVIS_PHP_VERSION" = "hhvm" ]; then
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover build/clover.xml
fi

0 comments on commit 37ee2c9

Please sign in to comment.