Skip to content

Commit 94ae925

Browse files
Merge branch '6.0' of github.com:darkwebdesign/symfony-addon-pack into issue-233-6.0
2 parents abf77dc + 6c723c4 commit 94ae925

File tree

14 files changed

+124
-159
lines changed

14 files changed

+124
-159
lines changed

.github/workflows/build.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Build'
2+
3+
on:
4+
push:
5+
6+
concurrency:
7+
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
8+
cancel-in-progress: true
9+
10+
jobs:
11+
rector:
12+
name: 'Rector'
13+
runs-on: 'ubuntu-24.04'
14+
steps:
15+
- name: 'Checkout'
16+
uses: 'actions/checkout@v4'
17+
- name: 'Setup PHP'
18+
uses: 'shivammathur/setup-php@v2'
19+
with:
20+
php-version: '8.3'
21+
- name: 'Composer Install'
22+
uses: 'ramsey/composer-install@v3'
23+
- name: 'Rector'
24+
run: 'vendor/bin/rector process --dry-run --no-progress-bar'
25+
26+
phpunit:
27+
name: 'PHPUnit'
28+
runs-on: 'ubuntu-24.04'
29+
strategy:
30+
matrix:
31+
include:
32+
- php: '8.0'
33+
- php: '8.1'
34+
- php: '8.2'
35+
- php: '8.3'
36+
fail-fast: false
37+
steps:
38+
- name: 'Checkout'
39+
uses: 'actions/checkout@v4'
40+
- name: 'Setup PHP'
41+
uses: 'shivammathur/setup-php@v2'
42+
with:
43+
php-version: "${{ matrix.php }}"
44+
- name: 'Composer Install'
45+
uses: 'ramsey/composer-install@v3'
46+
- name: 'PHPUnit'
47+
run: 'XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover phpunit-coverage.xml'
48+
- name: 'Code Climate'
49+
uses: 'paambaati/codeclimate-action@v6'
50+
with:
51+
coverageLocations: 'phpunit-coverage.xml:clover'
52+
env:
53+
CC_TEST_REPORTER_ID: "${{ secrets.CODECLIMATE_REPORTER_ID }}"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/.phpunit.result.cache
2-
/build/
1+
/.idea/
2+
/.phpunit.cache/
33
/composer.lock
44
/vendor/

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
{"name": "Raymond Schouten"}
1010
],
1111
"require": {
12-
"php": ">=8.0.2",
13-
"symfony/form": "6.0.*"
12+
"php": "^8.0",
13+
"symfony/event-dispatcher": "6.0.*",
14+
"symfony/form": "6.0.*",
15+
"symfony/options-resolver": "6.0.*"
1416
},
1517
"require-dev": {
1618
"darkwebdesign/symfony-addon-transformers": "6.0.*",
1719
"doctrine/orm": "^2.7",
18-
"phpunit/phpunit": "^8.5",
19-
"rector/rector": "^0.18.6"
20+
"phpunit/phpunit": "^9.5",
21+
"rector/rector": "^1.1"
2022
},
2123
"suggest": {
2224
"darkwebdesign/symfony-addon-pack": "All Symfony add-ons bundled together",

phpunit.xml.dist

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5+
cacheResultFile=".phpunit.cache/test-results"
56
colors="true"
67
executionOrder="depends,defects"
78
forceCoversAnnotation="true"
89
beStrictAboutCoversAnnotation="true"
910
beStrictAboutOutputDuringTests="true"
1011
beStrictAboutTodoAnnotatedTests="true"
12+
convertDeprecationsToExceptions="true"
13+
failOnRisky="true"
14+
failOnWarning="true"
1115
verbose="true">
1216

1317
<testsuites>
@@ -16,10 +20,11 @@
1620
</testsuite>
1721
</testsuites>
1822

19-
<filter>
20-
<whitelist processUncoveredFilesFromWhitelist="true">
23+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
24+
processUncoveredFiles="true">
25+
<include>
2126
<directory suffix=".php">src</directory>
22-
</whitelist>
23-
</filter>
27+
</include>
28+
</coverage>
2429

2530
</phpunit>

rector.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@
44

55
use Rector\Config\RectorConfig;
66
use Rector\Set\ValueObject\LevelSetList;
7-
use Rector\Symfony\Set\SymfonyLevelSetList;
7+
use Rector\Symfony\Set\SymfonySetList;
88

9-
return static function (RectorConfig $rectorConfig): void {
10-
$rectorConfig->paths([
9+
return RectorConfig::configure()
10+
->withPaths([
1111
__DIR__ . '/src',
1212
__DIR__ . '/tests',
13-
]);
14-
15-
$rectorConfig->sets([
13+
])
14+
->withSets([
1615
LevelSetList::UP_TO_PHP_80,
17-
SymfonyLevelSetList::UP_TO_SYMFONY_60,
18-
]);
19-
20-
$rectorConfig->importNames(true, false);
21-
$rectorConfig->importShortClasses(false);
22-
};
16+
SymfonySetList::SYMFONY_60,
17+
])
18+
->withImportNames(
19+
importDocBlockNames: false,
20+
importShortClasses: false,
21+
);

src/BooleanToYesNoSubscriber.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
*/
3636
class BooleanToYesNoSubscriber implements EventSubscriberInterface
3737
{
38-
/** @var string[] */
39-
private $fieldNames;
40-
41-
public function __construct(array $fieldNames)
42-
{
43-
$this->fieldNames = $fieldNames;
38+
public function __construct(
39+
/** @var string[] */
40+
private array $fieldNames
41+
) {
4442
}
4543

4644
/**

src/BooleanType.php

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class BooleanType extends AbstractType
4444
public function buildForm(FormBuilderInterface $builder, array $options): void
4545
{
4646
if (!class_exists(BooleanToValueTransformer::class)) {
47-
throw new \LogicException(sprintf('You cannot use "%s" as the "darkwebdesign/symfony-addon-transformers" package is not installed. Try running "composer require darkwebdesign/symfony-addon-transformers".', __CLASS__));
47+
throw new \LogicException(sprintf('You cannot use "%s" as the "darkwebdesign/symfony-addon-transformers" package is not installed. Try running "composer require darkwebdesign/symfony-addon-transformers".', self::class));
4848
}
4949

5050
$builder->addModelTransformer(new BooleanToValueTransformer($options['value_true'], $options['value_false']));
@@ -55,28 +55,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5555
*/
5656
public function configureOptions(OptionsResolver $resolver): void
5757
{
58-
$labelTrueNormalizer = function (Options $options, $value) {
59-
return !is_null($value) ? (string) $value : $this->humanize((string) $options['value_true']);
60-
};
58+
$labelTrueNormalizer = fn(Options $options, $value) =>
59+
!is_null($value) ? (string) $value : $this->humanize((string) $options['value_true']);
6160

62-
$labelFalseNormalizer = function (Options $options, $value) {
63-
return !is_null($value) ? (string) $value : $this->humanize((string) $options['value_false']);
64-
};
61+
$labelFalseNormalizer = fn(Options $options, $value) =>
62+
!is_null($value) ? (string) $value : $this->humanize((string) $options['value_false']);
6563

66-
$choicesNormalizer = function (Options $options) {
67-
return [
68-
$options['label_true'] => $options['value_true'],
69-
$options['label_false'] => $options['value_false'],
70-
];
71-
};
64+
$choicesNormalizer = fn(Options $options) => [
65+
$options['label_true'] => $options['value_true'],
66+
$options['label_false'] => $options['value_false'],
67+
];
7268

73-
$expandedNormalizer = function (Options $options) {
74-
return 'choice' !== $options['widget'];
75-
};
69+
$expandedNormalizer = fn(Options $options) => 'choice' !== $options['widget'];
7670

77-
$multipleNormalizer = function () {
78-
return false;
79-
};
71+
$multipleNormalizer = fn() => false;
8072

8173
$resolver->setDefaults([
8274
'label_true' => null,
@@ -109,7 +101,7 @@ public function getParent(): string
109101
}
110102

111103
/**
112-
* Makes a technical name human readable.
104+
* Makes a technical name human-readable.
113105
*/
114106
public function humanize(string $text): string
115107
{

src/EntityType.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
use Symfony\Component\OptionsResolver\Options;
3232
use Symfony\Component\OptionsResolver\OptionsResolver;
3333

34+
// @codeCoverageIgnoreStart
3435
if (!interface_exists(ManagerRegistry::class)) {
3536
throw new \LogicException('You cannot use "DarkWebDesign\SymfonyAddonFormTypes\EntityType" as the "doctrine/orm" package is not installed. Try running "composer require doctrine/orm".');
3637
}
38+
// @codeCoverageIgnoreEnd
3739

3840
/**
3941
* Entity form field type.
@@ -44,15 +46,9 @@
4446
*/
4547
class EntityType extends AbstractType
4648
{
47-
/** @var \Doctrine\Persistence\ManagerRegistry */
48-
private $registry;
49-
50-
/**
51-
* @param \Doctrine\Persistence\ManagerRegistry $registry
52-
*/
53-
public function __construct(ManagerRegistry $registry)
54-
{
55-
$this->registry = $registry;
49+
public function __construct(
50+
private ManagerRegistry $registry
51+
) {
5652
}
5753

5854
/**
@@ -61,7 +57,7 @@ public function __construct(ManagerRegistry $registry)
6157
public function buildForm(FormBuilderInterface $builder, array $options): void
6258
{
6359
if (!class_exists(EntityToIdentifierTransformer::class)) {
64-
throw new \LogicException(sprintf('You cannot use "%s" as the "darkwebdesign/symfony-addon-transformers" package is not installed. Try running "composer require darkwebdesign/symfony-addon-transformers".', __CLASS__));
60+
throw new \LogicException(sprintf('You cannot use "%s" as the "darkwebdesign/symfony-addon-transformers" package is not installed. Try running "composer require darkwebdesign/symfony-addon-transformers".', self::class));
6561
}
6662

6763
$builder->addViewTransformer(new EntityToIdentifierTransformer($options['entity_manager'], $options['class']));
@@ -73,7 +69,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
7369
public function configureOptions(OptionsResolver $resolver): void
7470
{
7571
if (!interface_exists(ObjectManager::class)) {
76-
throw new \LogicException(sprintf('You cannot use "%s" as the "doctrine/orm" package is not installed. Try running "composer require doctrine/orm".', __CLASS__));
72+
throw new \LogicException(sprintf('You cannot use "%s" as the "doctrine/orm" package is not installed. Try running "composer require doctrine/orm".', self::class));
7773
}
7874

7975
$registry = $this->registry;
@@ -99,9 +95,7 @@ public function configureOptions(OptionsResolver $resolver): void
9995
return $entityManager;
10096
};
10197

102-
$compoundNormalizer = function () {
103-
return false;
104-
};
98+
$compoundNormalizer = fn() => false;
10599

106100
$resolver->setDefaults([
107101
'entity_manager' => null,

src/JsonSchemaSubscriber.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@
3535
*/
3636
class JsonSchemaSubscriber implements EventSubscriberInterface
3737
{
38-
/** @var string */
39-
private $fieldName;
40-
41-
public function __construct(string $fieldName = 'schema')
42-
{
43-
$this->fieldName = $fieldName;
38+
public function __construct(
39+
private string $fieldName = 'schema'
40+
) {
4441
}
4542

4643
/**

0 commit comments

Comments
 (0)