docs(ide): 添加 WooCommerce Blocks 的 IDE 存根文件用于静态分析

添加 IDE 存根文件以消除静态分析工具中的“未定义类型”警告
该文件仅用于 IDE 和代码检查,不应在运行时加载
This commit is contained in:
tikkhun 2025-11-05 14:10:48 +08:00
parent 1c50907957
commit ca5e7a62ae
2 changed files with 38 additions and 1 deletions

View File

@ -42,7 +42,10 @@ function yoone_moneris_store_payment_data($order, $result, $request) {
// Only declare the Blocks payment method class when the Blocks base type exists to prevent type resolution issues.
if (class_exists('Automattic\WooCommerce\Blocks\Payments\PaymentMethodType') && ! class_exists('Yoone_Moneris_Blocks_Payment_Method')) {
class Yoone_Moneris_Blocks_Payment_Method extends Automattic\WooCommerce\Blocks\Payments\PaymentMethodType {
/**
* 使用 use 导入基类,避免 IDE Undefined type
*/
class Yoone_Moneris_Blocks_Payment_Method extends Automattic\WooCommerce\Blocks\Payments\PaymentMethodType {
/**
* Unique name of the payment method in Blocks.
* This MUST match the gateway id used by WooCommerce (yoone_moneris).

View File

@ -0,0 +1,34 @@
<?php
/**
* IDE/Linter stub for WooCommerce Blocks classes.
*
* 重要说明此文件仅用于静态分析IDE/代码检查以消除“Undefined type”告警
* 不会也不应该在 WordPress 运行时被 include/require
* 请勿在任何运行时路径中加载此文件。
*/
namespace Automattic\WooCommerce\Blocks\Payments;
// 如果真实类不存在,则为 IDE 提供一个最小的占位定义,避免类型未定义告警。
if (! class_exists(\Automattic\WooCommerce\Blocks\Payments\PaymentMethodType::class)) {
/**
* 最小占位基类:仅用于 IDE 类型解析。
* 注意:方法签名仅为常见实现提供参考,并不代表真实 Woo Blocks 行为。
*/
abstract class PaymentMethodType {
/** @return string */
abstract public function get_name();
/** @return bool */
public function is_active() { return true; }
/** @return array */
abstract public function get_payment_method_script_handles();
/** @return array */
public function get_payment_method_data() { return []; }
/** @return array */
public function get_supported_features() { return []; }
}
}