Skip to content

Commit 3d7d3fd

Browse files
authored
Support PHP 8.5 and Symfony 8 components (#98)
* Update Symfony dependencies to include version 8.0 Updated Symfony package versions to support up to 8.0. * Fixed CS issues with interface compatibility * Add support for Symfony 8 components in CI and remove Symfony 5 as it's below our supported PHP version anyway. * Modified Symfony version exclusions * Use PHP version 8.3 for Symfony 8 * Run test specific Composer versions directly without replacing the main composer.json during tests * Update Composer configurations and CI setup for Symfony 8 compatibility * Symfony 8 required PHP 8.4 * Refactor command registration in propel.php for Symfony 8 compatibility and clean up whitespace in ObjectBuilder.php * Refactor command addition in propel.php and TestCaseFixtures.php for Symfony 8 compatibility * Fix MigrationTest to use addCommands for Symfony < 8 compatibility * Remove Spryker strict incompatible phpcs rules * Upgrade phpstan for compatibility with our config file * Resolved test errors preventing Symfony 8 compatibility * Add BC wrappers for Symfony constraints to support versions < 8 and 8+ * Added missing *Validator classes * Update array syntax handling for Symfony compatibility in validation constraints * Refactor validation constraints to enhance Symfony 8 compatibility by updating parameter handling for Date, Length, Regex, Type, and Unique constraints. * Enhance Length constraint to support array syntax for Symfony 8 compatibility by mapping generic messages to specific parameters. * CS fixes * CS fixes * CS fixes * CS fixes * Added back file doc blocks because Spryker thinks this is a good idea... * Exclude Spryker.Commenting.FileDocBlock.FileDocBlockWrong - antiquated BS * Removed file doc block again because * Fixed property name * Fixed sniff exclusion * Added Propel file level docblocks * Added SprykerStrict sniffs * Move to services for CI - tests breaking due to version conflict with underlying containers * Restore env vars as they're needed for test script * Add MySQL grants * Added and updated Symfony polyfills based on min PHP version required
1 parent 248fb95 commit 3d7d3fd

Some content is hidden

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

44 files changed

+585
-176
lines changed

.github/actions/setup-php/action.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ runs:
3838
${{ runner.os }}-composer-php:${{ inputs.php-version }}-
3939
${{ runner.os }}-composer-
4040
41-
- name: Composer validate
42-
run: composer validate
43-
shell: bash
44-
45-
- name: Composer install
46-
run: composer install --prefer-dist --no-interaction
41+
- name: Composer update
42+
run: COMPOSER=tests/composer/composer-symfony${{ inputs.symfony-version }}.json composer update --prefer-dist --no-interaction
4743
shell: bash

.github/workflows/ci.yml

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -15,100 +15,78 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
php-version: [ '8.1', '8.4' ]
18+
php-version: [ '8.1', '8.5' ]
1919
db-type: [ sqlite, mysql, pgsql, agnostic ]
20-
symfony-version: [ '5-min', '5-max', '6-min', '6-max', '7-min', '7-max']
20+
symfony-version: [ '6-min', '6-max', '7-min', '7-max', '8-min', '8-max']
2121
exclude:
22-
- symfony-version: '6-min'
23-
php-version: '8.1'
24-
- symfony-version: '6-max'
25-
php-version: '8.1'
2622
- symfony-version: '7-min'
2723
php-version: '8.1'
2824
- symfony-version: '7-max'
2925
php-version: '8.1'
26+
- symfony-version: '8-min'
27+
php-version: '8.1'
28+
- symfony-version: '8-max'
29+
php-version: '8.1'
30+
services:
31+
postgres:
32+
image: ${{ matrix.php-version == '8.1' && 'postgres:9' || 'postgres:latest' }}
33+
env:
34+
POSTGRES_DB: propel_tests
35+
POSTGRES_USER: propel
36+
POSTGRES_PASSWORD: propel
37+
ports:
38+
- 5432:5432
39+
options: >-
40+
--health-cmd pg_isready
41+
--health-interval 10s
42+
--health-timeout 5s
43+
--health-retries 5
44+
mysql:
45+
image: ${{ matrix.php-version == '8.1' && 'mariadb:10.2' || 'mysql:latest' }}
46+
env:
47+
MYSQL_ROOT_PASSWORD: propel
48+
MYSQL_DATABASE: propel_tests
49+
MYSQL_USER: propel
50+
MYSQL_PASSWORD: propel
51+
ports:
52+
- 3306:3306
53+
options: >-
54+
--health-cmd="mysqladmin ping"
55+
--health-interval=10s
56+
--health-timeout=5s
57+
--health-retries=3
3058
env:
3159
DB_NAME: 'propel_tests'
3260
DB_USER: 'propel'
3361
DB_PW: 'propel'
3462
steps:
35-
- name: Install PostgreSQL latest
36-
if: matrix.db-type == 'pgsql' && matrix.php-version != '8.1'
37-
uses: CasperWA/postgresql-action@v1.2
38-
with:
39-
postgresql db: $DB_NAME
40-
postgresql user: $DB_USER
41-
postgresql password: $DB_PW
42-
43-
- name: Install PostgreSQL min
44-
if: matrix.db-type == 'pgsql' && matrix.php-version == '8.1'
45-
uses: CasperWA/postgresql-action@v1.2
46-
with:
47-
postgresql version: 9
48-
postgresql db: $DB_NAME
49-
postgresql user: $DB_USER
50-
postgresql password: $DB_PW
51-
52-
- name: Install MySQL latest
53-
if: matrix.db-type == 'mysql' && matrix.php-version != '8.1'
54-
uses: mirromutth/mysql-action@v1.1
55-
with:
56-
mysql root password: $DB_PW
57-
58-
- name: Install MariaDb min
59-
if: matrix.db-type == 'mysql' && matrix.php-version == '8.1'
60-
uses: getong/mariadb-action@v1.1
61-
with:
62-
mariadb version: '10.2'
63-
mysql root password: $DB_PW
64-
6563
- uses: actions/checkout@v3
6664

67-
- name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }})
68-
run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json
69-
7065
- id: build-container
7166
uses: ./.github/actions/setup-php
7267
with:
7368
php-version: ${{ matrix.php-version }}
7469
symfony-version: ${{ matrix.symfony-version }}
7570
cache-key-suffix: ${{ matrix.db-type}}
7671

