diff --git a/.travis.yml b/.travis.yml index 295c72b..da52ba4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ php: - '7.0' - '7.1' - '7.2' + - '7.3' - nightly sudo: false @@ -29,28 +30,28 @@ env: matrix: fast_finish: true include: - - php: '5.4' + - php: '5.6' env: COMPOSER_FLAGS="--prefer-lowest" - php: '7.0' env: SYMFONY=2.3.* - - php: '7.2' + - php: '7.0' env: SYMFONY=2.7.* - - php: '7.2' + - php: '7.0' env: SYMFONY=2.8.* - - php: '7.2' - env: SYMFONY=3.3.* - - php: '7.2' + - php: '7.3' env: SYMFONY=3.4.* - - php: '7.2' - env: SYMFONY=4.0.* - - php: '7.2' - env: SYMFONY='dev-master as 4.1.x-dev' - - php: '7.2' + - php: '7.3' + env: SYMFONY=4.1.* + - php: '7.3' + env: SYMFONY=4.2.* + - php: '7.3' + env: SYMFONY='dev-master as 4.3.x-dev' + - php: '7.3' env: SYMFONY_DEPRECATIONS_HELPER=0 allow_failures: - php: nightly - env: SYMFONY_DEPRECATIONS_HELPER=0 - - env: SYMFONY='dev-master as 4.1.x-dev' + - env: SYMFONY='dev-master as 4.3.x-dev' before_install: - echo memory_limit = -1 >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; diff --git a/DependencyInjection/Compiler/TemplatingPass.php b/DependencyInjection/Compiler/TemplatingPass.php index de29e82..12cae57 100644 --- a/DependencyInjection/Compiler/TemplatingPass.php +++ b/DependencyInjection/Compiler/TemplatingPass.php @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container) if (false !== ($template = $container->getParameter('a2lix_translation_form.templating'))) { $resources = $container->getParameter('twig.form.resources'); - if (!in_array($template, $resources)) { + if (!\in_array($template, $resources)) { $resources[] = $template; $container->setParameter('twig.form.resources', $resources); } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0426058..979af25 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -25,8 +25,14 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('a2lix_translation_form'); + $treeBuilder = new TreeBuilder('a2lix_translation_form'); + + // Keep compatibility with symfony/config < 4.2 + if (!method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->root('a2lix_translation_form'); + } else { + $rootNode = $treeBuilder->getRootNode(); + } $rootNode ->children() diff --git a/Form/EventListener/TranslationsListener.php b/Form/EventListener/TranslationsListener.php index 7ec62e3..79e5862 100644 --- a/Form/EventListener/TranslationsListener.php +++ b/Form/EventListener/TranslationsListener.php @@ -54,7 +54,7 @@ public function preSetData(FormEvent $event) [ 'data_class' => $translationClass, 'fields' => $fieldsOptions[$locale], - 'required' => in_array($locale, $formOptions['required_locales']), + 'required' => \in_array($locale, $formOptions['required_locales']), ] ); } diff --git a/Form/Type/TranslatedEntityType.php b/Form/Type/TranslatedEntityType.php index 50637a5..b957e6e 100644 --- a/Form/Type/TranslatedEntityType.php +++ b/Form/Type/TranslatedEntityType.php @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver) { // BC for SF < 2.7 $optionProperty = 'choice_label'; - if (in_array('property', $resolver->getDefinedOptions())) { + if (\in_array('property', $resolver->getDefinedOptions())) { $optionProperty = 'property'; } diff --git a/Form/Type/TranslationsFormsType.php b/Form/Type/TranslationsFormsType.php index f22b9ff..efd81f5 100644 --- a/Form/Type/TranslationsFormsType.php +++ b/Form/Type/TranslationsFormsType.php @@ -59,7 +59,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) foreach ($options['locales'] as $locale) { if (isset($formsOptions[$locale])) { $builder->add($locale, $options['form_type'], - $formsOptions[$locale] + ['required' => in_array($locale, $options['required_locales'])] + $formsOptions[$locale] + ['required' => \in_array($locale, $options['required_locales'])] ); } } diff --git a/Locale/DefaultProvider.php b/Locale/DefaultProvider.php index 11032db..c82ce23 100644 --- a/Locale/DefaultProvider.php +++ b/Locale/DefaultProvider.php @@ -44,8 +44,8 @@ class DefaultProvider implements LocaleProviderInterface */ public function __construct(array $locales, $defaultLocale, array $requiredLocales = []) { - if (!in_array($defaultLocale, $locales)) { - if (count($locales) > 0) { + if (!\in_array($defaultLocale, $locales)) { + if (\count($locales) > 0) { throw new \InvalidArgumentException(sprintf('Default locale `%s` not found within the configured locales `[%s]`. Perhaps you need to add it to your `a2lix_translation_form.locales` bundle configuration?', $defaultLocale, implode(',', $locales))); } diff --git a/TranslationForm/TranslationForm.php b/TranslationForm/TranslationForm.php index 814d672..0299e45 100644 --- a/TranslationForm/TranslationForm.php +++ b/TranslationForm/TranslationForm.php @@ -146,7 +146,7 @@ protected function getTranslationFields($translationClass, array $exclude = []) $metadataClass = $manager->getMetadataFactory()->getMetadataFor($translationClass); foreach ($metadataClass->fieldMappings as $fieldMapping) { - if (!in_array($fieldMapping['fieldName'], ['id', 'locale']) && !in_array($fieldMapping['fieldName'], $exclude)) { + if (!\in_array($fieldMapping['fieldName'], ['id', 'locale']) && !\in_array($fieldMapping['fieldName'], $exclude)) { $fields[] = $fieldMapping['fieldName']; } }