docs(ide): 添加 WooCommerce Blocks 的 IDE 存根文件用于静态分析
添加 IDE 存根文件以消除静态分析工具中的“未定义类型”警告 该文件仅用于 IDE 和代码检查,不应在运行时加载
This commit is contained in:
parent
1c50907957
commit
ca5e7a62ae
|
|
@ -42,6 +42,9 @@ 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')) {
|
||||
/**
|
||||
* 使用 use 导入基类,避免 IDE 报 Undefined type
|
||||
*/
|
||||
class Yoone_Moneris_Blocks_Payment_Method extends Automattic\WooCommerce\Blocks\Payments\PaymentMethodType {
|
||||
/**
|
||||
* Unique name of the payment method in Blocks.
|
||||
|
|
|
|||
|
|
@ -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 []; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue