Skip to content

feat: bump php to ">=7.2.5", use new language features of 7.2 #184

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ app/config/parameters.yml

# Composer
composer.phar
composer.lock

#PhpStorm
.idea
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('tetranz_select2_entity');
$rootNode = $treeBuilder->getRootNode();
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/TetranzSelect2EntityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TetranzSelect2EntityExtension extends Extension
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down
15 changes: 3 additions & 12 deletions Form/DataTransformer/EntitiesToPropertyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ class EntitiesToPropertyTransformer implements DataTransformerInterface
/** @var PropertyAccessor */
protected $accessor;

/**
* @param ObjectManager $em
* @param string $class
* @param string|null $textProperty
* @param string $primaryKey
* @param string $newTagPrefix
*/
public function __construct(ObjectManager $em, $class, $textProperty = null, $primaryKey = 'id', $newTagPrefix = '__', $newTagText = ' (NEW)')
public function __construct(ObjectManager $em, string $class, ?string $textProperty = null, string $primaryKey = 'id', string $newTagPrefix = '__', $newTagText = ' (NEW)')
{
$this->em = $em;
$this->className = $class;
Expand All @@ -53,9 +46,8 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr
* Transform initial entities to array
*
* @param mixed $entities
* @return array
*/
public function transform($entities)
public function transform($entities): array
{
if (empty($entities)) {
return array();
Expand Down Expand Up @@ -85,9 +77,8 @@ public function transform($entities)
* Transform array to a collection of entities
*
* @param array $values
* @return array
*/
public function reverseTransform($values)
public function reverseTransform($values): array
{
if (!is_array($values) || empty($values)) {
return array();
Expand Down
13 changes: 3 additions & 10 deletions Form/DataTransformer/EntityToPropertyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ class EntityToPropertyTransformer implements DataTransformerInterface
/** @var PropertyAccessor */
protected $accessor;

/**
* @param ObjectManager $em
* @param string $class
* @param string|null $textProperty
* @param string $primaryKey
* @param string $newTagPrefix
*/
public function __construct(ObjectManager $em, $class, $textProperty = null, $primaryKey = 'id', $newTagPrefix = '__', $newTagText = ' (NEW)')

public function __construct(ObjectManager $em, string $class, string $textProperty = null, string $primaryKey = 'id', string $newTagPrefix = '__', $newTagText = ' (NEW)')
{
$this->em = $em;
$this->className = $class;
Expand All @@ -54,9 +48,8 @@ public function __construct(ObjectManager $em, $class, $textProperty = null, $pr
* Transform entity to array
*
* @param mixed $entity
* @return array
*/
public function transform($entity)
public function transform($entity): array
{
$data = array();
if (empty($entity)) {
Expand Down
21 changes: 5 additions & 16 deletions Form/Type/Select2EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,15 @@ class Select2EntityType extends AbstractType
/** @var array */
protected $config;

/**
* @param ManagerRegistry $registry
* @param RouterInterface $router
* @param array $config
*/
public function __construct(ManagerRegistry $registry, RouterInterface $router, $config)
public function __construct(ManagerRegistry $registry, RouterInterface $router, array $config)
{
$this->registry = $registry;
$this->em = $registry->getManager();
$this->router = $router;
$this->config = $config;
}

public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
// custom object manager for this entity, override the default entity manager ?
if (isset($options['object_manager'])) {
Expand Down Expand Up @@ -97,7 +92,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder->addViewTransformer($transformer, true);
}

public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
parent::finishView($view, $form, $options);
// make variables available to the view
Expand Down Expand Up @@ -134,10 +129,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
$view->vars['class_type'] = $options['class_type'];
}

/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'object_manager' => null,
Expand Down Expand Up @@ -180,10 +172,7 @@ public function configureOptions(OptionsResolver $resolver)
);
}

/**
* @return string
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return 'tetranz_select2entity';
}
Expand Down
9 changes: 1 addition & 8 deletions Service/AutocompleteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@ class AutocompleteService
*/
private $doctrine;

/**
* @param FormFactoryInterface $formFactory
* @param ManagerRegistry $doctrine
*/
public function __construct(FormFactoryInterface $formFactory, ManagerRegistry $doctrine)
{
$this->formFactory = $formFactory;
$this->doctrine = $doctrine;
}

/**
* @param Request $request
* @param string|FormTypeInterface $type
*
* @return array
*/
public function getAutocompleteResults(Request $request, $type)
public function getAutocompleteResults(Request $request, $type): array
{
$form = $this->formFactory->create($type);
$fieldOptions = $form->get($request->get('field_name'))->getConfig()->getOptions();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=7.1.3",
"php": ">=7.2.5",
"doctrine/orm": ">=2.4",
"twig/twig": ">=2.9",
"symfony/property-access": ">=4.0",
Expand Down