Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop symfony < 3.4 and < 4.3 for 4.x #520

Merged
merged 3 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
phpunit.xml
composer.lock
vendor/
.phpunit.result.cache

43 changes: 14 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,36 @@ cache:
- $HOME/.composer/cache

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- 7.2
- 7.3
- 7.4

env:
global:
- TEST_COMMAND="./vendor/bin/phpunit"
matrix:
- SYMFONY_VERSION=2.8.*

matrix:
fast_finish: true
allow_failures:
- php: hhvm

include:
- php: 5.6
env: SYMFONY_VERSION=2.7.*
- php: 7.1
env: SYMFONY_VERSION=2.7.*
- php: 7.2
env: SYMFONY_VERSION=2.7.*
- php: 7.1
env: SYMFONY_VERSION=2.8.*
env: SYMFONY_VERSION=^3.4
- php: 7.3
env: SYMFONY_VERSION=^3.4
- php: 7.4
env: SYMFONY_VERSION=^3.4
- php: 7.2
env: SYMFONY_VERSION=2.8.*
- php: 5.6
env: SYMFONY_VERSION=^3.0
- php: 7.1
env: SYMFONY_VERSION=^3.0
- php: 7.2
env: SYMFONY_VERSION=^3.0
- php: 7.1
env: SYMFONY_VERSION=^4.0
- php: 7.2
env: SYMFONY_VERSION=^4.0
env: SYMFONY_VERSION=^4.3
- php: 7.3
env: SYMFONY_VERSION=^4.3
- php: 7.4
env: SYMFONY_VERSION=^4.3

before_install:
- travis_retry composer self-update

install:
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
- if [[ $SYMFONY_VERSION ]]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi
- COMPOSER_MEMORY_LIMIT=-1 composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction

script:
Expand Down
9 changes: 4 additions & 5 deletions Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
use JMS\TranslationBundle\Translation\Updater;
use Symfony\Component\HttpFoundation\Response;
use JMS\TranslationBundle\Util\FileUtils;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/api", service="jms_translation.controller.api_controller")
* @Route("/api")
Copy link
Contributor Author

@franmomu franmomu Feb 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a deprecation for Route and Method from SensioFrameworkExtraBundle, because of removing the service option, I had to defined these aliases too.

*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
Expand Down Expand Up @@ -58,10 +57,10 @@ public function __construct(ConfigFactory $configFactory, Updater $updater)

