Skip to content

Commit 2e36a7e

Browse files
authored
chore: Remove deprecation and start v2.0 #FRAM-221 (#18)
* chore: Uncomment new method on interface + remove deprecated methods (#FRAM-221) * ci: fix failing test * chore: Remove deprecated code and old SF compatibility (#FRAM-221) * chore: Add Override attributes + fix psalm errors (#FRAM-221) * ci: update infection for php 8.4 compatibility * ci: fix infection options * chore: Add type on properties and methods (#FRAM-221) * chore: Psalm lvl 2 (#FRAM-221) * chore: Update to phpunit 13 (#FRAM-221) * chore: compatibility with SF 8 (#FRAM-221) * ci: remove psalm on SF compatibility job * chore: compatibility with SF 6.4
1 parent 3d588ec commit 2e36a7e

186 files changed

Lines changed: 1892 additions & 3651 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/php.yml‎

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
14+
php-versions: ['8.4', '8.5']
1515
name: PHP ${{ matrix.php-versions }}
1616

1717
steps:
@@ -43,6 +43,43 @@ jobs:
4343
- name: Run test suite
4444
run: composer run-script tests
4545

46+
sf-compatibility:
47+
runs-on: ubuntu-latest
48+
strategy:
49+
matrix:
50+
sf-versions: ['6.4', '7.4', '8.0']
51+
name: Symfony ${{ matrix.sf-versions }}
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
56+
- name: Set Timezone
57+
uses: szenius/set-timezone@v1.0
58+
with:
59+
timezoneLinux: "Europe/Paris"
60+
61+
- name: Install PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: 8.4
65+
extensions: json, intl
66+
ini-values: date.timezone=Europe/Paris
67+
- name: Check PHP Version
68+
run: php -v
69+
70+
- name: Install dependencies
71+
run: composer install --prefer-dist --no-progress
72+
73+
# psalm 6 is not compatible with Symfony 6.4, so remove it
74+
- name: Remove psalm
75+
run: composer remove --dev vimeo/psalm
76+
77+
- name: Set Symfony version
78+
run: composer require --dev "symfony/symfony:~${{ matrix.sf-versions }}.0"
79+
80+
- name: Run test suite
81+
run: composer run-script tests
82+
4683
analysis:
4784
name: Analysis
4885
runs-on: ubuntu-latest
@@ -58,14 +95,14 @@ jobs:
5895
- name: Install PHP
5996
uses: shivammathur/setup-php@v2
6097
with:
61-
php-version: 7.4
98+
php-version: 8.4
6299
extensions: json
63100
ini-values: date.timezone=Europe/Paris
64101

65102
- name: Install Infection
66103
run: |
67-
wget https://github.com/infection/infection/releases/download/0.21.5/infection.phar
68-
wget https://github.com/infection/infection/releases/download/0.21.5/infection.phar.asc
104+
wget https://github.com/infection/infection/releases/download/0.32.6/infection.phar
105+
wget https://github.com/infection/infection/releases/download/0.32.6/infection.phar.asc
69106
chmod +x infection.phar
70107
gpg --recv-keys C6D76C329EBADE2FB9C458CFC5095986493B4AA0
71108
gpg --with-fingerprint --verify infection.phar.asc infection.phar
@@ -83,7 +120,7 @@ jobs:
83120
- name: Run Infection
84121
run: |
85122
git fetch --depth=1 origin $GITHUB_BASE_REF
86-
./infection.phar --logger-github --git-diff-filter=AM --min-msi=80
123+
./infection.phar --logger-github --git-diff-base=origin/$GITHUB_BASE_REF --git-diff-filter=AM --min-msi=80
87124
88125
coverage:
89126
name: Test coverage
@@ -100,7 +137,7 @@ jobs:
100137
- name: Install PHP
101138
uses: shivammathur/setup-php@v2
102139
with:
103-
php-version: 8.1
140+
php-version: 8.4
104141
extensions: json
105142
ini-values: date.timezone=Europe/Paris
106143

‎composer.json‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,25 @@
1111
"autoload": {
1212
"psr-4": {
1313
"Bdf\\Form\\": "src"
14-
},
15-
"classmap": ["polyfill/WeakReference.php"]
14+
}
1615
},
1716
"autoload-dev": {
1817
"psr-4": {
1918
"Bdf\\Form\\": "tests"
2019
}
2120
},
2221
"require": {
23-
"php": ">=7.4",
24-
"symfony/property-access": "~4.3|~5.0|~6.0|~7.0",
25-
"symfony/validator": "~4.3|~5.0|~6.0|~7.0",
26-
"symfony/polyfill-php80": "~1.22"
22+
"php": "~8.4",
23+
"symfony/property-access": "~6.4|~7.0|~8.0",
24+
"symfony/validator": "~6.4|~7.0|~8.0"
2725
},
2826
"require-dev": {
29-
"symfony/security-csrf": "~4.3|~5.0|~6.0|~7.0",
27+
"symfony/security-csrf": "~6.4|~7.0|~8.0",
3028
"giggsey/libphonenumber-for-php": "~8.0|~9.0",
31-
"phpunit/phpunit": "~7.0|~8.0|~9.0",
32-
"vimeo/psalm": "~4.30|~5.22",
33-
"symfony/http-foundation": "~4.3|~5.0|~6.0|~7.0",
34-
"symfony/form": "~4.3|~5.0|~6.0|~7.0"
29+
"phpunit/phpunit": "~13.0",
30+
"vimeo/psalm": "~6.15.1",
31+
"symfony/http-foundation": "~6.4|~7.0|~8.0",
32+
"symfony/form": "~6.4|~7.0|~8.0"
3533
},
3634
"suggest": {
3735
"symfony/security-csrf": "For enable CSRF element",

‎phpunit.xml.dist‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
2-
<phpunit bootstrap="tests/bootstrap.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
processIsolation="false"
8-
stopOnFailure="false"
9-
stderr="true"
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="tests/bootstrap.php"
5+
colors="true"
6+
processIsolation="false"
7+
stopOnFailure="false"
8+
stderr="true"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
10+
cacheDirectory=".phpunit.cache"
1011
>
11-
<php>
12-
<!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
13-
<!--<ini name="error_reporting" value="-16385"/>-->
14-
<ini name="error_reporting" value="-1" />
15-
<ini name="zend.enable_gc" value="0" />
16-
<ini name="memory_limit" value="2G" />
17-
</php>
18-
19-
<testsuites>
20-
<testsuite name="All Test Suite">
21-
<directory suffix="Test.php">tests</directory>
22-
</testsuite>
23-
</testsuites>
24-
<filter>
25-
<whitelist processUncoveredFilesFromWhitelist="false">
26-
<directory suffix=".php">src</directory>
27-
</whitelist>
28-
</filter>
12+
<php>
13+
<!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
14+
<!--<ini name="error_reporting" value="-16385"/>-->
15+
<ini name="error_reporting" value="-1"/>
16+
<ini name="zend.enable_gc" value="0"/>
17+
<ini name="memory_limit" value="2G"/>
18+
</php>
19+
<testsuites>
20+
<testsuite name="All Test Suite">
21+
<directory suffix="Test.php">tests</directory>
22+
</testsuite>
23+
</testsuites>
24+
<source>
25+
<include>
26+
<directory suffix=".php">src</directory>
27+
</include>
28+
</source>
2929
</phpunit>

‎polyfill/WeakReference.php‎

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

‎psalm.xml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<psalm
3-
errorLevel="3"
3+
errorLevel="2"
44
resolveFromConfigFile="true"
55
findUnusedBaselineEntry="false"
66
findUnusedCode="false"
@@ -15,4 +15,11 @@
1515
<directory name="vendor" />
1616
</ignoreFiles>
1717
</projectFiles>
18+
19+
<issueHandlers>
20+
<ClassMustBeFinal errorLevel="suppress" />
21+
<DocblockTypeContradiction errorLevel="suppress" />
22+
<RedundantConditionGivenDocblockType errorLevel="suppress" />
23+
<RedundantCastGivenDocblockType errorLevel="suppress" />
24+
</issueHandlers>
1825
</psalm>

‎src/AbstractElementBuilder.php‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Bdf\Form\Util\TransformerBuilderTrait;
99
use Bdf\Form\Util\ValidatorBuilderTrait;
1010
use Bdf\Form\Validator\ValueValidatorInterface;
11+
use Override;
1112

1213
/**
1314
* Base builder for elements
@@ -20,15 +21,8 @@ abstract class AbstractElementBuilder implements ElementBuilderInterface
2021
use TransformerBuilderTrait;
2122
use ValidatorBuilderTrait;
2223

23-
/**
24-
* @var RegistryInterface
25-
*/
26-
private $registry;
27-
28-
/**
29-
* @var mixed
30-
*/
31-
private $value;
24+
private readonly RegistryInterface $registry;
25+
private mixed $value = null;
3226

3327

3428
/**
@@ -41,19 +35,15 @@ public function __construct(?RegistryInterface $registry = null)
4135
$this->registry = $registry ?: new Registry();
4236
}
4337

44-
/**
45-
* {@inheritdoc}
46-
*/
47-
final public function value($value)
38+
#[Override]
39+
final public function value(mixed $value): static
4840
{
4941
$this->value = $value;
5042

5143
return $this;
5244
}
5345

54-
/**
55-
* {@inheritdoc}
56-
*/
46+
#[Override]
5747
final public function buildElement(): ElementInterface
5848
{
5949
$element = $this->createElement($this->buildValidator(), $this->buildTransformer());
@@ -75,9 +65,7 @@ final public function buildElement(): ElementInterface
7565
*/
7666
abstract protected function createElement(ValueValidatorInterface $validator, TransformerInterface $transformer): ElementInterface;
7767

78-
/**
79-
* {@inheritdoc}
80-
*/
68+
#[Override]
8169
final protected function registry(): RegistryInterface
8270
{
8371
return $this->registry;

‎src/Aggregate/ArrayChildBuilder.php‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
*/
1515
class ArrayChildBuilder extends ChildBuilder
1616
{
17-
/**
18-
* @var bool
19-
*/
20-
private $filterEmptyValues = true;
17+
private bool $filterEmptyValues = true;
2118

2219
/**
2320
* ArrayChildBuilder constructor.
@@ -30,7 +27,7 @@ public function __construct(string $name, ElementBuilderInterface $elementBuilde
3027
{
3128
parent::__construct($name, $elementBuilder, $registry);
3229

33-
$this->addFilterProvider([$this, 'provideEmptyValueFilter']);
30+
$this->addFilterProvider($this->provideEmptyValueFilter(...));
3431
}
3532

3633
/**

0 commit comments

Comments
 (0)