From 496f9338cd1ec767079d3d33c30b7732bb92b400 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 18:48:02 +0800 Subject: [PATCH 01/10] chore: update php-mysql-replication version constraint to support v9 Update the krowinski/php-mysql-replication dependency constraint to allow both v8 and v9, providing compatibility with the latest version while maintaining backward compatibility. --- composer.json | 2 +- src/trigger/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d9aca89b8..f288abfc4 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "google/recaptcha": "^1.2", "guzzlehttp/uri-template": "^1.0", "hyperf/elasticsearch": "~3.2.0", - "krowinski/php-mysql-replication": "^8.0", + "krowinski/php-mysql-replication": "^8.0 || ^9.0", "laravel/serializable-closure": "^1.0 || ^2.0", "league/commonmark": "^1.3 || ^2.0.2", "nesbot/carbon": "^2.0 || ^3.0", diff --git a/src/trigger/composer.json b/src/trigger/composer.json index c07786297..1be0262c0 100644 --- a/src/trigger/composer.json +++ b/src/trigger/composer.json @@ -35,7 +35,7 @@ "hyperf/stringable": "~3.2.0", "hyperf/support": "~3.2.0", "hyperf/tappable": "~3.2.0", - "krowinski/php-mysql-replication": "^8.0", + "krowinski/php-mysql-replication": "^8.0 || ^9.0", "ramsey/uuid": "^4.7" }, "suggest": { From 40e67191e12567d2886f749ffc57893d35e540aa Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 18:55:20 +0800 Subject: [PATCH 02/10] Add Doctrine DBAL v4 compatibility for type handling Introduces getDoctrineTypeName() to support Doctrine DBAL v4, where getName() was removed from Type and AbstractPlatform. Updates type and platform name retrieval logic to ensure compatibility with both DBAL v3 and v4. Co-Authored-By: Deeka Wong <8337659+huangdijia@users.noreply.github.com> --- src/ide-helper/src/Command/ModelCommand.php | 49 ++++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/ide-helper/src/Command/ModelCommand.php b/src/ide-helper/src/Command/ModelCommand.php index 286778105..1fc871ca8 100644 --- a/src/ide-helper/src/Command/ModelCommand.php +++ b/src/ide-helper/src/Command/ModelCommand.php @@ -274,6 +274,38 @@ protected function getTypeOverride(string $type): string return $typeOverrides[$type] ?? $type; } + /** + * Get the type name from a Doctrine Type instance. + * Doctrine DBAL v4 compatibility: getName() was removed from Type. + */ + protected function getDoctrineTypeName(\Doctrine\DBAL\Types\Type $type): string + { + // For DBAL v3 and earlier + if (method_exists($type, 'getName')) { + return $type->getName(); + } + + // For DBAL v4, map type instances to their string names + $typeClass = get_class($type); + $typeMap = [ + \Doctrine\DBAL\Types\StringType::class => 'string', + \Doctrine\DBAL\Types\TextType::class => 'text', + \Doctrine\DBAL\Types\IntegerType::class => 'integer', + \Doctrine\DBAL\Types\BigIntType::class => 'bigint', + \Doctrine\DBAL\Types\SmallIntType::class => 'smallint', + \Doctrine\DBAL\Types\FloatType::class => 'float', + \Doctrine\DBAL\Types\DecimalType::class => 'decimal', + \Doctrine\DBAL\Types\BooleanType::class => 'boolean', + \Doctrine\DBAL\Types\DateType::class => 'date', + \Doctrine\DBAL\Types\DateTimeType::class => 'datetime', + \Doctrine\DBAL\Types\DateTimeTzType::class => 'datetimetz', + \Doctrine\DBAL\Types\TimeType::class => 'time', + \Doctrine\DBAL\Types\GuidType::class => 'guid', + ]; + + return $typeMap[$typeClass] ?? 'mixed'; + } + /** * Load the properties from the database table. * @@ -285,23 +317,24 @@ protected function getPropertiesFromTable($model) $connection = $model->getConnection(); $table = $connection->getTablePrefix() . $model->getTable(); $schema = $connection->getDoctrineSchemaManager($table); - $databasePlatform = $schema->getDatabasePlatform(); + $databasePlatform = $connection->getDoctrineConnection()->getDatabasePlatform(); $databasePlatform->registerDoctrineTypeMapping('enum', 'string'); - $platformName = $databasePlatform->getName(); + // Doctrine DBAL v4 compatibility: getName() was removed from AbstractPlatform + $platformName = method_exists($databasePlatform, 'getName') + ? $databasePlatform->getName() + : strtolower((new \ReflectionClass($databasePlatform))->getShortName()); $customTypes = $this->config->get("ide-helper.model.custom_db_types.{$platformName}", []); foreach ($customTypes as $yourTypeName => $doctrineTypeName) { $databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName); } - $database = null; - if (strpos($table, '.')) { - [$database, $table] = explode('.', $table); + [, $table] = explode('.', $table); } - $columns = $schema->listTableColumns($table, $database); + $columns = $schema->listTableColumns($table); if ($columns) { foreach ($columns as $column) { @@ -309,7 +342,9 @@ protected function getPropertiesFromTable($model) if (in_array($name, $model->getDates())) { $type = $this->dateClass; } else { - $type = $column->getType()->getName(); + $columnType = $column->getType(); + // Doctrine DBAL v4 compatibility: getName() was removed, and Type cannot be cast to string + $type = $this->getDoctrineTypeName($columnType); switch ($type) { case 'string': case 'text': From e6e1ff8aa3ab990b082aafb852028d89cd0d3f73 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 18:55:41 +0800 Subject: [PATCH 03/10] fix: update ReflectionClass usage for Doctrine DBAL v4 compatibility --- src/ide-helper/src/Command/ModelCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ide-helper/src/Command/ModelCommand.php b/src/ide-helper/src/Command/ModelCommand.php index 1fc871ca8..077335336 100644 --- a/src/ide-helper/src/Command/ModelCommand.php +++ b/src/ide-helper/src/Command/ModelCommand.php @@ -323,7 +323,7 @@ protected function getPropertiesFromTable($model) // Doctrine DBAL v4 compatibility: getName() was removed from AbstractPlatform $platformName = method_exists($databasePlatform, 'getName') ? $databasePlatform->getName() - : strtolower((new \ReflectionClass($databasePlatform))->getShortName()); + : strtolower((new ReflectionClass($databasePlatform))->getShortName()); $customTypes = $this->config->get("ide-helper.model.custom_db_types.{$platformName}", []); foreach ($customTypes as $yourTypeName => $doctrineTypeName) { From e55180c0e9df71083b90d4d8c777452c83020b26 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:02:16 +0800 Subject: [PATCH 04/10] chore: add GitHub Actions workflow for component testing --- .github/workflows/test-components.yml | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/test-components.yml diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml new file mode 100644 index 000000000..ac03cea5f --- /dev/null +++ b/.github/workflows/test-components.yml @@ -0,0 +1,48 @@ +name: Test for Components + +on: + push: + paths: + - "**" + - "!docs/**" + - "!**.md" + pull_request: + paths: + - "**" + - "!docs/**" + - "!**.md" + schedule: + - cron: '0 2 * * *' +env: + SW_VERSION: 'v6.1.0' +jobs: + trigger: + name: Test for Trigger + runs-on: 'ubuntu-latest' + env: + PHP_VERSION: ${{ matrix.php-version }} + strategy: + matrix: + php-version: [ '8.4', '8.3', '8.2' ] + mysql-replication: [ '9.0', '8.0' ] + max-parallel: 2 + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: phpize + extensions: redis, pdo, pdo_mysql, bcmath, swoole + ini-values: opcache.enable_cli=1 + coverage: none + - name: Setup Packages + run: ./.travis/requirement.install.sh + - name: Run Test Cases + run: | + composer require krowinski/php-mysql-replication:^${{ matrix.mysql-replication }} --no-update + composer update -o + composer analyse + composer analyse:types From af2b6aa471548e2d77eae6bc83bfd55715a543a2 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:06:26 +0800 Subject: [PATCH 05/10] chore: update test workflow to run test cases after package setup --- .github/workflows/test-components.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml index ac03cea5f..5ed274dcf 100644 --- a/.github/workflows/test-components.yml +++ b/.github/workflows/test-components.yml @@ -39,10 +39,10 @@ jobs: ini-values: opcache.enable_cli=1 coverage: none - name: Setup Packages - run: ./.travis/requirement.install.sh - - name: Run Test Cases run: | composer require krowinski/php-mysql-replication:^${{ matrix.mysql-replication }} --no-update composer update -o + - name: Run Test Cases + run: | composer analyse composer analyse:types From 90a0b01056f4a9c28f1ddf6ce4269e505fe21f74 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:07:32 +0800 Subject: [PATCH 06/10] chore: specify source directory for composer analyse in test workflow --- .github/workflows/test-components.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml index 5ed274dcf..805d8a242 100644 --- a/.github/workflows/test-components.yml +++ b/.github/workflows/test-components.yml @@ -44,5 +44,5 @@ jobs: composer update -o - name: Run Test Cases run: | - composer analyse + composer analyse src composer analyse:types From af03f106caad49fece0688768fe2983e6374a538 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:10:49 +0800 Subject: [PATCH 07/10] chore: rename job for PHP MySQL replication in workflow --- .github/workflows/test-components.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml index 805d8a242..5dba99882 100644 --- a/.github/workflows/test-components.yml +++ b/.github/workflows/test-components.yml @@ -16,8 +16,8 @@ on: env: SW_VERSION: 'v6.1.0' jobs: - trigger: - name: Test for Trigger + php-mysql-replication: + name: Test for PHP MySQL Replication runs-on: 'ubuntu-latest' env: PHP_VERSION: ${{ matrix.php-version }} From ba42959d18399a035f8bc165ba40f553a7d0f867 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:17:51 +0800 Subject: [PATCH 08/10] chore: add serializable-closure job for PHP MySQL replication testing --- .github/workflows/test-components.yml | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml index 5dba99882..ca961734e 100644 --- a/.github/workflows/test-components.yml +++ b/.github/workflows/test-components.yml @@ -46,3 +46,33 @@ jobs: run: | composer analyse src composer analyse:types + serializable-closure: + name: Test for PHP MySQL Replication + runs-on: 'ubuntu-latest' + env: + PHP_VERSION: ${{ matrix.php-version }} + strategy: + matrix: + php-version: [ '8.4', '8.3', '8.2' ] + serializable-closure: [ '2.0', '1.0' ] + max-parallel: 2 + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: phpize + extensions: redis, pdo, pdo_mysql, bcmath, swoole + ini-values: opcache.enable_cli=1 + coverage: none + - name: Setup Packages + run: | + composer require laravel/serializable-closure:^${{ matrix.serializable-closure }} --no-update + composer update -o + - name: Run Test Cases + run: | + composer analyse src + composer analyse:types From 3b42d1aa4b756dcd479b77123e9cff81173a633b Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:20:22 +0800 Subject: [PATCH 09/10] chore: update job name for PHP Laravel Serializable Closure in workflow --- .github/workflows/test-components.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml index ca961734e..4ea285933 100644 --- a/.github/workflows/test-components.yml +++ b/.github/workflows/test-components.yml @@ -47,7 +47,7 @@ jobs: composer analyse src composer analyse:types serializable-closure: - name: Test for PHP MySQL Replication + name: Test for PHP Laravel Serializable Closure runs-on: 'ubuntu-latest' env: PHP_VERSION: ${{ matrix.php-version }} From e95487f0698108310c592e2942693d7bc78aa413 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 19:25:47 +0800 Subject: [PATCH 10/10] chore: update serializable-closure job name and increase max-parallel; add carbon job for testing --- .github/workflows/test-components.yml | 34 +++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-components.yml b/.github/workflows/test-components.yml index 4ea285933..a67b0764f 100644 --- a/.github/workflows/test-components.yml +++ b/.github/workflows/test-components.yml @@ -47,7 +47,7 @@ jobs: composer analyse src composer analyse:types serializable-closure: - name: Test for PHP Laravel Serializable Closure + name: Test for Laravel Serializable Closure runs-on: 'ubuntu-latest' env: PHP_VERSION: ${{ matrix.php-version }} @@ -55,7 +55,7 @@ jobs: matrix: php-version: [ '8.4', '8.3', '8.2' ] serializable-closure: [ '2.0', '1.0' ] - max-parallel: 2 + max-parallel: 20 fail-fast: false steps: - name: Checkout @@ -76,3 +76,33 @@ jobs: run: | composer analyse src composer analyse:types + carbon: + name: Test for Carbon + runs-on: 'ubuntu-latest' + env: + PHP_VERSION: ${{ matrix.php-version }} + strategy: + matrix: + php-version: [ '8.4', '8.3', '8.2' ] + carbon: [ '3.0', '2.0' ] + max-parallel: 20 + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: phpize + extensions: redis, pdo, pdo_mysql, bcmath, swoole + ini-values: opcache.enable_cli=1 + coverage: none + - name: Setup Packages + run: | + composer require nesbot/carbon:^${{ matrix.carbon }} --no-update + composer update -o + - name: Run Test Cases + run: | + composer analyse src + composer analyse:types