|
1 | 1 | <?php |
| 2 | + |
2 | 3 | /** |
3 | 4 | * PHPStan Bootstrap File |
4 | 5 | * Defines constants and global functions for static analysis |
5 | 6 | */ |
6 | 7 |
|
7 | 8 | // Define plugin constants |
8 | | -define( 'MONEI_VERSION', '6.4.0' ); |
9 | | -define( 'MONEI_MAIN_FILE', __DIR__ . '/../monei.php' ); |
10 | | -define( 'MONEI_SIGNUP', 'https://dashboard.monei.com/signup' ); |
11 | | -define( 'MONEI_WEB', 'https://monei.com' ); |
12 | | -define( 'MONEI_SUPPORT', 'https://support.monei.com' ); |
13 | | -define( 'MONEI_REVIEW', 'https://wordpress.org/support/plugin/monei/reviews/' ); |
14 | | -define( 'MONEI_GATEWAY_ID', 'monei' ); |
| 9 | +define('MONEI_VERSION', '6.4.0'); |
| 10 | +define('MONEI_MAIN_FILE', __DIR__ . '/../monei.php'); |
| 11 | +define('MONEI_SIGNUP', 'https://dashboard.monei.com/signup'); |
| 12 | +define('MONEI_WEB', 'https://monei.com'); |
| 13 | +define('MONEI_SUPPORT', 'https://support.monei.com'); |
| 14 | +define('MONEI_REVIEW', 'https://wordpress.org/support/plugin/monei/reviews/'); |
| 15 | +define('MONEI_GATEWAY_ID', 'monei'); |
15 | 16 |
|
16 | 17 | // Define WordPress constants if not already defined |
17 | | -if ( ! defined( 'ABSPATH' ) ) { |
18 | | - define( 'ABSPATH', '/tmp/wordpress/' ); |
| 18 | +if (!defined('ABSPATH')) { |
| 19 | + define('ABSPATH', '/tmp/wordpress/'); |
19 | 20 | } |
20 | 21 |
|
21 | 22 | // Define plugin helper functions that PHPStan should know about |
22 | | -if ( ! function_exists( 'WC_Monei' ) ) { |
| 23 | +if (!function_exists('WC_Monei')) { |
23 | 24 | /** |
24 | 25 | * @return object |
25 | 26 | */ |
26 | | - function WC_Monei() { |
| 27 | + function WC_Monei() |
| 28 | + { |
27 | 29 | return new class() { |
28 | | - public function plugin_path() { |
| 30 | + public $version = MONEI_VERSION; |
| 31 | + |
| 32 | + public function plugin_path() |
| 33 | + { |
29 | 34 | return __DIR__ . '/..'; |
30 | 35 | } |
31 | | - public function image_url( $file ) { |
| 36 | + |
| 37 | + public function image_url($file) |
| 38 | + { |
32 | 39 | return 'https://example.com/' . $file; |
33 | 40 | } |
34 | | - public function get_ipn_url() { |
| 41 | + |
| 42 | + public function get_ipn_url() |
| 43 | + { |
35 | 44 | return 'https://example.com/ipn'; |
36 | 45 | } |
37 | 46 | }; |
38 | 47 | } |
39 | 48 | } |
40 | 49 |
|
41 | | -if ( ! function_exists( 'monei_price_format' ) ) { |
| 50 | +if (!function_exists('monei_price_format')) { |
42 | 51 | /** |
43 | 52 | * @param float $price |
44 | 53 | * @return int |
45 | 54 | */ |
46 | | - function monei_price_format( $price ) { |
47 | | - return (int) ( $price * 100 ); |
| 55 | + function monei_price_format($price) |
| 56 | + { |
| 57 | + return (int) ($price * 100); |
48 | 58 | } |
49 | 59 | } |
50 | 60 |
|
51 | | -if ( ! function_exists( 'locale_iso_639_1_code' ) ) { |
| 61 | +if (!function_exists('locale_iso_639_1_code')) { |
52 | 62 | /** |
53 | 63 | * @return string |
54 | 64 | */ |
55 | | - function locale_iso_639_1_code() { |
| 65 | + function locale_iso_639_1_code() |
| 66 | + { |
56 | 67 | return 'en'; |
57 | 68 | } |
58 | 69 | } |
59 | 70 |
|
60 | | -if ( ! function_exists( 'monei_get_settings' ) ) { |
| 71 | +if (!function_exists('monei_get_settings')) { |
61 | 72 | /** |
62 | 73 | * @param string $key |
63 | 74 | * @param string $gateway_id |
64 | 75 | * @return mixed |
65 | 76 | */ |
66 | | - function monei_get_settings( $key, $gateway_id = '' ) { |
| 77 | + function monei_get_settings($key, $gateway_id = '') |
| 78 | + { |
67 | 79 | return ''; |
68 | 80 | } |
69 | 81 | } |
70 | 82 |
|
71 | | -if ( ! function_exists( 'monei_get_option_key_from_order' ) ) { |
| 83 | +if (!function_exists('monei_get_option_key_from_order')) { |
72 | 84 | /** |
73 | 85 | * @param \WC_Order $order |
74 | 86 | * @return string |
75 | 87 | */ |
76 | | - function monei_get_option_key_from_order( $order ) { |
| 88 | + function monei_get_option_key_from_order($order) |
| 89 | + { |
77 | 90 | return 'monei'; |
78 | 91 | } |
79 | 92 | } |
80 | 93 |
|
81 | | -if ( ! function_exists( 'wc_clean' ) ) { |
| 94 | +if (!function_exists('wc_clean')) { |
82 | 95 | /** |
83 | 96 | * @param string|array $var |
84 | 97 | * @return string|array |
85 | 98 | */ |
86 | | - function wc_clean( $var ) { |
| 99 | + function wc_clean($var) |
| 100 | + { |
87 | 101 | return $var; |
88 | 102 | } |
89 | 103 | } |
90 | 104 |
|
91 | | -if ( ! function_exists( 'wp_unslash' ) ) { |
| 105 | +if (!function_exists('wp_unslash')) { |
92 | 106 | /** |
93 | 107 | * @param string|array $value |
94 | 108 | * @return string|array |
95 | 109 | */ |
96 | | - function wp_unslash( $value ) { |
| 110 | + function wp_unslash($value) |
| 111 | + { |
97 | 112 | return $value; |
98 | 113 | } |
99 | 114 | } |
100 | 115 |
|
101 | | -if ( ! function_exists( 'wc_price' ) ) { |
| 116 | +if (!function_exists('wc_price')) { |
102 | 117 | /** |
103 | 118 | * @param float $price |
104 | 119 | * @return string |
105 | 120 | */ |
106 | | - function wc_price( $price ) { |
107 | | - return '$' . number_format( $price, 2 ); |
| 121 | + function wc_price($price) |
| 122 | + { |
| 123 | + return '$' . number_format($price, 2); |
108 | 124 | } |
109 | 125 | } |
110 | 126 |
|
111 | | -if ( ! function_exists( 'wc_get_order' ) ) { |
| 127 | +if (!function_exists('wc_get_order')) { |
112 | 128 | /** |
113 | 129 | * @param int $order_id |
114 | 130 | * @return \WC_Order|false |
115 | 131 | */ |
116 | | - function wc_get_order( $order_id ) { |
| 132 | + function wc_get_order($order_id) |
| 133 | + { |
117 | 134 | return false; |
118 | 135 | } |
119 | 136 | } |
120 | 137 |
|
121 | | -if ( ! function_exists( 'set_transient' ) ) { |
| 138 | +if (!function_exists('set_transient')) { |
122 | 139 | /** |
123 | 140 | * @param string $transient |
124 | 141 | * @param mixed $value |
125 | 142 | * @param int $expiration |
126 | 143 | * @return bool |
127 | 144 | */ |
128 | | - function set_transient( $transient, $value, $expiration = 0 ) { |
| 145 | + function set_transient($transient, $value, $expiration = 0) |
| 146 | + { |
129 | 147 | return true; |
130 | 148 | } |
131 | 149 | } |
132 | 150 |
|
133 | | -if ( ! function_exists( 'get_transient' ) ) { |
| 151 | +if (!function_exists('get_transient')) { |
134 | 152 | /** |
135 | 153 | * @param string $transient |
136 | 154 | * @return mixed |
137 | 155 | */ |
138 | | - function get_transient( $transient ) { |
| 156 | + function get_transient($transient) |
| 157 | + { |
139 | 158 | return false; |
140 | 159 | } |
141 | 160 | } |
142 | 161 |
|
143 | | -if ( ! function_exists( 'delete_transient' ) ) { |
| 162 | +if (!function_exists('delete_transient')) { |
144 | 163 | /** |
145 | 164 | * @param string $transient |
146 | 165 | * @return bool |
147 | 166 | */ |
148 | | - function delete_transient( $transient ) { |
| 167 | + function delete_transient($transient) |
| 168 | + { |
149 | 169 | return true; |
150 | 170 | } |
151 | 171 | } |
152 | 172 |
|
153 | | -if ( ! function_exists( 'wp_rand' ) ) { |
| 173 | +if (!function_exists('wp_rand')) { |
154 | 174 | /** |
155 | 175 | * @param int $min |
156 | 176 | * @param int $max |
157 | 177 | * @return int |
158 | 178 | */ |
159 | | - function wp_rand( $min = 0, $max = 0 ) { |
160 | | - return rand( $min, $max ); |
| 179 | + function wp_rand($min = 0, $max = 0) |
| 180 | + { |
| 181 | + return rand($min, $max); |
161 | 182 | } |
162 | 183 | } |
163 | 184 |
|
164 | 185 | // Define legacy classes from includes/ directory |
165 | | -if ( ! class_exists( 'WC_Monei_IPN' ) ) { |
| 186 | +if (!class_exists('WC_Monei_IPN')) { |
166 | 187 | /** |
167 | 188 | * Mock WC_Monei_IPN class for PHPStan |
168 | 189 | * |
169 | 190 | * @param bool $logging |
170 | 191 | */ |
171 | | - class WC_Monei_IPN { |
172 | | - public function __construct( bool $logging = false ) { |
| 192 | + class WC_Monei_IPN |
| 193 | + { |
| 194 | + public function __construct(bool $logging = false) |
| 195 | + { |
173 | 196 | // Stub implementation - parameter kept for signature compatibility |
174 | | - unset( $logging ); |
| 197 | + unset($logging); |
175 | 198 | } |
176 | 199 | } |
177 | 200 | } |
178 | 201 |
|
179 | | -if ( ! class_exists( 'WC_Monei_Logger' ) ) { |
| 202 | +if (!class_exists('WC_Monei_Logger')) { |
180 | 203 | /** |
181 | 204 | * Mock WC_Monei_Logger class for PHPStan |
182 | 205 | */ |
183 | | - class WC_Monei_Logger { |
184 | | - const LEVEL_INFO = 1; |
| 206 | + class WC_Monei_Logger |
| 207 | + { |
| 208 | + const LEVEL_INFO = 1; |
185 | 209 | const LEVEL_WARNING = 2; |
186 | | - const LEVEL_ERROR = 3; |
187 | | - const LEVEL_NONE = 4; |
| 210 | + const LEVEL_ERROR = 3; |
| 211 | + const LEVEL_NONE = 4; |
188 | 212 |
|
189 | | - public static function log( $message, $severity = 1 ) {} |
190 | | - public static function logDebug( $message ) {} |
191 | | - public static function logWarning( $message ) {} |
192 | | - public static function logError( $message ) {} |
| 213 | + public static function log($message, $severity = 1) {} |
| 214 | + public static function logDebug($message) {} |
| 215 | + public static function logWarning($message) {} |
| 216 | + public static function logError($message) {} |
193 | 217 | } |
194 | 218 | } |
195 | 219 |
|
196 | | -if ( ! class_exists( 'WC_Geolocation' ) ) { |
| 220 | +if (!class_exists('WC_Geolocation')) { |
197 | 221 | /** |
198 | 222 | * Mock WC_Geolocation class for PHPStan |
199 | 223 | */ |
200 | | - class WC_Geolocation { |
| 224 | + class WC_Geolocation |
| 225 | + { |
201 | 226 | /** |
202 | 227 | * @return string |
203 | 228 | */ |
204 | | - public static function get_ip_address() { |
| 229 | + public static function get_ip_address() |
| 230 | + { |
205 | 231 | return '127.0.0.1'; |
206 | 232 | } |
207 | 233 | } |
|
0 commit comments