-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathphpstan-bootstrap.php
More file actions
138 lines (123 loc) Β· 3.54 KB
/
Copy pathphpstan-bootstrap.php
File metadata and controls
138 lines (123 loc) Β· 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* PHPStan bootstrap file.
*
* Defines constants that exist at runtime but are not available during
* static analysis. These are defined in wp-sudo.php (plugin constants)
* and wp-settings.php (WordPress cookie constants).
*
* @package WP_Sudo
*/
// Plugin constants (defined in wp-sudo.php at runtime).
define( 'WP_SUDO_VERSION', '4.7.0' );
define( 'WP_SUDO_PLUGIN_DIR', __DIR__ . '/' );
define( 'WP_SUDO_PLUGIN_URL', 'https://example.com/wp-content/plugins/wp-sudo/' );
define( 'WP_SUDO_PLUGIN_BASENAME', 'wp-sudo/wp-sudo.php' );
// WordPress cookie constants (defined in wp-settings.php).
if ( ! defined( 'COOKIEPATH' ) ) {
define( 'COOKIEPATH', '/' );
}
if ( ! defined( 'ADMIN_COOKIE_PATH' ) ) {
define( 'ADMIN_COOKIE_PATH', '/wp-admin' );
}
if ( ! defined( 'COOKIE_DOMAIN' ) ) {
define( 'COOKIE_DOMAIN', '' );
}
// WordPress content directory (used by Admin::get_mu_plugin_dir).
if ( ! defined( 'WP_CONTENT_DIR' ) ) {
define( 'WP_CONTENT_DIR', __DIR__ . '/wp-content' );
}
if ( ! defined( 'WPMU_PLUGIN_DIR' ) ) {
define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' );
}
// WordPress MU-plugin constant.
if ( ! defined( 'WP_SUDO_MU_LOADED' ) ) {
define( 'WP_SUDO_MU_LOADED', false );
}
// WordPress 7.0 Connectors API (runtime-only on WP 7.0+).
if ( ! function_exists( 'wp_get_connectors' ) ) {
function wp_get_connectors(): array {
return array();
}
}
// Two Factor plugin classes (optional integration β present only when the
// WordPress/two-factor plugin is active). Stubbed for static analysis so the
// provider-class `instanceof` checks and the email provider's token methods in
// Challenge resolve; runtime `class_exists()` guards remain the real gate.
if ( ! class_exists( 'Two_Factor_Provider' ) ) {
abstract class Two_Factor_Provider {
/**
* @param \WP_User $user User.
* @return void
*/
public function authentication_page( $user ) {}
/**
* @param \WP_User $user User.
* @return bool
*/
public function validate_authentication( $user ) {
return false;
}
/**
* @param \WP_User $user User.
* @return bool
*/
public function pre_process_authentication( $user ) {
return false;
}
}
}
if ( ! class_exists( 'Two_Factor_Core' ) ) {
class Two_Factor_Core {
/**
* @param int $user_id User ID.
* @return bool
*/
public static function is_user_using_two_factor( $user_id = null ) {
return false;
}
/**
* @param \WP_User $user User.
* @return Two_Factor_Provider|null
*/
public static function get_primary_provider_for_user( $user ) {
return null;
}
}
}
if ( ! class_exists( 'Two_Factor_Totp' ) ) {
class Two_Factor_Totp extends Two_Factor_Provider {}
}
if ( ! class_exists( 'Two_Factor_Email' ) ) {
class Two_Factor_Email extends Two_Factor_Provider {
/**
* @param int $user_id User ID.
* @return bool
*/
public function user_has_token( $user_id ) {
return false;
}
/**
* @param int $user_id User ID.
* @return bool
*/
public function user_token_has_expired( $user_id ) {
return false;
}
}
}
if ( ! class_exists( 'Two_Factor_Backup_Codes' ) ) {
class Two_Factor_Backup_Codes extends Two_Factor_Provider {}
}
// WP-CLI class (runtime-only in CLI context).
if ( ! class_exists( 'WP_CLI' ) ) {
class WP_CLI {
public static function add_command( string $name, $callable ): bool {
return true;
}
public static function success( string $message ): void {}
public static function warning( string $message ): void {}
public static function log( string $message ): void {}
public static function error( string $message ): void {}
}
}