Skip to content

Commit 40792a3

Browse files
authored
Merge pull request #29 from LinioIT/build/update-project-base-code
build: update project base code
2 parents 90959df + bc7e99e commit 40792a3

21 files changed

+86
-61
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: composer install --prefer-dist --no-progress
2626

2727
- name: PHP Lint
28-
run: vendor/bin/php-cs-fixer fix --dry-run -v
28+
run: composer lint:check
2929

3030
- name: PHPUnit Tests
31-
run: vendor/bin/phpunit
31+
run: composer phpunit

.php_cs renamed to .php-cs-fixer.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,37 @@
44
->in(__DIR__ . '/src')
55
->in(__DIR__ . '/tests');
66

7-
return PhpCsFixer\Config::create()
8-
->setRules([
7+
$config = new PhpCsFixer\Config();
8+
return $config->setRules([
99
'@Symfony' => true,
10+
'@PHP71Migration:risky' => true,
11+
'@PHPUnit60Migration:risky' => true,
12+
'array_indentation' => true,
1013
'array_syntax' => ['syntax' => 'short'],
1114
'blank_line_after_opening_tag' => true,
1215
'concat_space' => ['spacing' => 'one'],
1316
'declare_strict_types' => true,
14-
'is_null' => ['use_yoda_style' => false],
17+
'increment_style' => ['style' => 'post'],
1518
'list_syntax' => ['syntax' => 'short'],
16-
'method_argument_space' => ['ensure_fully_multiline' => true],
19+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline' ],
20+
'method_chaining_indentation' => true,
1721
'modernize_types_casting' => true,
18-
'no_multiline_whitespace_before_semicolons' => true,
22+
'multiline_whitespace_before_semicolons' => false,
23+
'no_superfluous_elseif' => true,
24+
'no_superfluous_phpdoc_tags' => true,
1925
'no_useless_else' => true,
2026
'no_useless_return' => true,
2127
'ordered_imports' => true,
2228
'phpdoc_align' => false,
2329
'phpdoc_order' => true,
2430
'php_unit_construct' => true,
2531
'php_unit_dedicate_assert' => true,
26-
'pre_increment' => false,
32+
'return_assignment' => true,
2733
'single_line_comment_style' => true,
2834
'ternary_to_null_coalescing' => true,
35+
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
2936
'void_return' => true,
3037
])
3138
->setFinder($finder)
3239
->setUsingCache(true)
33-
->setRiskyAllowed(true);
40+
->setRiskyAllowed(true);

composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,14 @@
2323
"psr-4": {
2424
"Linio\\DynamicFormBundle\\": "tests/"
2525
}
26+
},
27+
"scripts": {
28+
"lint": "vendor/bin/php-cs-fixer fix --verbose --show-progress=dots",
29+
"lint:check": "vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=dots",
30+
"phpunit": "vendor/bin/phpunit",
31+
"test": [
32+
"@lint:check",
33+
"@phpunit"
34+
]
2635
}
27-
}
36+
}

src/DependencyInjection/Configuration.php

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,27 @@ public function getConfigTreeBuilder()
2727
$rootNode
2828
->useAttributeAsKey('name')
2929
->prototype('array')
30-
->useAttributeAsKey('field')
31-
->prototype('array')
32-
->children()
33-
->booleanNode('enabled')
34-
->defaultTrue()
35-
->end()
36-
37-
->scalarNode('type')
38-
->isRequired()
39-
->end()
40-
41-
->variableNode('options')
42-
->end()
43-
44-
->variableNode('transformer')
45-
->end()
46-
47-
->variableNode('validation')
48-
->end()
49-
50-
->scalarNode('data_provider')
51-
->end()
52-
53-
->scalarNode('help_message_provider')
54-
->end()
55-
->end()
56-
->end()
30+
->useAttributeAsKey('field')
31+
->prototype('array')
32+
->children()
33+
->booleanNode('enabled')
34+
->defaultTrue()
35+
->end()
36+
->scalarNode('type')
37+
->isRequired()
38+
->end()
39+
->variableNode('options')
40+
->end()
41+
->variableNode('transformer')
42+
->end()
43+
->variableNode('validation')
44+
->end()
45+
->scalarNode('data_provider')
46+
->end()
47+
->scalarNode('help_message_provider')
48+
->end()
49+
->end()
50+
->end()
5751
->end();
5852

