build: 移植 PHPCS + PHPStan L6 品質 gate(PR-I 前半)

- phpcs.xml(自 A 移植):ruleset 改名、*/tools/* 例外換成 */back-compat/*、
  中文註解全域排除 Squiz.Commenting.InlineComment.InvalidEndChar、
  interface 別名檔排除 OneObjectStructurePerFile
- 檔頭正規化:16 個檔案的 declare(strict_types=1) 與前導 // 註解移到
  file docblock 之後,並移除 <?php 後多餘空行(phpcbf 另自動修 190 處)
- phpstan.neon + .phpstan/stubs.php(TMDO_ 與 WPDO_ 兩套常數)+
  重新產生的 phpstan-baseline.neon(710 errors,A 的 3877 行 baseline
  因前綴與路徑不同無法沿用)

現況:PHPCS 0 errors / 0 warnings、PHPStan L6 No errors、
unit 451 / integration 398 GREEN

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
This commit is contained in:
2026-07-31 06:22:00 +08:00
parent 76c01e44df
commit f524ea3f16
23 changed files with 4356 additions and 340 deletions
+7 -6
View File
@@ -1,13 +1,14 @@
<?php
declare(strict_types=1);
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: native meta queries for management dashboard
/**
* WP Data Optimizer admin UI class.
*
* @package WP_Data_Optimizer
*/
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: native meta queries for management dashboard
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -3109,9 +3110,9 @@ wpdo.getListings({ per_page: 3 }).then(r => console.log(r));'
);
echo '</tr></thead><tbody>';
foreach ( $enable as $module => $r ) {
$conf = (float) $r['confidence'];
$bar_w = (int) round( $conf * 100 );
$color = $conf >= 0.7 ? '#46b450' : ( $conf >= 0.5 ? '#dba617' : '#c3c4c7' );
$conf = (float) $r['confidence'];
$bar_w = (int) round( $conf * 100 );
$color = $conf >= 0.7 ? '#46b450' : ( $conf >= 0.5 ? '#dba617' : '#c3c4c7' );
printf(
'<tr><td><code>%s</code></td><td><div style="background:#f0f0f1;border-radius:3px;width:80px;height:18px;position:relative;"><div style="background:%s;width:%d%%;height:100%%;border-radius:3px;"></div><span style="position:absolute;inset:0;text-align:center;font-size:11px;line-height:18px;">%s</span></div></td>',
esc_html( $module ),
+5 -4
View File
@@ -1,7 +1,4 @@
<?php
declare(strict_types=1);
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: native postmeta count for dashboard widget
/**
* TMDO_Dashboard_Widget — wp-admin home dashboard widget (v2.4.0 M9).
*
@@ -17,6 +14,10 @@ declare(strict_types=1);
* @package WP_Data_Optimizer
*/
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: native postmeta count for dashboard widget
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -60,7 +61,7 @@ class TMDO_Dashboard_Widget {
* @return void
*/
public static function render(): void {
$page_url = admin_url( 'tools.php?page=wp-data-optimizer' );
$page_url = admin_url( 'tools.php?page=wp-data-optimizer' );
$bridge_url = add_query_arg( 'tab', 'entity-bridge', $page_url );
$status = self::compute_status();
+4 -3
View File
@@ -1,7 +1,4 @@
<?php
declare(strict_types=1);
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: postmeta inventory for setup wizard
/**
* TMDO_Setup_Wizard — First-run onboarding wizard (v2.3.0 M5).
*
@@ -22,6 +19,10 @@ declare(strict_types=1);
* @package WP_Data_Optimizer
*/
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: postmeta inventory for setup wizard
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+4 -3
View File
@@ -1,7 +1,4 @@
<?php
declare(strict_types=1);
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: stress test SQL example display
/**
* Comment Stress Test template (v2.13.1).
*
@@ -18,6 +15,10 @@ declare(strict_types=1);
* @package WP_Data_Optimizer
*/
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: stress test SQL example display
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+4 -3
View File
@@ -1,7 +1,4 @@
<?php
declare(strict_types=1);
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: stress test SQL example display
/**
* Term Stress Test template (v2.13.0).
*
@@ -18,6 +15,10 @@ declare(strict_types=1);
* @package WP_Data_Optimizer
*/
// phpcs:ignore WPDO.AntiEAV -- platform admin UI: stress test SQL example display
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}