77-
- name: Wait for MySQL server to load
78-
if: matrix.db-type == 'mysql'
79-
run: |
80-
bash -c "
81-
for i in {1..10}; do
82-
mysqladmin -h 127.0.0.1 -u root status >/dev/null 2>&1 && exit 0 || sleep 6
83-
echo 'trying again'
84-
done;
85-
echo 'could not establish connection after 10 tries'
86-
exit 1
87-
"
88-
env:
89-
MYSQL_PWD: ${{ env.DB_PW }}
90-
91-
- name: Create MySQL Propel user
72+
- name: Grant MySQL privileges to propel user
9273
if: matrix.db-type == 'mysql'
9374
run: |
9475
mysql -h 127.0.0.1 -u root -e "
95-
CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PW';
96-
CREATE USER '$DB_USER'@'%' IDENTIFIED BY '$DB_PW';
97-
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost';
98-
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'%';
76+
GRANT ALL PRIVILEGES ON *.* TO 'propel'@'%';
9977
FLUSH PRIVILEGES;
10078
"
10179
env:
102-
MYSQL_PWD: ${{ env.DB_PW }}
80+
MYSQL_PWD: propel
10381

10482
- name: Setup database for test suite
10583
if: matrix.db-type != 'agnostic'
10684
run: tests/bin/setup.${{ matrix.db-type }}.sh
10785

10886
- name: Run tests
109-
shell: 'script -q -e -c "bash {0}"'
87+
shell: bash
11088
run: |
111-
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.symfony-version }} == '5-max' ]]; then
89+
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.symfony-version }} == '6-max' ]]; then
11290
export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --verbose --coverage-clover=tests/coverage.xml
11391
else
11492
vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml
@@ -117,7 +95,7 @@ jobs:
11795
SYMFONY_VERSION: ${{ matrix.symfony-version }}
11896