5953
return $treeBuilder;

src/Form/FormFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function addEventSubscriber($formName, EventSubscriberInterface $eventSub
8282

8383
/**
8484
* @param string $key The key of the Form in the form configuration
85-
* @param mixed $data
85+
* @param array $data
8686
* @param array $options
8787
* @param string $name An name for the form. If empty, the key will be used
8888
*
@@ -242,7 +242,7 @@ public function loadHelpMessageProvider($alias)
242242
*/
243243
public function getConfiguration($name = null)
244244
{
245-
if (null === $name) {
245+
if ($name === null) {
246246
return $this->configuration;
247247
}
248248

tests/Form/FormFactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
use Linio\DynamicFormBundle\Exception\NonExistentFormException;
88
use Linio\DynamicFormBundle\Form\FormFactory;
99
use Linio\DynamicFormBundle\HelpMessageProvider;
10+
use PHPUnit\Framework\TestCase;
1011
use Prophecy\Prophecy\ObjectProphecy;
1112
use Symfony\Component\Form\DataTransformerInterface;
1213
use Symfony\Component\Form\Extension\Core\Type\FormType;
1314
use Symfony\Component\Form\FormBuilder;
1415
use Symfony\Component\Form\FormFactory as SymfonyFormFactory;
1516
use Symfony\Component\Validator\Constraints\IsTrue;
1617

17-
class FormFactoryTest extends \PHPUnit_Framework_TestCase
18+
class FormFactoryTest extends TestCase
1819
{
1920
/**
2021
* @var ObjectProphecy
@@ -31,11 +32,10 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
3132
*/
3233
protected $formFactoryMock;
3334

34-
/**
35-
* @expectedException \Linio\DynamicFormBundle\Exception\NonExistentFormException
36-
*/
3735
public function testIsThrowingExceptionWhenCreatingAnInexistentForm(): void
3836
{
37+
$this->expectException(NonExistentFormException::class);
38+
3939
$this->formFactory->setConfiguration(['foo' => []]);
4040
$this->formFactory->createForm('bar');
4141
}

tests/FormlyMapper/FormlyField/ChoiceFieldTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
namespace Linio\DynamicFormBundle\Tests\FormlyMapper\FormlyField;
66

77
use Linio\DynamicFormBundle\FormlyMapper\FormlyField\ChoiceField;
8+
use PHPUnit\Framework\TestCase;
89

9-
class ChoiceFieldTest extends \PHPUnit_Framework_TestCase
10+
class ChoiceFieldTest extends TestCase
1011
{
1112
/**
1213
* @var ChoiceField

tests/FormlyMapper/FormlyField/DateFieldTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
namespace Linio\DynamicFormBundle\Tests\FormlyMapper\FormlyField;
66

77
use Linio\DynamicFormBundle\FormlyMapper\FormlyField\DateField;
8+
use PHPUnit\Framework\TestCase;
89

9-
class DateFieldTest extends \PHPUnit_Framework_TestCase
10+
class DateFieldTest extends TestCase
1011
{
1112
/**
1213
* @var DateField

tests/FormlyMapper/FormlyField/EmailFieldTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
namespace Linio\DynamicFormBundle\Tests\FormlyMapper\FormlyField;
66

77
use Linio\DynamicFormBundle\FormlyMapper\FormlyField\EmailField;
8+
use PHPUnit\Framework\TestCase;
89

9-
class EmailFieldTest extends \PHPUnit_Framework_TestCase
10+
class EmailFieldTest extends TestCase
1011
{
1112
/**
1213
* @var EmailField

tests/FormlyMapper/FormlyField/EntityFieldTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
namespace Linio\DynamicFormBundle\Tests\FormlyMapper\FormlyField;
66

77
use Linio\DynamicFormBundle\FormlyMapper\FormlyField\EntityField;
8+
use PHPUnit\Framework\TestCase;
89

9-
class EntityFieldTest extends \PHPUnit_Framework_TestCase
10+
class EntityFieldTest extends TestCase
1011
{
1112
/**
1213
* @var EntityField

0 commit comments

Comments
 (0)