/**
* @Route("/configs/{config}/domains/{domain}/locales/{locale}/messages",
* methods={"PUT"},
* name="jms_translation_update_message",
* defaults = {"id" = null},
* options = {"i18n" = false})
* @Method("PUT")
* @param Request $request
* @param string $config
* @param string $domain
Expand All @@ -84,7 +83,7 @@ public function updateMessageAction(Request $request, $config, $domain, $locale)
// the loaders of the translation component as these currently simply discard
// the extra information that is contained in these files

list($format, $file) = $files[$domain][$locale];
[$format, $file] = $files[$domain][$locale];

$this->updater->updateTranslation(
$file, $format, $domain, $locale, $id,
Expand Down
3 changes: 1 addition & 2 deletions Controller/TranslateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
use JMS\TranslationBundle\Translation\ConfigFactory;
use JMS\TranslationBundle\Translation\LoaderManager;
use JMS\TranslationBundle\Util\FileUtils;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**
* Translate Controller.
*
* @Route(service="jms_translation.controller.translate_controller")
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class TranslateController
Expand Down
7 changes: 1 addition & 6 deletions DependencyInjection/Compiler/MountDumpersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

use JMS\TranslationBundle\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand All @@ -40,11 +39,7 @@ public function process(ContainerBuilder $container)
throw new RuntimeException(sprintf('The "alias" attribute must be set for tag "translation.dumper" for service "%s".', $id));
}

if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
$def = new ChildDefinition('jms_translation.dumper.symfony_adapter');
} else {
$def = new DefinitionDecorator('jms_translation.dumper.symfony_adapter');
}
$def = new ChildDefinition('jms_translation.dumper.symfony_adapter');
$def->addArgument(new Reference($id))->addArgument($attr[0]['alias']);
$container->setDefinition($id = 'jms_translation.dumper.wrapped_symfony_dumper.'.($i++), $def);

Expand Down
7 changes: 1 addition & 6 deletions DependencyInjection/Compiler/MountLoadersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use JMS\TranslationBundle\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

Expand All @@ -40,11 +39,7 @@ public function process(ContainerBuilder $container)
throw new RuntimeException(sprintf('The attribute "alias" must be defined for tag "translation.loader" for service "%s".', $id));
}

if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
$def = new ChildDefinition('jms_translation.loader.symfony_adapter');
} else {
$def = new DefinitionDecorator('jms_translation.loader.symfony_adapter');
}
$def = new ChildDefinition('jms_translation.loader.symfony_adapter');
$def->addArgument(new Reference($id));
$container->setDefinition($id = 'jms_translation.loader.wrapped_symfony_loader.'.($i++), $def);

Expand Down
8 changes: 3 additions & 5 deletions DependencyInjection/JMSTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use JMS\TranslationBundle\Translation\ConfigBuilder;

class JMSTranslationExtension extends Extension
{
Expand All @@ -32,10 +33,7 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

if (!class_exists('Symfony\Component\ClassLoader\ClassLoader')) {
$loader->load('console.xml');
}
$loader->load('console.xml');

$container->setParameter('jms_translation.source_language', $config['source_language']);
$container->setParameter('jms_translation.locales', $config['locales']);
Expand All @@ -46,7 +44,7 @@ public function load(array $configs, ContainerBuilder $container)

$requests = array();
foreach ($config['configs'] as $name => $extractConfig) {
$def = new Definition('JMS\TranslationBundle\Translation\ConfigBuilder');
$def = new Definition(ConfigBuilder::class);
$def->addMethodCall('setTranslationsDir', array($extractConfig['output_dir']));
$def->addMethodCall('setScanDirs', array($extractConfig['dirs']));

Expand Down
4 changes: 4 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@
<argument>%jms_translation.source_language%</argument>
</call>
</service>

<service id="JMS\TranslationBundle\Controller\TranslateController" alias="jms_translation.controller.translate_controller" public="true" />

<service id="jms_translation.controller.api_controller" class="%jms_translation.controller.api_controller.class%" public="true">
<argument id="jms_translation.config_factory" type="service"/>
<argument id="jms_translation.updater" type="service"/>
</service>

<service id="JMS\TranslationBundle\Controller\ApiController" alias="jms_translation.controller.api_controller" public="true"/>

<service id="jms_translation.updater" class="%jms_translation.updater.class%" public="true">
<argument type="service" id="jms_translation.loader_manager" />
Expand Down
27 changes: 0 additions & 27 deletions Tests/BaseTestCase.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class MountDumpersPassTest extends AbstractCompilerPassTestCase
{
protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new MountDumpersPass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class MountExtractorsPassTest extends AbstractCompilerPassTestCase
{
protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new MountExtractorsPass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class MountFileVisitorsPassTest extends AbstractCompilerPassTestCase
{
protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new MountFileVisitorsPass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class MountLoadersPassTest extends AbstractCompilerPassTestCase
{
protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new MountLoadersPass());
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/JMSTranslationExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class JMSTranslationExtensionTest extends AbstractExtensionTestCase
{
protected function getContainerExtensions()
protected function getContainerExtensions(): array
{
return array(
new JMSTranslationExtension(),
Expand Down
6 changes: 3 additions & 3 deletions Tests/Functional/Command/ExtractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testExtract()
$files = FileUtils::findTranslationFiles($outputDir);
$this->assertTrue(isset($files['messages']['en']));
}

public function testExtractDryRun()
{
$input = new ArgvInput(array(
Expand Down Expand Up @@ -86,9 +86,9 @@ public function testExtractDryRun()
);

$this->getApp()->run($input, $output = new Output());

foreach ($expectedOutput as $transID) {
$this->assertContains($transID, $output->getContent());
$this->assertStringContainsString($transID, $output->getContent());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace JMS\TranslationBundle\Tests\Functional\Fixture\TestBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/apples")
Expand Down
12 changes: 8 additions & 4 deletions Tests/Functional/ServiceInstantiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@

namespace JMS\TranslationBundle\Tests\Functional;

use JMS\TranslationBundle\Twig\TranslationExtension;
use JMS\TranslationBundle\Translation\ConfigFactory;
use JMS\TranslationBundle\Translation\Updater;

/**
* Make sure we instantiate services.
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class ServiceInstantiationTest extends BaseTestCase
{
public function setUp()
protected function setUp(): void
{
static::createClient();
}

public function provider()
{
return array(
array('jms_translation.updater', 'JMS\TranslationBundle\Translation\Updater'),
array('jms_translation.config_factory', 'JMS\TranslationBundle\Translation\ConfigFactory'),
array('jms_translation.twig_extension', 'JMS\TranslationBundle\Twig\TranslationExtension'),
array('jms_translation.updater', Updater::class),
array('jms_translation.config_factory', ConfigFactory::class),
array('jms_translation.twig_extension', TranslationExtension::class),
);
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Model/FileSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
namespace JMS\TranslationBundle\Tests\Model;

use JMS\TranslationBundle\Model\FileSource;
use JMS\TranslationBundle\Tests\BaseTestCase;
use PHPUnit\Framework\TestCase;

class FileSourceTest extends BaseTestCase
class FileSourceTest extends TestCase
{
public function testGetPath()
{
Expand Down
13 changes: 6 additions & 7 deletions Tests/Model/MessageCatalogueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Model\MessageCatalogue;
use PHPUnit\Framework\TestCase;

class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
class MessageCatalogueTest extends TestCase
{
public function testAdd()
{
Expand All @@ -41,11 +42,10 @@ public function testGet()
$this->assertSame($message, $catalogue->get('foo'));
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetThrowsExceptionWhenMessageDoesNotExist()
{
$this->expectException(\InvalidArgumentException::class);

$catalogue = new MessageCatalogue();
$catalogue->getDomain('foo');
}
Expand Down Expand Up @@ -78,11 +78,10 @@ public function testGetDomain()
$this->assertEquals(array('foo'), array_keys($col->all()));
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetDomainWhenDomainDoesNotExist()
{
$this->expectException(\InvalidArgumentException::class);

$catalogue = new MessageCatalogue();
$catalogue->getDomain('messages');
}
Expand Down
Loading