11997
- name: Code Coverage Report
120-
if: success() && matrix.php-version == '8.1' && matrix.symfony-version == '5-max'
98+
if: success() && matrix.php-version == '8.1' && matrix.symfony-version == '6-max'
12199
uses: codecov/codecov-action@v1
122100
with:
123101
flags: ${{ matrix.php-version }}, ${{ matrix.db-type }}, ${{ matrix.symfony-version }}
@@ -182,7 +160,7 @@ jobs:
182160
run: |
183161
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
184162
&& composer stan -- -a autoload.php.dist tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*[^Query].php
185-
163+
186164
query-code-style:
187165
runs-on: ubuntu-24.04
188166
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
vendor/
44
composer.phar
55
/composer.lock
6+
/tests/composer/*.lock
67
autoload.php
78
phpunit.xml
89
.phpunit.result.cache

bin/propel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
foreach ($finder as $file) {
3131
$r = new \ReflectionClass($ns . $file->getBasename('.php'));
3232
if ($r->isSubclassOf(Command::class) && !$r->isAbstract()) {
33-
$app->add($r->newInstance());
33+
$app->addCommands([$r->newInstance()]); // Using addCommands for BC with Symfony <8.0
3434
}
3535
}
3636

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525
"ext-xml": "*",
2626
"php": ">=8.1",
2727
"psr/log": "^1.0 || ^2.0 || ^3.0",
28-
"symfony/yaml": "^5.0.0 || ^6.0.0 || ^7.0.0",
29-
"symfony/config": "^5.0.0 || ^6.0.0 || ^7.0.0",
30-
"symfony/console": "^5.0.0 || ^6.0.0 || ^7.0.0",
31-
"symfony/filesystem": "^5.0.0 || ^6.0.0 || ^7.0.0",
32-
"symfony/finder": "^5.0.0 || ^6.0.0 || ^7.0.0",
33-
"symfony/translation": "^5.0.0 || ^6.0.0 || ^7.0.0",
34-
"symfony/validator": "^5.0.0 || ^6.0.0 || ^7.0.0",
35-
"symfony/polyfill-php82": "^1.31",
36-
"symfony/polyfill-php83": "^1.31",
37-
"symfony/polyfill-php84": "^1.31"
28+
"symfony/yaml": "^6.0.0 || ^7.0.0 || ^8.0.0",
29+
"symfony/config": "^6.0.0 || ^7.0.0 || ^8.0.0",
30+
"symfony/console": "^6.0.0 || ^7.0.0 || ^8.0.0",
31+
"symfony/filesystem": "^6.0.0 || ^7.0.0 || ^8.0.0",
32+
"symfony/finder": "^6.0.0 || ^7.0.0 || ^8.0.0",
33+
"symfony/translation": "^6.0.0 || ^7.0.0 || ^8.0.0",
34+
"symfony/validator": "^6.0.0 || ^7.0.0 || ^8.0.0",
35+
"symfony/polyfill-php82": "^1.33",
36+
"symfony/polyfill-php83": "^1.33",
37+
"symfony/polyfill-php84": "^1.33",
38+
"symfony/polyfill-php85": "^1.33"
3839
},
3940
"require-dev": {
4041
"monolog/monolog": "^1.3 || ^2.3 || ^3.0",

phpcs.xml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<description>
44
Propel Coding Standard.
55

6-
Extends Spryker+Slevomatik Coding Standard.
6+
Extends Spryker Coding Standard.
77
</description>
88

99
<config name="installed_paths" value="../../spryker/code-sniffer"/>
@@ -12,18 +12,9 @@
1212

1313
<file>src/</file>
1414

15-
<rule ref="Spryker"/>
16-
17-
<rule ref="vendor/spryker/code-sniffer/SprykerStrict/ruleset.xml">
15+
<rule ref="SprykerStrict">
1816
<exclude name="SprykerStrict.TypeHints.ParameterTypeHint"/>
1917
<exclude name="SprykerStrict.TypeHints.PropertyTypeHint"/>
2018
<exclude name="SprykerStrict.TypeHints.ReturnTypeHint"/>
2119
</rule>
22-
23-
<rule ref="Spryker.Internal.SprykerDisallowFunctions">
24-
<properties>
25-
<!-- We want to prevent 8.0+ functions to break 7.4 compatibility -->
26-
<property name="phpVersion" value="7.4"/>
27-
</properties>
28-
</rule>
2920
</ruleset>

src/Propel/Generator/Builder/Om/ObjectBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,13 +1915,13 @@ public function hashCode()
19151915
$checkExpression = implode(" &&\n$offset", $checks);
19161916
$script .= "
19171917
\$pkIsValid = $checkExpression;
1918-
1918+
19191919
if (\$pkIsValid) {
19201920
\$json = json_encode(\$this->getPrimaryKey(), JSON_UNESCAPED_UNICODE);
19211921
if (\$json === false) {
19221922
throw new RuntimeException('Failed to encode PK as JSON.');
19231923
}
1924-
1924+
19251925
return crc32(\$json);
19261926
}
19271927
";

src/Propel/Generator/Command/AbstractCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class AbstractCommand extends Command
4848
* @return void
4949
*/
5050
#[\Override]
51-
protected function configure()
51+
protected function configure(): void
5252
{
5353
$this
5454
->addOption('platform', null, InputOption::VALUE_REQUIRED, 'The platform to use. Define a full qualified class name or mysql|pgsql|sqlite|mssql|oracle.')

src/Propel/Generator/Command/ConfigConvertCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ConfigConvertCommand extends AbstractCommand
3434
* @inheritDoc
3535
*/
3636
#[\Override]
37-
protected function configure()
37+
protected function configure(): void
3838
{
3939
$this
4040
->addOption('config-dir', null, InputOption::VALUE_REQUIRED, 'The directory where the configuration file is placed.', self::DEFAULT_CONFIG_DIRECTORY)

src/Propel/Generator/Command/DataDictionaryExportCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class DataDictionaryExportCommand extends AbstractCommand
4040
* @return void
4141
*/
4242
#[\Override]
43-
protected function configure()
43+
protected function configure(): void
4444
{
4545
parent::configure();
4646

0 commit comments

Comments
 (0)