Completed
Branch fix-caching-loader-test (55a737)
by
unknown
23:20 queued 15:31
created
domain/entities/routing/specifications/RouteMatchSpecificationInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@
 block discarded – undo
14 14
  */
15 15
 interface RouteMatchSpecificationInterface extends InterminableInterface
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since 4.9.71.p
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute();
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since 4.9.71.p
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute();
24 24
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Payment.model.php 2 patches
Indentation   +313 added lines, -313 removed lines patch added patch discarded remove patch
@@ -12,347 +12,347 @@
 block discarded – undo
12 12
  */
13 13
 class EEM_Payment extends EEM_Base implements EEMI_Payment
14 14
 {
15
-    /**
16
-     * Status id in esp_status table that represents an approved payment
17
-     */
18
-    const status_id_approved = 'PAP';
15
+	/**
16
+	 * Status id in esp_status table that represents an approved payment
17
+	 */
18
+	const status_id_approved = 'PAP';
19 19
 
20
-    /**
21
-     * Status id in esp_status table that represents a pending payment
22
-     */
23
-    const status_id_pending = 'PPN';
20
+	/**
21
+	 * Status id in esp_status table that represents a pending payment
22
+	 */
23
+	const status_id_pending = 'PPN';
24 24
 
25
-    /**
26
-     * Status id in esp_status table that represents a cancelled payment (eg, the
27
-     * user went to PayPal, but on the paypal site decided to cancel the payment)
28
-     */
29
-    const status_id_cancelled = 'PCN';
25
+	/**
26
+	 * Status id in esp_status table that represents a cancelled payment (eg, the
27
+	 * user went to PayPal, but on the paypal site decided to cancel the payment)
28
+	 */
29
+	const status_id_cancelled = 'PCN';
30 30
 
31
-    /**
32
-     * Status id in esp_status table that represents a payment that was declined by
33
-     * the gateway. (eg, the user's card had no funds, or it was a fraudulent card)
34
-     */
35
-    const status_id_declined = 'PDC';
31
+	/**
32
+	 * Status id in esp_status table that represents a payment that was declined by
33
+	 * the gateway. (eg, the user's card had no funds, or it was a fraudulent card)
34
+	 */
35
+	const status_id_declined = 'PDC';
36 36
 
37
-    /**
38
-     * Status id in esp_status table that represents a payment that failed for technical reasons.
39
-     * (Eg, there was some error in communicating with the payment gateway.)
40
-     */
41
-    const status_id_failed = 'PFL';
37
+	/**
38
+	 * Status id in esp_status table that represents a payment that failed for technical reasons.
39
+	 * (Eg, there was some error in communicating with the payment gateway.)
40
+	 */
41
+	const status_id_failed = 'PFL';
42 42
 
43
-    /**
44
-     * @var EE_Payment
45
-     */
46
-    protected static $_instance = null;
43
+	/**
44
+	 * @var EE_Payment
45
+	 */
46
+	protected static $_instance = null;
47 47
 
48 48
 
49
-    /**
50
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
51
-     *                         (and any incoming timezone data that gets saved).
52
-     *                         Note this just sends the timezone info to the date time model field objects.
53
-     *                         Default is NULL
54
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
55
-     * @throws EE_Error
56
-     * @throws ReflectionException
57
-     */
58
-    protected function __construct($timezone)
59
-    {
60
-        $this->singular_item = esc_html__('Payment', 'event_espresso');
61
-        $this->plural_item   = esc_html__('Payments', 'event_espresso');
49
+	/**
50
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
51
+	 *                         (and any incoming timezone data that gets saved).
52
+	 *                         Note this just sends the timezone info to the date time model field objects.
53
+	 *                         Default is NULL
54
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
55
+	 * @throws EE_Error
56
+	 * @throws ReflectionException
57
+	 */
58
+	protected function __construct($timezone)
59
+	{
60
+		$this->singular_item = esc_html__('Payment', 'event_espresso');
61
+		$this->plural_item   = esc_html__('Payments', 'event_espresso');
62 62
 
63
-        $this->_tables = [
64
-            'Payment' => new EE_Primary_Table('esp_payment', 'PAY_ID'),
65
-        ];
66
-        $this->_fields = [
67
-            'Payment' => [
68
-                'PAY_ID'               => new EE_Primary_Key_Int_Field(
69
-                    'PAY_ID',
70
-                    esc_html__('Payment ID', 'event_espresso')
71
-                ),
72
-                'TXN_ID'               => new EE_Foreign_Key_Int_Field(
73
-                    'TXN_ID',
74
-                    esc_html__('Transaction ID', 'event_espresso'),
75
-                    false,
76
-                    0,
77
-                    'Transaction'
78
-                ),
79
-                'STS_ID'               => new EE_Foreign_Key_String_Field(
80
-                    'STS_ID',
81
-                    esc_html__('Status ID', 'event_espresso'),
82
-                    false,
83
-                    EEM_Payment::status_id_failed,
84
-                    'Status'
85
-                ),
86
-                'PAY_timestamp'        => new EE_Datetime_Field(
87
-                    'PAY_timestamp',
88
-                    esc_html__(
89
-                        'Timestamp of when payment was attempted',
90
-                        'event_espresso'
91
-                    ),
92
-                    false,
93
-                    EE_Datetime_Field::now,
94
-                    $timezone
95
-                ),
96
-                'PAY_source'           => new EE_All_Caps_Text_Field(
97
-                    'PAY_source',
98
-                    esc_html__(
99
-                        'User-friendly description of payment',
100
-                        'event_espresso'
101
-                    ),
102
-                    false,
103
-                    'CART'
104
-                ),
105
-                'PAY_amount'           => new EE_Money_Field(
106
-                    'PAY_amount',
107
-                    esc_html__('Amount Payment should be for', 'event_espresso'),
108
-                    false
109
-                ),
110
-                'PMD_ID'               => new EE_Foreign_Key_Int_Field(
111
-                    'PMD_ID',
112
-                    esc_html__("Payment Method ID", 'event_espresso'),
113
-                    false,
114
-                    null,
115
-                    'Payment_Method'
116
-                ),
117
-                'PAY_gateway_response' => new EE_Plain_Text_Field(
118
-                    'PAY_gateway_response',
119
-                    esc_html__(
120
-                        'Response from Gateway about the payment',
121
-                        'event_espresso'
122
-                    ),
123
-                    false,
124
-                    ''
125
-                ),
126
-                'PAY_txn_id_chq_nmbr'  => new EE_Plain_Text_Field(
127
-                    'PAY_txn_id_chq_nmbr',
128
-                    esc_html__(
129
-                        'Gateway Transaction ID or Cheque Number',
130
-                        'event_espresso'
131
-                    ),
132
-                    true,
133
-                    ''
134
-                ),
135
-                'PAY_po_number'        => new EE_Plain_Text_Field(
136
-                    'PAY_po_number',
137
-                    esc_html__(
138
-                        'Purchase or Sales Number',
139
-                        'event_espresso'
140
-                    ),
141
-                    true,
142
-                    ''
143
-                ),
144
-                'PAY_extra_accntng'    => new EE_Simple_HTML_Field(
145
-                    'PAY_extra_accntng',
146
-                    esc_html__('Extra Account Info', 'event_espresso'),
147
-                    true,
148
-                    ''
149
-                ),
150
-                'PAY_details'          => new EE_Serialized_Text_Field(
151
-                    'PAY_details',
152
-                    esc_html__(
153
-                        'Full Gateway response about payment',
154
-                        'event_espresso'
155
-                    ),
156
-                    true,
157
-                    ''
158
-                ),
159
-                'PAY_redirect_url'     => new EE_Plain_Text_Field(
160
-                    'PAY_redirect_url',
161
-                    esc_html__("Redirect URL", 'event_espresso'),
162
-                    true
163
-                ),
164
-                'PAY_redirect_args'    => new EE_Serialized_Text_Field(
165
-                    'PAY_redirect_args',
166
-                    esc_html__(
167
-                        "Key-Value POST vars to send along with redirect",
168
-                        'event_espresso'
169
-                    ),
170
-                    true
171
-                ),
172
-            ],
173
-        ];
63
+		$this->_tables = [
64
+			'Payment' => new EE_Primary_Table('esp_payment', 'PAY_ID'),
65
+		];
66
+		$this->_fields = [
67
+			'Payment' => [
68
+				'PAY_ID'               => new EE_Primary_Key_Int_Field(
69
+					'PAY_ID',
70
+					esc_html__('Payment ID', 'event_espresso')
71
+				),
72
+				'TXN_ID'               => new EE_Foreign_Key_Int_Field(
73
+					'TXN_ID',
74
+					esc_html__('Transaction ID', 'event_espresso'),
75
+					false,
76
+					0,
77
+					'Transaction'
78
+				),
79
+				'STS_ID'               => new EE_Foreign_Key_String_Field(
80
+					'STS_ID',
81
+					esc_html__('Status ID', 'event_espresso'),
82
+					false,
83
+					EEM_Payment::status_id_failed,
84
+					'Status'
85
+				),
86
+				'PAY_timestamp'        => new EE_Datetime_Field(
87
+					'PAY_timestamp',
88
+					esc_html__(
89
+						'Timestamp of when payment was attempted',
90
+						'event_espresso'
91
+					),
92
+					false,
93
+					EE_Datetime_Field::now,
94
+					$timezone
95
+				),
96
+				'PAY_source'           => new EE_All_Caps_Text_Field(
97
+					'PAY_source',
98
+					esc_html__(
99
+						'User-friendly description of payment',
100
+						'event_espresso'
101
+					),
102
+					false,
103
+					'CART'
104
+				),
105
+				'PAY_amount'           => new EE_Money_Field(
106
+					'PAY_amount',
107
+					esc_html__('Amount Payment should be for', 'event_espresso'),
108
+					false
109
+				),
110
+				'PMD_ID'               => new EE_Foreign_Key_Int_Field(
111
+					'PMD_ID',
112
+					esc_html__("Payment Method ID", 'event_espresso'),
113
+					false,
114
+					null,
115
+					'Payment_Method'
116
+				),
117
+				'PAY_gateway_response' => new EE_Plain_Text_Field(
118
+					'PAY_gateway_response',
119
+					esc_html__(
120
+						'Response from Gateway about the payment',
121
+						'event_espresso'
122
+					),
123
+					false,
124
+					''
125
+				),
126
+				'PAY_txn_id_chq_nmbr'  => new EE_Plain_Text_Field(
127
+					'PAY_txn_id_chq_nmbr',
128
+					esc_html__(
129
+						'Gateway Transaction ID or Cheque Number',
130
+						'event_espresso'
131
+					),
132
+					true,
133
+					''
134
+				),
135
+				'PAY_po_number'        => new EE_Plain_Text_Field(
136
+					'PAY_po_number',
137
+					esc_html__(
138
+						'Purchase or Sales Number',
139
+						'event_espresso'
140
+					),
141
+					true,
142
+					''
143
+				),
144
+				'PAY_extra_accntng'    => new EE_Simple_HTML_Field(
145
+					'PAY_extra_accntng',
146
+					esc_html__('Extra Account Info', 'event_espresso'),
147
+					true,
148
+					''
149
+				),
150
+				'PAY_details'          => new EE_Serialized_Text_Field(
151
+					'PAY_details',
152
+					esc_html__(
153
+						'Full Gateway response about payment',
154
+						'event_espresso'
155
+					),
156
+					true,
157
+					''
158
+				),
159
+				'PAY_redirect_url'     => new EE_Plain_Text_Field(
160
+					'PAY_redirect_url',
161
+					esc_html__("Redirect URL", 'event_espresso'),
162
+					true
163
+				),
164
+				'PAY_redirect_args'    => new EE_Serialized_Text_Field(
165
+					'PAY_redirect_args',
166
+					esc_html__(
167
+						"Key-Value POST vars to send along with redirect",
168
+						'event_espresso'
169
+					),
170
+					true
171
+				),
172
+			],
173
+		];
174 174
 
175
-        $this->_model_relations        = [
176
-            'Transaction'          => new EE_Belongs_To_Relation(),
177
-            'Status'               => new EE_Belongs_To_Relation(),
178
-            'Payment_Method'       => new EE_Belongs_To_Relation(),
179
-            'Registration_Payment' => new EE_Has_Many_Relation(),
180
-            'Registration'         => new EE_HABTM_Relation('Registration_Payment'),
181
-        ];
182
-        $this->_model_chain_to_wp_user = 'Payment_Method';
183
-        $this->_caps_slug              = 'transactions';
184
-        parent::__construct($timezone);
185
-    }
175
+		$this->_model_relations        = [
176
+			'Transaction'          => new EE_Belongs_To_Relation(),
177
+			'Status'               => new EE_Belongs_To_Relation(),
178
+			'Payment_Method'       => new EE_Belongs_To_Relation(),
179
+			'Registration_Payment' => new EE_Has_Many_Relation(),
180
+			'Registration'         => new EE_HABTM_Relation('Registration_Payment'),
181
+		];
182
+		$this->_model_chain_to_wp_user = 'Payment_Method';
183
+		$this->_caps_slug              = 'transactions';
184
+		parent::__construct($timezone);
185
+	}
186 186
 
187 187
 
188
-    /**
189
-     * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned
190
-     * to the payment. This is handy for verifying an IPN hasn't already been processed.
191
-     *
192
-     * @param string $PAY_txn_id_chq_nmbr
193
-     * @return EE_Payment|null
194
-     * @throws EE_Error
195
-     */
196
-    public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr): ?EE_Payment
197
-    {
198
-        return $this->get_one([['PAY_txn_id_chq_nmbr' => $PAY_txn_id_chq_nmbr]]);
199
-    }
188
+	/**
189
+	 * Gets the payment by the gateway server's unique ID. Eg, the unique ID PayPal assigned
190
+	 * to the payment. This is handy for verifying an IPN hasn't already been processed.
191
+	 *
192
+	 * @param string $PAY_txn_id_chq_nmbr
193
+	 * @return EE_Payment|null
194
+	 * @throws EE_Error
195
+	 */
196
+	public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr): ?EE_Payment
197
+	{
198
+		return $this->get_one([['PAY_txn_id_chq_nmbr' => $PAY_txn_id_chq_nmbr]]);
199
+	}
200 200
 
201 201
 
202
-    /**
203
-     * retrieve  all payments from db for a particular transaction, optionally with a particular status
204
-     *
205
-     * @param int         $TXN_ID
206
-     * @param string|null $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided,
207
-     *                                       gets
208
-     *                                       payments with any status
209
-     * @return EE_Payment[]
210
-     * @throws EE_Error
211
-     */
212
-    public function get_payments_for_transaction(int $TXN_ID = 0, ?string $status_of_payment = null): array
213
-    {
214
-        // all payments for a TXN ordered chronologically
215
-        $query_params = [['TXN_ID' => $TXN_ID], 'order_by' => ['PAY_timestamp' => 'ASC']];
216
-        // if provided with a status, search specifically for that status. Otherwise get them all
217
-        if ($status_of_payment) {
218
-            $query_params[0]['STS_ID'] = $status_of_payment;
219
-        }
220
-        // retrieve payments
221
-        return $this->get_all($query_params);
222
-    }
202
+	/**
203
+	 * retrieve  all payments from db for a particular transaction, optionally with a particular status
204
+	 *
205
+	 * @param int         $TXN_ID
206
+	 * @param string|null $status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided,
207
+	 *                                       gets
208
+	 *                                       payments with any status
209
+	 * @return EE_Payment[]
210
+	 * @throws EE_Error
211
+	 */
212
+	public function get_payments_for_transaction(int $TXN_ID = 0, ?string $status_of_payment = null): array
213
+	{
214
+		// all payments for a TXN ordered chronologically
215
+		$query_params = [['TXN_ID' => $TXN_ID], 'order_by' => ['PAY_timestamp' => 'ASC']];
216
+		// if provided with a status, search specifically for that status. Otherwise get them all
217
+		if ($status_of_payment) {
218
+			$query_params[0]['STS_ID'] = $status_of_payment;
219
+		}
220
+		// retrieve payments
221
+		return $this->get_all($query_params);
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * Only gets payments which have been approved
227
-     *
228
-     * @param int $TXN_ID
229
-     * @return EE_Payment[]
230
-     * @throws EE_Error
231
-     */
232
-    public function get_approved_payments_for_transaction(int $TXN_ID = 0): array
233
-    {
234
-        return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
235
-    }
225
+	/**
226
+	 * Only gets payments which have been approved
227
+	 *
228
+	 * @param int $TXN_ID
229
+	 * @return EE_Payment[]
230
+	 * @throws EE_Error
231
+	 */
232
+	public function get_approved_payments_for_transaction(int $TXN_ID = 0): array
233
+	{
234
+		return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
235
+	}
236 236
 
237 237
 
238
-    /**
239
-     * retrieve  all payments from db between two dates,
240
-     *
241
-     * @param string $start_date        incoming start date. If empty the beginning of today is used.
242
-     * @param string $end_date          incoming end date. If empty the end of today is used.
243
-     * @param string $format            If you include $start_date or $end_date then you must include the format string
244
-     *                                  for the format your date is in.
245
-     * @param string $timezone          If your range is in a different timezone then the current setting on this
246
-     *                                  WordPress install, then include it here.
247
-     * @return EE_Payment[]
248
-     * @throws EE_Error
249
-     *
250
-     */
251
-    public function get_payments_made_between_dates(
252
-        string $start_date = '',
253
-        string $end_date = '',
254
-        string $format = '',
255
-        string $timezone = ''
256
-    ): array {
257
-        $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
258
-        // if $start_date or $end date, verify $format is included.
259
-        if ((! empty($start_date) || ! empty($end_date)) && empty($format)) {
260
-            throw new EE_Error(
261
-                esc_html__(
262
-                    'You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query',
263
-                    'event_espresso'
264
-                )
265
-            );
266
-        }
267
-        $now = new DateTime('now');
268
-        // setup timezone objects once
269
-        $modelDateTimeZone  = new DateTimeZone($this->_timezone);
270
-        $passedDateTimeZone = new DateTimeZone($timezone);
271
-        // setup start date
272
-        $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
273
-        EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
274
-        $start_date = $start_date->format('Y-m-d') . ' 00:00:00';
275
-        $start_date = strtotime($start_date);
276
-        // setup end date
277
-        $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
278
-        EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
279
-        $end_date = $end_date->format('Y-m-d') . ' 23:59:59';
280
-        $end_date = strtotime($end_date);
238
+	/**
239
+	 * retrieve  all payments from db between two dates,
240
+	 *
241
+	 * @param string $start_date        incoming start date. If empty the beginning of today is used.
242
+	 * @param string $end_date          incoming end date. If empty the end of today is used.
243
+	 * @param string $format            If you include $start_date or $end_date then you must include the format string
244
+	 *                                  for the format your date is in.
245
+	 * @param string $timezone          If your range is in a different timezone then the current setting on this
246
+	 *                                  WordPress install, then include it here.
247
+	 * @return EE_Payment[]
248
+	 * @throws EE_Error
249
+	 *
250
+	 */
251
+	public function get_payments_made_between_dates(
252
+		string $start_date = '',
253
+		string $end_date = '',
254
+		string $format = '',
255
+		string $timezone = ''
256
+	): array {
257
+		$timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
258
+		// if $start_date or $end date, verify $format is included.
259
+		if ((! empty($start_date) || ! empty($end_date)) && empty($format)) {
260
+			throw new EE_Error(
261
+				esc_html__(
262
+					'You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query',
263
+					'event_espresso'
264
+				)
265
+			);
266
+		}
267
+		$now = new DateTime('now');
268
+		// setup timezone objects once
269
+		$modelDateTimeZone  = new DateTimeZone($this->_timezone);
270
+		$passedDateTimeZone = new DateTimeZone($timezone);
271
+		// setup start date
272
+		$start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
273
+		EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
274
+		$start_date = $start_date->format('Y-m-d') . ' 00:00:00';
275
+		$start_date = strtotime($start_date);
276
+		// setup end date
277
+		$end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
278
+		EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
279
+		$end_date = $end_date->format('Y-m-d') . ' 23:59:59';
280
+		$end_date = strtotime($end_date);
281 281
 
282
-        // make sure our start date is the lowest value and vice versa
283
-        $start = min($start_date, $end_date);
284
-        $end   = max($start_date, $end_date);
282
+		// make sure our start date is the lowest value and vice versa
283
+		$start = min($start_date, $end_date);
284
+		$end   = max($start_date, $end_date);
285 285
 
286
-        // yes we generated the date and time string in utc
287
-        // but we WANT this start date and time used in the set timezone on the model.
288
-        $start_date = $this->convert_datetime_for_query(
289
-            'PAY_timestamp',
290
-            date('Y-m-d', $start) . ' 00:00:00',
291
-            'Y-m-d H:i:s',
292
-            $this->get_timezone()
293
-        );
294
-        $end_date   = $this->convert_datetime_for_query(
295
-            'PAY_timestamp',
296
-            date('Y-m-d', $end) . ' 23:59:59',
297
-            'Y-m-d H:i:s',
298
-            $this->get_timezone()
299
-        );
286
+		// yes we generated the date and time string in utc
287
+		// but we WANT this start date and time used in the set timezone on the model.
288
+		$start_date = $this->convert_datetime_for_query(
289
+			'PAY_timestamp',
290
+			date('Y-m-d', $start) . ' 00:00:00',
291
+			'Y-m-d H:i:s',
292
+			$this->get_timezone()
293
+		);
294
+		$end_date   = $this->convert_datetime_for_query(
295
+			'PAY_timestamp',
296
+			date('Y-m-d', $end) . ' 23:59:59',
297
+			'Y-m-d H:i:s',
298
+			$this->get_timezone()
299
+		);
300 300
 
301
-        return $this->get_all([['PAY_timestamp' => ['>=', $start_date], 'PAY_timestamp*' => ['<=', $end_date]]]);
302
-    }
301
+		return $this->get_all([['PAY_timestamp' => ['>=', $start_date], 'PAY_timestamp*' => ['<=', $end_date]]]);
302
+	}
303 303
 
304 304
 
305
-    /**
306
-     * returns a string for the approved status
307
-     *
308
-     * @return string
309
-     */
310
-    public function approved_status(): string
311
-    {
312
-        return self::status_id_approved;
313
-    }
305
+	/**
306
+	 * returns a string for the approved status
307
+	 *
308
+	 * @return string
309
+	 */
310
+	public function approved_status(): string
311
+	{
312
+		return self::status_id_approved;
313
+	}
314 314
 
315 315
 
316
-    /**
317
-     * returns a string for the pending status
318
-     *
319
-     * @return string
320
-     */
321
-    public function pending_status(): string
322
-    {
323
-        return self::status_id_pending;
324
-    }
316
+	/**
317
+	 * returns a string for the pending status
318
+	 *
319
+	 * @return string
320
+	 */
321
+	public function pending_status(): string
322
+	{
323
+		return self::status_id_pending;
324
+	}
325 325
 
326 326
 
327
-    /**
328
-     * returns a string for the cancelled status
329
-     *
330
-     * @return string
331
-     */
332
-    public function cancelled_status(): string
333
-    {
334
-        return self::status_id_cancelled;
335
-    }
327
+	/**
328
+	 * returns a string for the cancelled status
329
+	 *
330
+	 * @return string
331
+	 */
332
+	public function cancelled_status(): string
333
+	{
334
+		return self::status_id_cancelled;
335
+	}
336 336
 
337 337
 
338
-    /**
339
-     * returns a string for the failed status
340
-     *
341
-     * @return string
342
-     */
343
-    public function failed_status(): string
344
-    {
345
-        return self::status_id_failed;
346
-    }
338
+	/**
339
+	 * returns a string for the failed status
340
+	 *
341
+	 * @return string
342
+	 */
343
+	public function failed_status(): string
344
+	{
345
+		return self::status_id_failed;
346
+	}
347 347
 
348 348
 
349
-    /**
350
-     * returns a string for the declined status
351
-     *
352
-     * @return string
353
-     */
354
-    public function declined_status(): string
355
-    {
356
-        return self::status_id_declined;
357
-    }
349
+	/**
350
+	 * returns a string for the declined status
351
+	 *
352
+	 * @return string
353
+	 */
354
+	public function declined_status(): string
355
+	{
356
+		return self::status_id_declined;
357
+	}
358 358
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             ],
173 173
         ];
174 174
 
175
-        $this->_model_relations        = [
175
+        $this->_model_relations = [
176 176
             'Transaction'          => new EE_Belongs_To_Relation(),
177 177
             'Status'               => new EE_Belongs_To_Relation(),
178 178
             'Payment_Method'       => new EE_Belongs_To_Relation(),
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     ): array {
257 257
         $timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
258 258
         // if $start_date or $end date, verify $format is included.
259
-        if ((! empty($start_date) || ! empty($end_date)) && empty($format)) {
259
+        if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) {
260 260
             throw new EE_Error(
261 261
                 esc_html__(
262 262
                     'You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query',
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
         // setup start date
272 272
         $start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
273 273
         EEH_DTT_Helper::setTimezone($start_date, $modelDateTimeZone);
274
-        $start_date = $start_date->format('Y-m-d') . ' 00:00:00';
274
+        $start_date = $start_date->format('Y-m-d').' 00:00:00';
275 275
         $start_date = strtotime($start_date);
276 276
         // setup end date
277 277
         $end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
278 278
         EEH_DTT_Helper::setTimezone($end_date, $modelDateTimeZone);
279
-        $end_date = $end_date->format('Y-m-d') . ' 23:59:59';
279
+        $end_date = $end_date->format('Y-m-d').' 23:59:59';
280 280
         $end_date = strtotime($end_date);
281 281
 
282 282
         // make sure our start date is the lowest value and vice versa
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
         // but we WANT this start date and time used in the set timezone on the model.
288 288
         $start_date = $this->convert_datetime_for_query(
289 289
             'PAY_timestamp',
290
-            date('Y-m-d', $start) . ' 00:00:00',
290
+            date('Y-m-d', $start).' 00:00:00',
291 291
             'Y-m-d H:i:s',
292 292
             $this->get_timezone()
293 293
         );
294
-        $end_date   = $this->convert_datetime_for_query(
294
+        $end_date = $this->convert_datetime_for_query(
295 295
             'PAY_timestamp',
296
-            date('Y-m-d', $end) . ' 23:59:59',
296
+            date('Y-m-d', $end).' 23:59:59',
297 297
             'Y-m-d H:i:s',
298 298
             $this->get_timezone()
299 299
         );
Please login to merge, or discard this patch.
core/EE_Registry.core.php 2 patches
Indentation   +1746 added lines, -1746 removed lines patch added patch discarded remove patch
@@ -22,1750 +22,1750 @@
 block discarded – undo
22 22
  */
23 23
 class EE_Registry implements ResettableInterface
24 24
 {
25
-    /**
26
-     * @var EE_Registry $_instance
27
-     */
28
-    private static $_instance;
29
-
30
-    /**
31
-     * @var EE_Dependency_Map $_dependency_map
32
-     */
33
-    protected $_dependency_map;
34
-
35
-    /**
36
-     * @var Mirror
37
-     */
38
-    private $mirror;
39
-
40
-    /**
41
-     * @var ClassInterfaceCache $class_cache
42
-     */
43
-    private $class_cache;
44
-
45
-    /**
46
-     * @var array $_class_abbreviations
47
-     */
48
-    protected $_class_abbreviations = [];
49
-
50
-    /**
51
-     * @var CommandBusInterface $BUS
52
-     */
53
-    public $BUS;
54
-
55
-    /**
56
-     * @var EE_Cart $CART
57
-     */
58
-    public $CART;
59
-
60
-    /**
61
-     * @var EE_Config $CFG
62
-     */
63
-    public $CFG;
64
-
65
-    /**
66
-     * @var EE_Network_Config $NET_CFG
67
-     */
68
-    public $NET_CFG;
69
-
70
-    /**
71
-     * RegistryContainer for storing library classes in
72
-     *
73
-     * @var RegistryContainer $LIB
74
-     */
75
-    public $LIB;
76
-
77
-    /**
78
-     * @var EE_Request_Handler $REQ
79
-     * @deprecated 4.10.14.p
80
-     */
81
-    public $REQ;
82
-
83
-    /**
84
-     * @var EE_Session $SSN
85
-     */
86
-    public $SSN;
87
-
88
-    /**
89
-     * @since 4.5.0
90
-     * @var EE_Capabilities $CAP
91
-     */
92
-    public $CAP;
93
-
94
-    /**
95
-     * @since 4.9.0
96
-     * @var EE_Message_Resource_Manager $MRM
97
-     */
98
-    public $MRM;
99
-
100
-    /**
101
-     * @var Registry $AssetsRegistry
102
-     */
103
-    public $AssetsRegistry;
104
-
105
-    /**
106
-     * RegistryContainer for holding addons which have registered themselves to work with EE core
107
-     *
108
-     * @var RegistryContainer|EE_Addon[] $addons
109
-     */
110
-    public $addons;
111
-
112
-    /**
113
-     * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
114
-     *
115
-     * @var EEM_Base[] $models
116
-     */
117
-    public $models = [];
118
-
119
-    /**
120
-     * @var RegistryContainer|EED_Module[] $modules
121
-     */
122
-    public $modules;
123
-
124
-    /**
125
-     * @var RegistryContainer|EES_Shortcode[] $shortcodes
126
-     */
127
-    public $shortcodes;
128
-
129
-    /**
130
-     * @var RegistryContainer|WP_Widget[] $widgets
131
-     */
132
-    public $widgets;
133
-
134
-    /**
135
-     * this is an array of all implemented model names (i.e. not the parent abstract models, or models
136
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
137
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
138
-     * classnames (eg "EEM_Event")
139
-     *
140
-     * @var array $non_abstract_db_models
141
-     */
142
-    public $non_abstract_db_models = [];
143
-
144
-    /**
145
-     * internationalization for JS strings
146
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
147
-     *    in js file:  var translatedString = eei18n.string_key;
148
-     *
149
-     * @var array $i18n_js_strings
150
-     */
151
-    public static $i18n_js_strings = [];
152
-
153
-    /**
154
-     * $main_file - path to espresso.php
155
-     *
156
-     * @var array $main_file
157
-     */
158
-    public $main_file;
159
-
160
-    /**
161
-     * array of ReflectionClass objects where the key is the class name
162
-     *
163
-     * @deprecated 4.9.62.p
164
-     * @var ReflectionClass[] $_reflectors
165
-     */
166
-    public $_reflectors;
167
-
168
-    /**
169
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
170
-     *
171
-     * @var boolean $_cache_on
172
-     */
173
-    protected $_cache_on = true;
174
-
175
-    /**
176
-     * @var ObjectIdentifier
177
-     */
178
-    private $object_identifier;
179
-
180
-
181
-    /**
182
-     * @singleton method used to instantiate class object
183
-     * @param EE_Dependency_Map|null   $dependency_map
184
-     * @param Mirror|null              $mirror
185
-     * @param ClassInterfaceCache|null $class_cache
186
-     * @param ObjectIdentifier|null    $object_identifier
187
-     * @return EE_Registry instance
188
-     */
189
-    public static function instance(
190
-        EE_Dependency_Map $dependency_map = null,
191
-        Mirror $mirror = null,
192
-        ClassInterfaceCache $class_cache = null,
193
-        ObjectIdentifier $object_identifier = null
194
-    ): EE_Registry {
195
-        // check if class object is instantiated
196
-        if (
197
-            ! self::$_instance instanceof EE_Registry
198
-            && $dependency_map instanceof EE_Dependency_Map
199
-            && $mirror instanceof Mirror
200
-            && $class_cache instanceof ClassInterfaceCache
201
-            && $object_identifier instanceof ObjectIdentifier
202
-        ) {
203
-            self::$_instance = new self(
204
-                $dependency_map,
205
-                $mirror,
206
-                $class_cache,
207
-                $object_identifier
208
-            );
209
-        }
210
-        return self::$_instance;
211
-    }
212
-
213
-
214
-    /**
215
-     * protected constructor to prevent direct creation
216
-     *
217
-     * @Constructor
218
-     * @param EE_Dependency_Map   $dependency_map
219
-     * @param Mirror              $mirror
220
-     * @param ClassInterfaceCache $class_cache
221
-     * @param ObjectIdentifier    $object_identifier
222
-     */
223
-    protected function __construct(
224
-        EE_Dependency_Map $dependency_map,
225
-        Mirror $mirror,
226
-        ClassInterfaceCache $class_cache,
227
-        ObjectIdentifier $object_identifier
228
-    ) {
229
-        $this->_dependency_map   = $dependency_map;
230
-        $this->mirror            = $mirror;
231
-        $this->class_cache       = $class_cache;
232
-        $this->object_identifier = $object_identifier;
233
-        // $registry_container = new RegistryContainer();
234
-        $this->LIB        = new RegistryContainer();
235
-        $this->addons     = new RegistryContainer();
236
-        $this->modules    = new RegistryContainer();
237
-        $this->shortcodes = new RegistryContainer();
238
-        $this->widgets    = new RegistryContainer();
239
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', [$this, 'initialize']);
240
-    }
241
-
242
-
243
-    /**
244
-     * initialize
245
-     *
246
-     * @throws OutOfBoundsException
247
-     * @throws InvalidArgumentException
248
-     * @throws InvalidInterfaceException
249
-     * @throws InvalidDataTypeException
250
-     * @throws EE_Error
251
-     * @throws ReflectionException
252
-     */
253
-    public function initialize()
254
-    {
255
-        $this->_class_abbreviations = apply_filters(
256
-            'FHEE__EE_Registry____construct___class_abbreviations',
257
-            [
258
-                'EE_Config'                                       => 'CFG',
259
-                'EE_Session'                                      => 'SSN',
260
-                'EE_Capabilities'                                 => 'CAP',
261
-                'EE_Cart'                                         => 'CART',
262
-                'EE_Network_Config'                               => 'NET_CFG',
263
-                'EE_Request_Handler'                              => 'REQ',
264
-                'EE_Message_Resource_Manager'                     => 'MRM',
265
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
266
-                'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
267
-            ]
268
-        );
269
-        $this->load_core('Base', [], true);
270
-        // add our request and response objects to the cache
271
-        $request_loader = $this->_dependency_map->class_loader(
272
-            'EventEspresso\core\services\request\Request'
273
-        );
274
-        $this->_set_cached_class(
275
-            $request_loader(),
276
-            'EventEspresso\core\services\request\Request'
277
-        );
278
-        $response_loader = $this->_dependency_map->class_loader(
279
-            'EventEspresso\core\services\request\Response'
280
-        );
281
-        $this->_set_cached_class(
282
-            $response_loader(),
283
-            'EventEspresso\core\services\request\Response'
284
-        );
285
-        add_action('AHEE__EE_System__set_hooks_for_core', [$this, 'init']);
286
-    }
287
-
288
-
289
-    /**
290
-     * @return void
291
-     */
292
-    public function init()
293
-    {
294
-        // Get current page protocol
295
-        $protocol = is_ssl() ? 'https://' : 'http://';
296
-        // Output admin-ajax.php URL with same protocol as current page
297
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
298
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') && WP_DEBUG;
299
-    }
300
-
301
-
302
-    /**
303
-     * @return array
304
-     */
305
-    public static function sanitize_i18n_js_strings(): array
306
-    {
307
-        $i18n_js_strings = (array) self::$i18n_js_strings;
308
-        foreach ($i18n_js_strings as $key => $value) {
309
-            if (is_scalar($value)) {
310
-                $decoded_value           = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
311
-                $i18n_js_strings[ $key ] = wp_strip_all_tags($decoded_value);
312
-            }
313
-        }
314
-        return $i18n_js_strings;
315
-    }
316
-
317
-
318
-    /**
319
-     * localize_i18n_js_strings
320
-     *
321
-     * @return string
322
-     */
323
-    public static function localize_i18n_js_strings(): string
324
-    {
325
-        $i18n_js_strings = EE_Registry::sanitize_i18n_js_strings();
326
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
327
-    }
328
-
329
-
330
-    /**
331
-     * @param mixed string | EED_Module $module
332
-     * @throws OutOfBoundsException
333
-     * @throws InvalidArgumentException
334
-     * @throws InvalidInterfaceException
335
-     * @throws InvalidDataTypeException
336
-     * @throws EE_Error
337
-     * @throws ReflectionException
338
-     */
339
-    public function add_module($module)
340
-    {
341
-        if ($module instanceof EED_Module) {
342
-            $module_class = get_class($module);
343
-            $this->modules->add($module_class, $module);
344
-        } else {
345
-            if (! class_exists('EE_Module_Request_Router', false)) {
346
-                $this->load_core('Module_Request_Router');
347
-            }
348
-            EE_Module_Request_Router::module_factory($module);
349
-        }
350
-    }
351
-
352
-
353
-    /**
354
-     * @param string $module_name
355
-     * @return mixed EED_Module | NULL
356
-     */
357
-    public function get_module(string $module_name = '')
358
-    {
359
-        return $this->modules->get($module_name);
360
-    }
361
-
362
-
363
-    /**
364
-     * loads core classes - must be singletons
365
-     *
366
-     * @param string $class_name - simple class name ie: session
367
-     * @param mixed  $arguments
368
-     * @param bool   $load_only
369
-     * @return bool|null|object
370
-     * @throws InvalidInterfaceException
371
-     * @throws InvalidDataTypeException
372
-     * @throws EE_Error
373
-     * @throws ReflectionException
374
-     * @throws InvalidArgumentException
375
-     */
376
-    public function load_core(string $class_name, $arguments = [], bool $load_only = false)
377
-    {
378
-        $core_paths = (array) apply_filters(
379
-            'FHEE__EE_Registry__load_core__core_paths',
380
-            [
381
-                EE_CORE,
382
-                EE_ADMIN,
383
-                EE_CPTS,
384
-                EE_CORE . 'CPTs/',
385
-                EE_CORE . 'data_migration_scripts/',
386
-                EE_CORE . 'request_stack/',
387
-                EE_CORE . 'middleware/',
388
-            ]
389
-        );
390
-        // retrieve instantiated class
391
-        return $this->_load(
392
-            $core_paths,
393
-            'EE_',
394
-            $class_name,
395
-            'core',
396
-            $arguments,
397
-            false,
398
-            true,
399
-            $load_only
400
-        );
401
-    }
402
-
403
-
404
-    /**
405
-     * loads service classes
406
-     *
407
-     * @param string $class_name - simple class name ie: session
408
-     * @param mixed  $arguments
409
-     * @param bool   $load_only
410
-     * @return bool|null|object
411
-     * @throws InvalidInterfaceException
412
-     * @throws InvalidDataTypeException
413
-     * @throws EE_Error
414
-     * @throws ReflectionException
415
-     * @throws InvalidArgumentException
416
-     * @deprecated  4.10.33.p
417
-     */
418
-    public function load_service(string $class_name, $arguments = [], bool $load_only = false)
419
-    {
420
-        $service_paths = (array) apply_filters(
421
-            'FHEE__EE_Registry__load_service__service_paths',
422
-            [
423
-                EE_CORE . 'services/',
424
-            ]
425
-        );
426
-        // retrieve instantiated class
427
-        return $this->_load(
428
-            $service_paths,
429
-            'EE_',
430
-            $class_name,
431
-            'class',
432
-            $arguments,
433
-            false,
434
-            true,
435
-            $load_only
436
-        );
437
-    }
438
-
439
-
440
-    /**
441
-     * loads data_migration_scripts
442
-     *
443
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
444
-     * @param mixed  $arguments
445
-     * @return bool|null|object
446
-     * @throws InvalidInterfaceException
447
-     * @throws InvalidDataTypeException
448
-     * @throws EE_Error
449
-     * @throws ReflectionException
450
-     * @throws InvalidArgumentException
451
-     */
452
-    public function load_dms(string $class_name, $arguments = [])
453
-    {
454
-        // retrieve instantiated class
455
-        return $this->_load(
456
-            EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
457
-            'EE_DMS_',
458
-            $class_name,
459
-            'dms',
460
-            $arguments,
461
-            false,
462
-            false
463
-        );
464
-    }
465
-
466
-
467
-    /**
468
-     * loads object creating classes - must be singletons
469
-     *
470
-     * @param string $class_name - simple class name ie: attendee
471
-     * @param mixed  $arguments  - an array of arguments to pass to the class
472
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
473
-     *                           instantiate
474
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
475
-     *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
476
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
477
-     *                           (default)
478
-     * @return bool|null|object
479
-     * @throws InvalidInterfaceException
480
-     * @throws InvalidDataTypeException
481
-     * @throws EE_Error
482
-     * @throws ReflectionException
483
-     * @throws InvalidArgumentException
484
-     */
485
-    public function load_class(
486
-        string $class_name,
487
-        $arguments = [],
488
-        bool $from_db = false,
489
-        bool $cache = true,
490
-        bool $load_only = false
491
-    ) {
492
-        $paths = (array) apply_filters(
493
-            'FHEE__EE_Registry__load_class__paths',
494
-            [
495
-                EE_CORE,
496
-                EE_CLASSES,
497
-                EE_BUSINESS,
498
-            ]
499
-        );
500
-        // retrieve instantiated class
501
-        return $this->_load(
502
-            $paths,
503
-            'EE_',
504
-            $class_name,
505
-            'class',
506
-            $arguments,
507
-            $from_db,
508
-            $cache,
509
-            $load_only
510
-        );
511
-    }
512
-
513
-
514
-    /**
515
-     * loads helper classes - must be singletons
516
-     *
517
-     * @param string $class_name - simple class name ie: price
518
-     * @param mixed  $arguments
519
-     * @param bool   $load_only
520
-     * @return bool|null|object
521
-     * @throws InvalidInterfaceException
522
-     * @throws InvalidDataTypeException
523
-     * @throws EE_Error
524
-     * @throws ReflectionException
525
-     * @throws InvalidArgumentException
526
-     */
527
-    public function load_helper(string $class_name, $arguments = [], bool $load_only = true)
528
-    {
529
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
530
-        $helper_paths = (array) apply_filters('FHEE__EE_Registry__load_helper__helper_paths', [EE_HELPERS]);
531
-        // retrieve instantiated class
532
-        return $this->_load(
533
-            $helper_paths,
534
-            'EEH_',
535
-            $class_name,
536
-            'helper',
537
-            $arguments,
538
-            false,
539
-            true,
540
-            $load_only
541
-        );
542
-    }
543
-
544
-
545
-    /**
546
-     * loads core classes - must be singletons
547
-     *
548
-     * @param string $class_name - simple class name ie: session
549
-     * @param mixed  $arguments
550
-     * @param bool   $load_only
551
-     * @param bool   $cache      whether to cache the object or not.
552
-     * @return bool|null|object
553
-     * @throws InvalidInterfaceException
554
-     * @throws InvalidDataTypeException
555
-     * @throws EE_Error
556
-     * @throws ReflectionException
557
-     * @throws InvalidArgumentException
558
-     */
559
-    public function load_lib(string $class_name, $arguments = [], bool $load_only = false, bool $cache = true)
560
-    {
561
-        $paths = [
562
-            EE_LIBRARIES,
563
-            EE_LIBRARIES . 'messages/',
564
-            EE_LIBRARIES . 'shortcodes/',
565
-            EE_LIBRARIES . 'qtips/',
566
-            EE_LIBRARIES . 'payment_methods/',
567
-        ];
568
-        // retrieve instantiated class
569
-        return $this->_load(
570
-            $paths,
571
-            'EE_',
572
-            $class_name,
573
-            'lib',
574
-            $arguments,
575
-            false,
576
-            $cache,
577
-            $load_only
578
-        );
579
-    }
580
-
581
-
582
-    /**
583
-     * loads model classes - must be singletons
584
-     *
585
-     * @param string $class_name - simple class name ie: price
586
-     * @param mixed  $arguments
587
-     * @param bool   $load_only
588
-     * @return bool|null|object
589
-     * @throws InvalidInterfaceException
590
-     * @throws InvalidDataTypeException
591
-     * @throws EE_Error
592
-     * @throws ReflectionException
593
-     * @throws InvalidArgumentException
594
-     */
595
-    public function load_model(string $class_name, $arguments = [], bool $load_only = false)
596
-    {
597
-        $paths = (array) apply_filters(
598
-            'FHEE__EE_Registry__load_model__paths',
599
-            [
600
-                EE_MODELS,
601
-                EE_CORE,
602
-            ]
603
-        );
604
-        // retrieve instantiated class
605
-        return $this->_load(
606
-            $paths,
607
-            'EEM_',
608
-            $class_name,
609
-            'model',
610
-            $arguments,
611
-            false,
612
-            true,
613
-            $load_only
614
-        );
615
-    }
616
-
617
-
618
-    /**
619
-     * loads model classes - must be singletons
620
-     *
621
-     * @param string $class_name - simple class name ie: price
622
-     * @param mixed  $arguments
623
-     * @param bool   $load_only
624
-     * @return bool|null|object
625
-     * @throws InvalidInterfaceException
626
-     * @throws InvalidDataTypeException
627
-     * @throws EE_Error
628
-     * @throws ReflectionException
629
-     * @throws InvalidArgumentException
630
-     * @deprecated  4.10.33.p
631
-     */
632
-    public function load_model_class(string $class_name, $arguments = [], bool $load_only = true)
633
-    {
634
-        $paths = [
635
-            EE_MODELS . 'fields/',
636
-            EE_MODELS . 'helpers/',
637
-            EE_MODELS . 'relations/',
638
-            EE_MODELS . 'strategies/',
639
-        ];
640
-        // retrieve instantiated class
641
-        return $this->_load(
642
-            $paths,
643
-            'EE_',
644
-            $class_name,
645
-            '',
646
-            $arguments,
647
-            false,
648
-            true,
649
-            $load_only
650
-        );
651
-    }
652
-
653
-
654
-    /**
655
-     * Determines if $model_name is the name of an actual EE model.
656
-     *
657
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
658
-     * @return boolean
659
-     */
660
-    public function is_model_name(string $model_name): bool
661
-    {
662
-        return isset($this->models[ $model_name ]);
663
-    }
664
-
665
-
666
-    /**
667
-     * generic class loader
668
-     *
669
-     * @param string $path_to_file - directory path to file location, not including filename
670
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
671
-     * @param string $type         - file type - core? class? helper? model?
672
-     * @param mixed  $arguments
673
-     * @param bool   $load_only
674
-     * @return bool|null|object
675
-     * @throws InvalidInterfaceException
676
-     * @throws InvalidDataTypeException
677
-     * @throws EE_Error
678
-     * @throws ReflectionException
679
-     * @throws InvalidArgumentException
680
-     */
681
-    public function load_file(
682
-        string $path_to_file,
683
-        string $file_name,
684
-        string $type = '',
685
-        $arguments = [],
686
-        bool $load_only = true
687
-    ) {
688
-        // retrieve instantiated class
689
-        return $this->_load(
690
-            (array) $path_to_file,
691
-            '',
692
-            $file_name,
693
-            $type,
694
-            $arguments,
695
-            false,
696
-            true,
697
-            $load_only
698
-        );
699
-    }
700
-
701
-
702
-    /**
703
-     * @param string $path_to_file - directory path to file location, not including filename
704
-     * @param string $class_name   - full class name  ie:  My_Class
705
-     * @param string $type         - file type - core? class? helper? model?
706
-     * @param mixed  $arguments
707
-     * @param bool   $load_only
708
-     * @return bool|null|object
709
-     * @throws InvalidInterfaceException
710
-     * @throws InvalidDataTypeException
711
-     * @throws EE_Error
712
-     * @throws ReflectionException
713
-     * @throws InvalidArgumentException
714
-     * @deprecated  4.10.33.p
715
-     */
716
-    public function load_addon(
717
-        string $path_to_file,
718
-        string $class_name,
719
-        string $type = 'class',
720
-        $arguments = [],
721
-        bool $load_only = false
722
-    ) {
723
-        // retrieve instantiated class
724
-        return $this->_load(
725
-            (array) $path_to_file,
726
-            'addon',
727
-            $class_name,
728
-            $type,
729
-            $arguments,
730
-            false,
731
-            true,
732
-            $load_only
733
-        );
734
-    }
735
-
736
-
737
-    /**
738
-     * instantiates, caches, and automatically resolves dependencies
739
-     * for classes that use a Fully Qualified Class Name.
740
-     * if the class is not capable of being loaded using PSR-4 autoloading,
741
-     * then you need to use one of the existing load_*() methods
742
-     * which can resolve the classname and filepath from the passed arguments
743
-     *
744
-     * @param string      $class_name Fully Qualified Class Name
745
-     * @param array       $arguments  an argument, or array of arguments to pass to the class upon instantiation
746
-     * @param bool        $cache      whether to cache the instantiated object for reuse
747
-     * @param bool        $from_db    some classes are instantiated from the db
748
-     *                                and thus call a different method to instantiate
749
-     * @param bool        $load_only  if true, will only load the file, but will NOT instantiate an object
750
-     * @param bool|string $addon      if true, will cache the object in the EE_Registry->$addons array
751
-     * @return bool|null|mixed     null = failure to load or instantiate class object.
752
-     *                                object = class loaded and instantiated successfully.
753
-     *                                bool = fail or success when $load_only is true
754
-     * @throws InvalidInterfaceException
755
-     * @throws InvalidDataTypeException
756
-     * @throws EE_Error
757
-     * @throws ReflectionException
758
-     * @throws InvalidArgumentException
759
-     */
760
-    public function create(
761
-        string $class_name = '',
762
-        array $arguments = [],
763
-        bool $cache = false,
764
-        bool $from_db = false,
765
-        bool $load_only = false,
766
-        bool $addon = false
767
-    ) {
768
-        $class_name   = ltrim($class_name, '\\');
769
-        $class_name   = $this->class_cache->getFqnForAlias($class_name);
770
-        $class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
771
-        // if a non-FQCN was passed, then
772
-        // verifyClassExists() might return an object
773
-        // or it could return null if the class just could not be found anywhere
774
-        if ($class_exists instanceof $class_name || $class_exists === null) {
775
-            // either way, return the results
776
-            return $class_exists;
777
-        }
778
-        $class_name = $class_exists;
779
-        // if we're only loading the class and it already exists, then let's just return true immediately
780
-        if ($load_only) {
781
-            return true;
782
-        }
783
-        $addon = $addon ? 'addon' : '';
784
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
785
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
786
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
787
-        if ($this->_cache_on && $cache) {
788
-            // return object if it's already cached
789
-            $cached_class = $this->_get_cached_class($class_name, $addon, $arguments);
790
-            if ($cached_class !== null) {
791
-                return $cached_class;
792
-            }
793
-        }                                                           // obtain the loader method from the dependency map
794
-        $loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
795
-        if ($loader instanceof Closure) {
796
-            $class_obj = $loader($arguments);
797
-        } else {
798
-            if ($loader && method_exists($this, $loader)) {
799
-                $class_obj = $this->{$loader}($class_name, $arguments);
800
-            } else {
801
-                $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
802
-            }
803
-        }
804
-        if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
805
-            // save it for later... kinda like gum  { : $
806
-            $this->_set_cached_class(
807
-                $class_obj,
808
-                $class_name,
809
-                $addon,
810
-                $from_db,
811
-                $arguments
812
-            );
813
-        }
814
-        $this->_cache_on = true;
815
-        return $class_obj;
816
-    }
817
-
818
-
819
-    /**
820
-     * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
821
-     *
822
-     * @param string|mixed $class_name
823
-     * @param array        $arguments
824
-     * @param int          $attempt
825
-     * @return mixed
826
-     */
827
-    private function loadOrVerifyClassExists($class_name, array $arguments, int $attempt = 1)
828
-    {
829
-        if (is_object($class_name) || class_exists($class_name)) {
830
-            return $class_name;
831
-        }
832
-        switch ($attempt) {
833
-            case 1:
834
-                // if it's a FQCN then maybe the class is registered with a preceding \
835
-                $class_name = strpos($class_name, '\\') !== false
836
-                    ? '\\' . ltrim($class_name, '\\')
837
-                    : $class_name;
838
-                break;
839
-            case 2:
840
-                //
841
-                $loader = $this->_dependency_map->class_loader($class_name);
842
-                if ($loader && method_exists($this, $loader)) {
843
-                    return $this->{$loader}($class_name, $arguments);
844
-                }
845
-                break;
846
-            case 3:
847
-            default:
848
-                return null;
849
-        }
850
-        $attempt++;
851
-        return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
852
-    }
853
-
854
-
855
-    /**
856
-     * instantiates, caches, and injects dependencies for classes
857
-     *
858
-     * @param array  $file_paths         an array of paths to folders to look in
859
-     * @param string $class_prefix       EE  or EEM or... ???
860
-     * @param string $class_name         $class name
861
-     * @param string $type               file type - core? class? helper? model?
862
-     * @param mixed  $arguments          an argument or array of arguments to pass to the class upon instantiation
863
-     * @param bool   $from_db            some classes are instantiated from the db
864
-     *                                   and thus call a different method to instantiate
865
-     * @param bool   $cache              whether to cache the instantiated object for reuse
866
-     * @param bool   $load_only          if true, will only load the file, but will NOT instantiate an object
867
-     * @return bool|null|object          null   = failure to load or instantiate class object.
868
-     *                                   object = class loaded and instantiated successfully.
869
-     *                                   bool   = fail or success when $load_only is true
870
-     * @throws EE_Error
871
-     * @throws ReflectionException
872
-     * @throws InvalidInterfaceException
873
-     * @throws InvalidDataTypeException
874
-     * @throws InvalidArgumentException
875
-     */
876
-    protected function _load(
877
-        array $file_paths = [],
878
-        string $class_prefix = 'EE_',
879
-        string $class_name = '',
880
-        string $type = 'class',
881
-        array $arguments = [],
882
-        bool $from_db = false,
883
-        bool $cache = true,
884
-        bool $load_only = false
885
-    ) {
886
-        $class_name = ltrim($class_name, '\\');
887
-        // strip php file extension
888
-        $class_name = str_replace('.php', '', trim($class_name));
889
-        // does the class have a prefix ?
890
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
891
-            // make sure $class_prefix is uppercase
892
-            $class_prefix = strtoupper(trim($class_prefix));
893
-            // add class prefix ONCE!!!
894
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
895
-        }
896
-        $class_name   = $this->class_cache->getFqnForAlias($class_name);
897
-        $class_exists = class_exists($class_name, false);
898
-        // if we're only loading the class and it already exists, then let's just return true immediately
899
-        if ($load_only && $class_exists) {
900
-            return true;
901
-        }
902
-        $arguments = is_array($arguments) ? $arguments : [$arguments];
903
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
904
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
905
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
906
-        if ($this->_cache_on && $cache && ! $load_only) {
907
-            // return object if it's already cached
908
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix, $arguments);
909
-            if ($cached_class !== null) {
910
-                return $cached_class;
911
-            }
912
-        }
913
-        // if the class doesn't already exist.. then we need to try and find the file and load it
914
-        if (! $class_exists) {
915
-            // get full path to file
916
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
917
-            // load the file
918
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
919
-            // if we are only loading a file but NOT instantiating an object
920
-            // then return boolean for whether class was loaded or not
921
-            if ($load_only) {
922
-                return $loaded;
923
-            }
924
-            // if an object was expected but loading failed, then return nothing
925
-            if (! $loaded) {
926
-                return null;
927
-            }
928
-        }
929
-        // instantiate the requested object
930
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
931
-        if ($this->_cache_on && $cache) {
932
-            // save it for later... kinda like gum  { : $
933
-            $this->_set_cached_class(
934
-                $class_obj,
935
-                $class_name,
936
-                $class_prefix,
937
-                $from_db,
938
-                $arguments
939
-            );
940
-        }
941
-        $this->_cache_on = true;
942
-        return $class_obj;
943
-    }
944
-
945
-
946
-    /**
947
-     * @param string $class_name
948
-     * @param string $default have to specify something, but not anything that will conflict
949
-     * @return mixed|string
950
-     */
951
-    protected function get_class_abbreviation(string $class_name, string $default = 'FANCY_BATMAN_PANTS')
952
-    {
953
-        return $this->_class_abbreviations[ $class_name ] ?? $default;
954
-    }
955
-
956
-
957
-    /**
958
-     * attempts to find a cached version of the requested class
959
-     * by looking in the following places:
960
-     *        $this->{$class_abbreviation}            ie:    $this->CART
961
-     *        $this->{$class_name}                        ie:    $this->Some_Class
962
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
963
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
964
-     *
965
-     * @param string $class_name
966
-     * @param string $class_prefix
967
-     * @param array  $arguments
968
-     * @return mixed
969
-     */
970
-    protected function _get_cached_class(
971
-        string $class_name,
972
-        string $class_prefix = '',
973
-        array $arguments = []
974
-    ) {
975
-        if ($class_name === 'EE_Registry') {
976
-            return $this;
977
-        }
978
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
979
-        // check if class has already been loaded, and return it if it has been
980
-        if (isset($this->{$class_abbreviation})) {
981
-            return $this->{$class_abbreviation};
982
-        }
983
-        $class_name = str_replace('\\', '_', $class_name);
984
-        if (isset($this->{$class_name})) {
985
-            return $this->{$class_name};
986
-        }
987
-        if ($class_prefix === 'addon' && $this->addons->has($class_name)) {
988
-            return $this->addons->get($class_name);
989
-        }
990
-        $object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
991
-        if ($this->LIB->has($object_identifier)) {
992
-            return $this->LIB->get($object_identifier);
993
-        }
994
-        foreach ($this->LIB as $key => $object) {
995
-            if (
996
-                // request does not contain new arguments and therefore no args identifier
997
-                ! $this->object_identifier->hasArguments($object_identifier)
998
-                // but previously cached class with args was found
999
-                && $this->object_identifier->fqcnMatchesObjectIdentifier($class_name, $key)
1000
-            ) {
1001
-                return $object;
1002
-            }
1003
-        }
1004
-        return null;
1005
-    }
1006
-
1007
-
1008
-    /**
1009
-     * removes a cached version of the requested class
1010
-     *
1011
-     * @param string  $class_name
1012
-     * @param boolean $addon
1013
-     * @param array   $arguments
1014
-     * @return boolean
1015
-     */
1016
-    public function clear_cached_class(
1017
-        string $class_name,
1018
-        bool $addon = false,
1019
-        array $arguments = []
1020
-    ): bool {
1021
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
1022
-        // check if class has already been loaded, and return it if it has been
1023
-        if (isset($this->{$class_abbreviation}) && ! $this->{$class_abbreviation} instanceof InterminableInterface) {
1024
-            $this->{$class_abbreviation} = null;
1025
-            return true;
1026
-        }
1027
-        $class_name = str_replace('\\', '_', $class_name);
1028
-        if (isset($this->{$class_name}) && ! $this->{$class_name} instanceof InterminableInterface) {
1029
-            $this->{$class_name} = null;
1030
-            return true;
1031
-        }
1032
-        if ($addon && $this->addons->has($class_name)) {
1033
-            $this->addons->remove($class_name);
1034
-            return true;
1035
-        }
1036
-        $object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
1037
-        if (
1038
-            $this->LIB->has($object_identifier)
1039
-            && ! $this->LIB->get($object_identifier) instanceof InterminableInterface
1040
-        ) {
1041
-            $this->LIB->remove($object_identifier);
1042
-            return true;
1043
-        }
1044
-        return false;
1045
-    }
1046
-
1047
-
1048
-    /**
1049
-     * _set_cached_class
1050
-     * attempts to cache the instantiated class locally
1051
-     * in one of the following places, in the following order:
1052
-     *        $this->{class_abbreviation}   ie:    $this->CART
1053
-     *        $this->{$class_name}          ie:    $this->Some_Class
1054
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1055
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1056
-     *
1057
-     * @param object $class_obj
1058
-     * @param string $class_name
1059
-     * @param string $class_prefix
1060
-     * @param bool   $from_db
1061
-     * @param array  $arguments
1062
-     * @return void
1063
-     */
1064
-    protected function _set_cached_class(
1065
-        $class_obj,
1066
-        string $class_name,
1067
-        string $class_prefix = '',
1068
-        bool $from_db = false,
1069
-        array $arguments = []
1070
-    ) {
1071
-        if ($class_name === 'EE_Registry' || empty($class_obj)) {
1072
-            return;
1073
-        }
1074
-        // return newly instantiated class
1075
-        $class_abbreviation = $this->get_class_abbreviation($class_name, '');
1076
-        if ($class_abbreviation) {
1077
-            $this->{$class_abbreviation} = $class_obj;
1078
-            return;
1079
-        }
1080
-        $class_name = str_replace('\\', '_', $class_name);
1081
-        if (property_exists($this, $class_name)) {
1082
-            $this->{$class_name} = $class_obj;
1083
-            return;
1084
-        }
1085
-        if ($class_prefix === 'addon') {
1086
-            $this->addons->add($class_name, $class_obj);
1087
-            return;
1088
-        }
1089
-        if (! $from_db) {
1090
-            $class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1091
-            $this->LIB->add($class_name, $class_obj);
1092
-        }
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * attempts to find a full valid filepath for the requested class.
1098
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
1099
-     * then returns that path if the target file has been found and is readable
1100
-     *
1101
-     * @param string $class_name
1102
-     * @param string $type
1103
-     * @param array  $file_paths
1104
-     * @return string | bool
1105
-     */
1106
-    protected function _resolve_path(string $class_name, string $type = '', array $file_paths = [])
1107
-    {
1108
-        // make sure $file_paths is an array
1109
-        $file_paths = is_array($file_paths)
1110
-            ? $file_paths
1111
-            : [$file_paths];
1112
-        // cycle thru paths
1113
-        foreach ($file_paths as $key => $file_path) {
1114
-            // convert all separators to proper /, if no filepath, then use EE_CLASSES
1115
-            $file_path = $file_path
1116
-                ? str_replace(['/', '\\'], '/', $file_path)
1117
-                : EE_CLASSES;
1118
-            // prep file type
1119
-            $type = ! empty($type)
1120
-                ? trim($type, '.') . '.'
1121
-                : '';
1122
-            // build full file path
1123
-            $file_paths[ $key ] = rtrim($file_path, '/') . '/' . $class_name . '.' . $type . 'php';
1124
-            // does the file exist and can be read ?
1125
-            if (is_readable($file_paths[ $key ])) {
1126
-                return $file_paths[ $key ];
1127
-            }
1128
-        }
1129
-        return false;
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * basically just performs a require_once()
1135
-     * but with some error handling
1136
-     *
1137
-     * @param string $path
1138
-     * @param string $class_name
1139
-     * @param string $type
1140
-     * @param array  $file_paths
1141
-     * @return bool
1142
-     * @throws EE_Error
1143
-     * @throws ReflectionException
1144
-     */
1145
-    protected function _require_file(string $path, string $class_name, string $type = '', array $file_paths = []): bool
1146
-    {
1147
-        $this->resolve_legacy_class_parent($class_name);
1148
-        // don't give up! you gotta...
1149
-        try {
1150
-            // does the file exist and can it be read ?
1151
-            if (! $path) {
1152
-                // just in case the file has already been autoloaded,
1153
-                // but discrepancies in the naming schema are preventing it from
1154
-                // being loaded via one of the EE_Registry::load_*() methods,
1155
-                // then let's try one last hail mary before throwing an exception
1156
-                // and call class_exists() again, but with autoloading turned ON
1157
-                if (class_exists($class_name)) {
1158
-                    return true;
1159
-                }
1160
-                // so sorry, can't find the file
1161
-                throw new EE_Error(
1162
-                    sprintf(
1163
-                        esc_html__(
1164
-                            'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
1165
-                            'event_espresso'
1166
-                        ),
1167
-                        trim($type, '.'),
1168
-                        $class_name,
1169
-                        '<br />' . implode(',<br />', $file_paths)
1170
-                    )
1171
-                );
1172
-            }
1173
-            // get the file
1174
-            require_once($path);
1175
-            // if the class isn't already declared somewhere
1176
-            if (class_exists($class_name, false) === false) {
1177
-                // so sorry, not a class
1178
-                throw new EE_Error(
1179
-                    sprintf(
1180
-                        esc_html__(
1181
-                            'The %s file %s does not appear to contain the %s Class.',
1182
-                            'event_espresso'
1183
-                        ),
1184
-                        $type,
1185
-                        $path,
1186
-                        $class_name
1187
-                    )
1188
-                );
1189
-            }
1190
-        } catch (EE_Error $e) {
1191
-            $e->get_error();
1192
-            return false;
1193
-        }
1194
-        return true;
1195
-    }
1196
-
1197
-
1198
-    /**
1199
-     * Some of our legacy classes that extended a parent class would simply use a require() statement
1200
-     * before their class declaration in order to ensure that the parent class was loaded.
1201
-     * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1202
-     * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1203
-     *
1204
-     * @param string $class_name
1205
-     */
1206
-    protected function resolve_legacy_class_parent(string $class_name = '')
1207
-    {
1208
-        try {
1209
-            $legacy_parent_class_map = [
1210
-                'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1211
-            ];
1212
-            if (isset($legacy_parent_class_map[ $class_name ])) {
1213
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1214
-            }
1215
-        } catch (Exception $exception) {
1216
-        }
1217
-    }
1218
-
1219
-
1220
-    /**
1221
-     * _create_object
1222
-     * Attempts to instantiate the requested class via any of the
1223
-     * commonly used instantiation methods employed throughout EE.
1224
-     * The priority for instantiation is as follows:
1225
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1226
-     *        - model objects via their 'new_instance_from_db' method
1227
-     *        - model objects via their 'new_instance' method
1228
-     *        - "singleton" classes" via their 'instance' method
1229
-     *    - standard instantiable classes via their __constructor
1230
-     * Prior to instantiation, if the classname exists in the dependency_map,
1231
-     * then the constructor for the requested class will be examined to determine
1232
-     * if any dependencies exist, and if they can be injected.
1233
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1234
-     *
1235
-     * @param string $class_name
1236
-     * @param array  $arguments
1237
-     * @param string $type
1238
-     * @param bool   $from_db
1239
-     * @return null|object|bool
1240
-     * @throws InvalidArgumentException
1241
-     * @throws InvalidInterfaceException
1242
-     * @throws EE_Error
1243
-     * @throws ReflectionException
1244
-     * @throws InvalidDataTypeException
1245
-     */
1246
-    protected function _create_object(
1247
-        string $class_name,
1248
-        array $arguments = [],
1249
-        string $type = '',
1250
-        bool $from_db = false
1251
-    ) {
1252
-        // create reflection
1253
-        $reflector = $this->mirror->getReflectionClass($class_name);
1254
-        // make sure arguments are an array
1255
-        $arguments = is_array($arguments)
1256
-            ? $arguments
1257
-            : [$arguments];
1258
-        // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1259
-        // else wrap it in an additional array so that it doesn't get split into multiple parameters
1260
-        $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1261
-            ? $arguments
1262
-            : [$arguments];
1263
-        // attempt to inject dependencies ?
1264
-        if ($this->_dependency_map->has($class_name)) {
1265
-            $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1266
-        }
1267
-        // instantiate the class if possible
1268
-        if ($reflector->isAbstract()) {
1269
-            // nothing to instantiate, loading file was enough
1270
-            // does not throw an exception so $instantiation_mode is unused
1271
-            // $instantiation_mode = "1) no constructor abstract class";
1272
-            return true;
1273
-        }
1274
-        if (
1275
-            empty($arguments)
1276
-            && $this->mirror->getConstructorFromReflection($reflector) === null
1277
-            && $reflector->isInstantiable()
1278
-        ) {
1279
-            // no constructor = static methods only... nothing to instantiate, loading file was enough
1280
-            // $instantiation_mode = "2) no constructor but instantiable";
1281
-            return $reflector->newInstance();
1282
-        }
1283
-        if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1284
-            // $instantiation_mode = "3) new_instance_from_db()";
1285
-            return call_user_func_array([$class_name, 'new_instance_from_db'], $arguments);
1286
-        }
1287
-        if (method_exists($class_name, 'new_instance')) {
1288
-            // $instantiation_mode = "4) new_instance()";
1289
-            return call_user_func_array([$class_name, 'new_instance'], $arguments);
1290
-        }
1291
-        if (method_exists($class_name, 'instance')) {
1292
-            // $instantiation_mode = "5) instance()";
1293
-            return call_user_func_array([$class_name, 'instance'], $arguments);
1294
-        }
1295
-        if ($reflector->isInstantiable()) {
1296
-            $args_passed_count = count($arguments);
1297
-            $args_required_count = count($this->mirror->getRequiredParameters($class_name));
1298
-            if ($args_passed_count < $args_required_count) {
1299
-                throw new RuntimeException(
1300
-                    sprintf(
1301
-                        __(
1302
-                            'Invalid arguments supplied for the %1$s class, %2$s were required but %3$s were passed.',
1303
-                            'event_espresso'
1304
-                        ),
1305
-                        $class_name,
1306
-                        $args_required_count,
1307
-                        $args_passed_count
1308
-                    )
1309
-                );
1310
-            }
1311
-            // $instantiation_mode = "6) constructor";
1312
-            return $reflector->newInstanceArgs($arguments);
1313
-        }
1314
-        // heh ? something's not right !
1315
-        throw new EE_Error(
1316
-            sprintf(
1317
-                esc_html__('The %s file %s could not be instantiated.', 'event_espresso'),
1318
-                $type,
1319
-                $class_name
1320
-            )
1321
-        );
1322
-    }
1323
-
1324
-
1325
-    /**
1326
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1327
-     * @param array $array
1328
-     * @return bool
1329
-     */
1330
-    protected function _array_is_numerically_and_sequentially_indexed(array $array): bool
1331
-    {
1332
-        return empty($array) || array_keys($array) === range(0, count($array) - 1);
1333
-    }
1334
-
1335
-
1336
-    /**
1337
-     * _resolve_dependencies
1338
-     * examines the constructor for the requested class to determine
1339
-     * if any dependencies exist, and if they can be injected.
1340
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1341
-     * PLZ NOTE: this is achieved by type hinting the constructor params
1342
-     * For example:
1343
-     *        if attempting to load a class "Foo" with the following constructor:
1344
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
1345
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
1346
-     *        but only IF they are NOT already present in the incoming arguments array,
1347
-     *        and the correct classes can be loaded
1348
-     *
1349
-     * @param ReflectionClass $reflector
1350
-     * @param string          $class_name
1351
-     * @param array           $arguments
1352
-     * @return array
1353
-     * @throws InvalidArgumentException
1354
-     * @throws InvalidDataTypeException
1355
-     * @throws InvalidInterfaceException
1356
-     * @throws ReflectionException
1357
-     */
1358
-    protected function _resolve_dependencies(
1359
-        ReflectionClass $reflector,
1360
-        string $class_name,
1361
-        array $arguments = []
1362
-    ): array {
1363
-        // let's examine the constructor
1364
-        $constructor = $this->mirror->getConstructorFromReflection($reflector);
1365
-        // whu? huh? nothing?
1366
-        if (! $constructor) {
1367
-            return $arguments;
1368
-        }
1369
-        // get constructor parameters
1370
-        $params = $this->mirror->getParametersFromReflection($reflector);
1371
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1372
-        $argument_keys = array_keys($arguments);
1373
-        // now loop thru all of the constructors expected parameters
1374
-        foreach ($params as $index => $param) {
1375
-            try {
1376
-                // is this a dependency for a specific class ?
1377
-                $param_class = $this->mirror->getParameterClassName($param, $class_name, $index);
1378
-            } catch (ReflectionException $exception) {
1379
-                // uh-oh... most likely a legacy class that has not been autoloaded
1380
-                // let's try to derive the classname from what we have now
1381
-                // and hope that the property var name is close to the class name
1382
-                $param_class = $param->getName();
1383
-                $param_class = str_replace('_', ' ', $param_class);
1384
-                $param_class = ucwords($param_class);
1385
-                $param_class = str_replace(' ', '_', $param_class);
1386
-            }
1387
-            // BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1388
-            $param_class = $this->class_cache->getFqnForAlias($param_class, $class_name);
1389
-            if (
1390
-                // param is not even a class
1391
-                ($param_class === null || $this->parameterIsPrimitive($param_class))
1392
-                // and something already exists in the incoming arguments for this param
1393
-                && array_key_exists($index, $argument_keys)
1394
-                && isset($arguments[ $argument_keys[ $index ] ])
1395
-            ) {
1396
-                // so let's skip this argument and move on to the next
1397
-                continue;
1398
-            }
1399
-            // parameter is type hinted as a class
1400
-            if ($param_class !== null) {
1401
-                // parameter exists as an incoming argument, AND it's the correct class
1402
-                if (
1403
-                    array_key_exists($index, $argument_keys)
1404
-                    && isset($arguments[ $argument_keys[ $index ] ])
1405
-                    && $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1406
-                ) {
1407
-                    // skip this argument and move on to the next
1408
-                    continue;
1409
-                }
1410
-                // parameter should be injected
1411
-                if ($this->_dependency_map->has_dependency_for_class($class_name, $param_class)) {
1412
-                    $arguments = $this->_resolve_dependency(
1413
-                        $class_name,
1414
-                        $param_class,
1415
-                        $arguments,
1416
-                        $index
1417
-                    );
1418
-                }
1419
-            }
1420
-            if (empty($arguments[ $index ])) {
1421
-                $default_value = $this->mirror->getParameterDefaultValue(
1422
-                    $param,
1423
-                    $class_name,
1424
-                    $index
1425
-                );
1426
-                // if there's no default value, and the incoming argument is an array (albeit empty), then use that
1427
-                $arguments[ $index ] = $default_value === null
1428
-                                       && isset($arguments[ $index ])
1429
-                                       && is_array($arguments[ $index ])
1430
-                    ? $arguments[ $index ]
1431
-                    : $default_value;
1432
-            }
1433
-        }
1434
-        return $arguments;
1435
-    }
1436
-
1437
-
1438
-    /**
1439
-     * @param string $class_name
1440
-     * @param string $param_class
1441
-     * @param array  $arguments
1442
-     * @param mixed  $index
1443
-     * @return array
1444
-     * @throws InvalidArgumentException
1445
-     * @throws InvalidInterfaceException
1446
-     * @throws InvalidDataTypeException
1447
-     */
1448
-    protected function _resolve_dependency(string $class_name, string $param_class, array $arguments, $index): array
1449
-    {
1450
-        $dependency = null;
1451
-        // should dependency be loaded from cache ?
1452
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1453
-            $class_name,
1454
-            $param_class
1455
-        );
1456
-        $cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1457
-        // we might have a dependency...
1458
-        // let's MAYBE try and find it in our cache if that's what's been requested
1459
-        $cached_class = $cache_on
1460
-            ? $this->_get_cached_class($param_class)
1461
-            : null;
1462
-        // and grab it if it exists
1463
-        if ($cached_class instanceof $param_class) {
1464
-            $dependency = $cached_class;
1465
-        } elseif ($param_class !== $class_name) {
1466
-            // obtain the loader method from the dependency map
1467
-            $loader = $this->_dependency_map->class_loader($param_class);
1468
-            // is loader a custom closure ?
1469
-            if ($loader instanceof Closure) {
1470
-                $dependency = $loader($arguments);
1471
-            } else {
1472
-                // set the cache on property for the recursive loading call
1473
-                $this->_cache_on = $cache_on;
1474
-                // if not, then let's try and load it via the registry
1475
-                if ($loader && method_exists($this, $loader)) {
1476
-                    $dependency = $this->{$loader}($param_class);
1477
-                } else {
1478
-                    $dependency = LoaderFactory::getLoader()->load(
1479
-                        $param_class,
1480
-                        [],
1481
-                        $cache_on
1482
-                    );
1483
-                }
1484
-            }
1485
-        }
1486
-        // did we successfully find the correct dependency ?
1487
-        if ($dependency instanceof $param_class) {
1488
-            // then let's inject it into the incoming array of arguments at the correct location
1489
-            $arguments[ $index ] = $dependency;
1490
-        }
1491
-        return $arguments;
1492
-    }
1493
-
1494
-
1495
-    /**
1496
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1497
-     *
1498
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1499
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1500
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1501
-     * @param array  $arguments
1502
-     * @return mixed
1503
-     */
1504
-    public static function factory(string $classname, array $arguments = [])
1505
-    {
1506
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1507
-        if ($loader instanceof Closure) {
1508
-            return $loader($arguments);
1509
-        }
1510
-        if (method_exists(self::instance(), $loader)) {
1511
-            return self::instance()->{$loader}($classname, $arguments);
1512
-        }
1513
-        return null;
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * Gets the addon by its class name
1519
-     *
1520
-     * @param string $class_name
1521
-     * @return EE_Addon
1522
-     */
1523
-    public function getAddon(string $class_name): ?EE_Addon
1524
-    {
1525
-        $class_name = str_replace('\\', '_', $class_name);
1526
-        return $this->addons->{$class_name} ?? null;
1527
-    }
1528
-
1529
-
1530
-    /**
1531
-     * removes the addon from the internal cache
1532
-     *
1533
-     * @param string $class_name
1534
-     * @return void
1535
-     */
1536
-    public function removeAddon(string $class_name)
1537
-    {
1538
-        $class_name = str_replace('\\', '_', $class_name);
1539
-        $this->addons->remove($class_name);
1540
-    }
1541
-
1542
-
1543
-    /**
1544
-     * Gets the addon by its name/slug (not classname. For that, just
1545
-     * use the get_addon() method above
1546
-     *
1547
-     * @param string $name
1548
-     * @return EE_Addon
1549
-     */
1550
-    public function get_addon_by_name(string $name): ?EE_Addon
1551
-    {
1552
-        foreach ($this->addons as $addon) {
1553
-            if ($addon->name() === $name) {
1554
-                return $addon;
1555
-            }
1556
-        }
1557
-        return null;
1558
-    }
1559
-
1560
-
1561
-    /**
1562
-     * Gets an array of all the registered addons, where the keys are their names.
1563
-     * (ie, what each returns for their name() function)
1564
-     * They're already available on EE_Registry::instance()->addons as properties,
1565
-     * where each property's name is the addon's classname,
1566
-     * So if you just want to get the addon by classname,
1567
-     * OR use the get_addon() method above.
1568
-     * PLEASE  NOTE:
1569
-     * addons with Fully Qualified Class Names
1570
-     * have had the namespace separators converted to underscores,
1571
-     * so a classname like Fully\Qualified\ClassName
1572
-     * would have been converted to Fully_Qualified_ClassName
1573
-     *
1574
-     * @return EE_Addon[] where the KEYS are the addon's name()
1575
-     */
1576
-    public function get_addons_by_name(): array
1577
-    {
1578
-        $addons = [];
1579
-        foreach ($this->addons as $addon) {
1580
-            $addons[ $addon->name() ] = $addon;
1581
-        }
1582
-        return $addons;
1583
-    }
1584
-
1585
-
1586
-    /**
1587
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1588
-     * a stale copy of it around
1589
-     *
1590
-     * @param string $model_name
1591
-     * @return EEM_Base
1592
-     * @throws EE_Error
1593
-     * @throws ReflectionException
1594
-     */
1595
-    public function reset_model(string $model_name): ?EEM_Base
1596
-    {
1597
-        $model_class_name = strpos($model_name, 'EEM_') !== 0
1598
-            ? "EEM_$model_name"
1599
-            : $model_name;
1600
-        if (! $this->LIB->has($model_class_name)) {
1601
-            return null;
1602
-        }
1603
-        $model = $this->LIB->get($model_class_name);
1604
-        if (! $model instanceof EEM_Base) {
1605
-            return null;
1606
-        }
1607
-        // get that model reset it and make sure we nuke the old reference to it
1608
-        if ($model instanceof $model_class_name && is_callable([$model_class_name, 'reset'])) {
1609
-            $this->LIB->remove($model_class_name);
1610
-            $this->LIB->add($model_class_name, $model->reset());
1611
-        } else {
1612
-            throw new EE_Error(
1613
-                sprintf(
1614
-                    esc_html__('Model %s does not have a method "reset"', 'event_espresso'),
1615
-                    $model_name
1616
-                )
1617
-            );
1618
-        }
1619
-        return $model;
1620
-    }
1621
-
1622
-
1623
-    /**
1624
-     * Resets the registry.
1625
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when
1626
-     * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1627
-     * - $_dependency_map
1628
-     * - $_class_abbreviations
1629
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1630
-     * - $REQ:  Still on the same request so no need to change.
1631
-     * - $CAP: There is no site specific state in the EE_Capability class.
1632
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1633
-     * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1634
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1635
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1636
-     *             switch or on the restore.
1637
-     * - $modules
1638
-     * - $shortcodes
1639
-     * - $widgets
1640
-     *
1641
-     * @param boolean $hard             [deprecated]
1642
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1643
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1644
-     *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1645
-     * @param bool    $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1646
-     *                                  client
1647
-     *                                  code instead can just change the model context to a different blog id if
1648
-     *                                  necessary
1649
-     * @return EE_Registry
1650
-     * @throws EE_Error
1651
-     * @throws ReflectionException
1652
-     */
1653
-    public static function reset(bool $hard = false, bool $reinstantiate = true, bool $reset_models = true): EE_Registry
1654
-    {
1655
-        $instance            = self::instance();
1656
-        $instance->_cache_on = true;
1657
-        // reset some "special" classes
1658
-        EEH_Activation::reset();
1659
-        $hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1660
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1661
-        $instance->CART = null;
1662
-        $instance->MRM = null;
1663
-        // messages reset
1664
-        EED_Messages::reset();
1665
-        // handle of objects cached on LIB
1666
-        foreach (['LIB', 'modules'] as $cache) {
1667
-            foreach ($instance->{$cache} as $class_name => $class) {
1668
-                if (self::_reset_and_unset_object($class, $reset_models)) {
1669
-                    unset($instance->{$cache}->{$class_name});
1670
-                }
1671
-            }
1672
-        }
1673
-        return $instance;
1674
-    }
1675
-
1676
-
1677
-    /**
1678
-     * if passed object implements ResettableInterface, then call it's reset() method
1679
-     * if passed object implements InterminableInterface, then return false,
1680
-     * to indicate that it should NOT be cleared from the Registry cache
1681
-     *
1682
-     * @param      $object
1683
-     * @param bool $reset_models
1684
-     * @return bool returns true if cached object should be unset
1685
-     * @throws EE_Error
1686
-     * @throws ReflectionException
1687
-     */
1688
-    private static function _reset_and_unset_object($object, bool $reset_models): bool
1689
-    {
1690
-        if (! is_object($object)) {
1691
-            // don't unset anything that's not an object
1692
-            return false;
1693
-        }
1694
-        if ($object instanceof InterminableInterface) {
1695
-            // don't unset anything that's not terminable
1696
-            return false;
1697
-        }
1698
-        if ($object instanceof EED_Module) {
1699
-            $object::reset();
1700
-            // don't unset modules
1701
-            return false;
1702
-        }
1703
-        if ($object instanceof ResettableInterface) {
1704
-            if ($object instanceof EEM_Base) {
1705
-                if ($reset_models) {
1706
-                    $object->reset();
1707
-                    return true;
1708
-                }
1709
-                return false;
1710
-            }
1711
-            $object->reset();
1712
-            return true;
1713
-        }
1714
-        // at least clear object from cache
1715
-        self::$_instance->clear_cached_class(get_class($object));
1716
-        return false;
1717
-    }
1718
-
1719
-
1720
-    /**
1721
-     * Gets all the custom post type models defined
1722
-     *
1723
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1724
-     */
1725
-    public function cpt_models(): array
1726
-    {
1727
-        $cpt_models = [];
1728
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1729
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1730
-                $cpt_models[ $short_name ] = $classname;
1731
-            }
1732
-        }
1733
-        return $cpt_models;
1734
-    }
1735
-
1736
-
1737
-    /**
1738
-     * @return EE_Config
1739
-     */
1740
-    public static function CFG(): EE_Config
1741
-    {
1742
-        return self::instance()->CFG;
1743
-    }
1744
-
1745
-
1746
-    /**
1747
-     * @param string $class_name
1748
-     * @return ReflectionClass
1749
-     * @throws ReflectionException
1750
-     * @throws InvalidDataTypeException
1751
-     * @deprecated 4.9.62.p
1752
-     */
1753
-    public function get_ReflectionClass(string $class_name): ReflectionClass
1754
-    {
1755
-        return $this->mirror->getReflectionClass($class_name);
1756
-    }
1757
-
1758
-    private function parameterIsPrimitive(?string $param_class): bool
1759
-    {
1760
-        return in_array(
1761
-            $param_class,
1762
-            [
1763
-                'array',
1764
-                'bool',
1765
-                'float',
1766
-                'int',
1767
-                'string',
1768
-            ]
1769
-        );
1770
-    }
25
+	/**
26
+	 * @var EE_Registry $_instance
27
+	 */
28
+	private static $_instance;
29
+
30
+	/**
31
+	 * @var EE_Dependency_Map $_dependency_map
32
+	 */
33
+	protected $_dependency_map;
34
+
35
+	/**
36
+	 * @var Mirror
37
+	 */
38
+	private $mirror;
39
+
40
+	/**
41
+	 * @var ClassInterfaceCache $class_cache
42
+	 */
43
+	private $class_cache;
44
+
45
+	/**
46
+	 * @var array $_class_abbreviations
47
+	 */
48
+	protected $_class_abbreviations = [];
49
+
50
+	/**
51
+	 * @var CommandBusInterface $BUS
52
+	 */
53
+	public $BUS;
54
+
55
+	/**
56
+	 * @var EE_Cart $CART
57
+	 */
58
+	public $CART;
59
+
60
+	/**
61
+	 * @var EE_Config $CFG
62
+	 */
63
+	public $CFG;
64
+
65
+	/**
66
+	 * @var EE_Network_Config $NET_CFG
67
+	 */
68
+	public $NET_CFG;
69
+
70
+	/**
71
+	 * RegistryContainer for storing library classes in
72
+	 *
73
+	 * @var RegistryContainer $LIB
74
+	 */
75
+	public $LIB;
76
+
77
+	/**
78
+	 * @var EE_Request_Handler $REQ
79
+	 * @deprecated 4.10.14.p
80
+	 */
81
+	public $REQ;
82
+
83
+	/**
84
+	 * @var EE_Session $SSN
85
+	 */
86
+	public $SSN;
87
+
88
+	/**
89
+	 * @since 4.5.0
90
+	 * @var EE_Capabilities $CAP
91
+	 */
92
+	public $CAP;
93
+
94
+	/**
95
+	 * @since 4.9.0
96
+	 * @var EE_Message_Resource_Manager $MRM
97
+	 */
98
+	public $MRM;
99
+
100
+	/**
101
+	 * @var Registry $AssetsRegistry
102
+	 */
103
+	public $AssetsRegistry;
104
+
105
+	/**
106
+	 * RegistryContainer for holding addons which have registered themselves to work with EE core
107
+	 *
108
+	 * @var RegistryContainer|EE_Addon[] $addons
109
+	 */
110
+	public $addons;
111
+
112
+	/**
113
+	 * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
114
+	 *
115
+	 * @var EEM_Base[] $models
116
+	 */
117
+	public $models = [];
118
+
119
+	/**
120
+	 * @var RegistryContainer|EED_Module[] $modules
121
+	 */
122
+	public $modules;
123
+
124
+	/**
125
+	 * @var RegistryContainer|EES_Shortcode[] $shortcodes
126
+	 */
127
+	public $shortcodes;
128
+
129
+	/**
130
+	 * @var RegistryContainer|WP_Widget[] $widgets
131
+	 */
132
+	public $widgets;
133
+
134
+	/**
135
+	 * this is an array of all implemented model names (i.e. not the parent abstract models, or models
136
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
137
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
138
+	 * classnames (eg "EEM_Event")
139
+	 *
140
+	 * @var array $non_abstract_db_models
141
+	 */
142
+	public $non_abstract_db_models = [];
143
+
144
+	/**
145
+	 * internationalization for JS strings
146
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
147
+	 *    in js file:  var translatedString = eei18n.string_key;
148
+	 *
149
+	 * @var array $i18n_js_strings
150
+	 */
151
+	public static $i18n_js_strings = [];
152
+
153
+	/**
154
+	 * $main_file - path to espresso.php
155
+	 *
156
+	 * @var array $main_file
157
+	 */
158
+	public $main_file;
159
+
160
+	/**
161
+	 * array of ReflectionClass objects where the key is the class name
162
+	 *
163
+	 * @deprecated 4.9.62.p
164
+	 * @var ReflectionClass[] $_reflectors
165
+	 */
166
+	public $_reflectors;
167
+
168
+	/**
169
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
170
+	 *
171
+	 * @var boolean $_cache_on
172
+	 */
173
+	protected $_cache_on = true;
174
+
175
+	/**
176
+	 * @var ObjectIdentifier
177
+	 */
178
+	private $object_identifier;
179
+
180
+
181
+	/**
182
+	 * @singleton method used to instantiate class object
183
+	 * @param EE_Dependency_Map|null   $dependency_map
184
+	 * @param Mirror|null              $mirror
185
+	 * @param ClassInterfaceCache|null $class_cache
186
+	 * @param ObjectIdentifier|null    $object_identifier
187
+	 * @return EE_Registry instance
188
+	 */
189
+	public static function instance(
190
+		EE_Dependency_Map $dependency_map = null,
191
+		Mirror $mirror = null,
192
+		ClassInterfaceCache $class_cache = null,
193
+		ObjectIdentifier $object_identifier = null
194
+	): EE_Registry {
195
+		// check if class object is instantiated
196
+		if (
197
+			! self::$_instance instanceof EE_Registry
198
+			&& $dependency_map instanceof EE_Dependency_Map
199
+			&& $mirror instanceof Mirror
200
+			&& $class_cache instanceof ClassInterfaceCache
201
+			&& $object_identifier instanceof ObjectIdentifier
202
+		) {
203
+			self::$_instance = new self(
204
+				$dependency_map,
205
+				$mirror,
206
+				$class_cache,
207
+				$object_identifier
208
+			);
209
+		}
210
+		return self::$_instance;
211
+	}
212
+
213
+
214
+	/**
215
+	 * protected constructor to prevent direct creation
216
+	 *
217
+	 * @Constructor
218
+	 * @param EE_Dependency_Map   $dependency_map
219
+	 * @param Mirror              $mirror
220
+	 * @param ClassInterfaceCache $class_cache
221
+	 * @param ObjectIdentifier    $object_identifier
222
+	 */
223
+	protected function __construct(
224
+		EE_Dependency_Map $dependency_map,
225
+		Mirror $mirror,
226
+		ClassInterfaceCache $class_cache,
227
+		ObjectIdentifier $object_identifier
228
+	) {
229
+		$this->_dependency_map   = $dependency_map;
230
+		$this->mirror            = $mirror;
231
+		$this->class_cache       = $class_cache;
232
+		$this->object_identifier = $object_identifier;
233
+		// $registry_container = new RegistryContainer();
234
+		$this->LIB        = new RegistryContainer();
235
+		$this->addons     = new RegistryContainer();
236
+		$this->modules    = new RegistryContainer();
237
+		$this->shortcodes = new RegistryContainer();
238
+		$this->widgets    = new RegistryContainer();
239
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', [$this, 'initialize']);
240
+	}
241
+
242
+
243
+	/**
244
+	 * initialize
245
+	 *
246
+	 * @throws OutOfBoundsException
247
+	 * @throws InvalidArgumentException
248
+	 * @throws InvalidInterfaceException
249
+	 * @throws InvalidDataTypeException
250
+	 * @throws EE_Error
251
+	 * @throws ReflectionException
252
+	 */
253
+	public function initialize()
254
+	{
255
+		$this->_class_abbreviations = apply_filters(
256
+			'FHEE__EE_Registry____construct___class_abbreviations',
257
+			[
258
+				'EE_Config'                                       => 'CFG',
259
+				'EE_Session'                                      => 'SSN',
260
+				'EE_Capabilities'                                 => 'CAP',
261
+				'EE_Cart'                                         => 'CART',
262
+				'EE_Network_Config'                               => 'NET_CFG',
263
+				'EE_Request_Handler'                              => 'REQ',
264
+				'EE_Message_Resource_Manager'                     => 'MRM',
265
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
266
+				'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
267
+			]
268
+		);
269
+		$this->load_core('Base', [], true);
270
+		// add our request and response objects to the cache
271
+		$request_loader = $this->_dependency_map->class_loader(
272
+			'EventEspresso\core\services\request\Request'
273
+		);
274
+		$this->_set_cached_class(
275
+			$request_loader(),
276
+			'EventEspresso\core\services\request\Request'
277
+		);
278
+		$response_loader = $this->_dependency_map->class_loader(
279
+			'EventEspresso\core\services\request\Response'
280
+		);
281
+		$this->_set_cached_class(
282
+			$response_loader(),
283
+			'EventEspresso\core\services\request\Response'
284
+		);
285
+		add_action('AHEE__EE_System__set_hooks_for_core', [$this, 'init']);
286
+	}
287
+
288
+
289
+	/**
290
+	 * @return void
291
+	 */
292
+	public function init()
293
+	{
294
+		// Get current page protocol
295
+		$protocol = is_ssl() ? 'https://' : 'http://';
296
+		// Output admin-ajax.php URL with same protocol as current page
297
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
298
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') && WP_DEBUG;
299
+	}
300
+
301
+
302
+	/**
303
+	 * @return array
304
+	 */
305
+	public static function sanitize_i18n_js_strings(): array
306
+	{
307
+		$i18n_js_strings = (array) self::$i18n_js_strings;
308
+		foreach ($i18n_js_strings as $key => $value) {
309
+			if (is_scalar($value)) {
310
+				$decoded_value           = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
311
+				$i18n_js_strings[ $key ] = wp_strip_all_tags($decoded_value);
312
+			}
313
+		}
314
+		return $i18n_js_strings;
315
+	}
316
+
317
+
318
+	/**
319
+	 * localize_i18n_js_strings
320
+	 *
321
+	 * @return string
322
+	 */
323
+	public static function localize_i18n_js_strings(): string
324
+	{
325
+		$i18n_js_strings = EE_Registry::sanitize_i18n_js_strings();
326
+		return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
327
+	}
328
+
329
+
330
+	/**
331
+	 * @param mixed string | EED_Module $module
332
+	 * @throws OutOfBoundsException
333
+	 * @throws InvalidArgumentException
334
+	 * @throws InvalidInterfaceException
335
+	 * @throws InvalidDataTypeException
336
+	 * @throws EE_Error
337
+	 * @throws ReflectionException
338
+	 */
339
+	public function add_module($module)
340
+	{
341
+		if ($module instanceof EED_Module) {
342
+			$module_class = get_class($module);
343
+			$this->modules->add($module_class, $module);
344
+		} else {
345
+			if (! class_exists('EE_Module_Request_Router', false)) {
346
+				$this->load_core('Module_Request_Router');
347
+			}
348
+			EE_Module_Request_Router::module_factory($module);
349
+		}
350
+	}
351
+
352
+
353
+	/**
354
+	 * @param string $module_name
355
+	 * @return mixed EED_Module | NULL
356
+	 */
357
+	public function get_module(string $module_name = '')
358
+	{
359
+		return $this->modules->get($module_name);
360
+	}
361
+
362
+
363
+	/**
364
+	 * loads core classes - must be singletons
365
+	 *
366
+	 * @param string $class_name - simple class name ie: session
367
+	 * @param mixed  $arguments
368
+	 * @param bool   $load_only
369
+	 * @return bool|null|object
370
+	 * @throws InvalidInterfaceException
371
+	 * @throws InvalidDataTypeException
372
+	 * @throws EE_Error
373
+	 * @throws ReflectionException
374
+	 * @throws InvalidArgumentException
375
+	 */
376
+	public function load_core(string $class_name, $arguments = [], bool $load_only = false)
377
+	{
378
+		$core_paths = (array) apply_filters(
379
+			'FHEE__EE_Registry__load_core__core_paths',
380
+			[
381
+				EE_CORE,
382
+				EE_ADMIN,
383
+				EE_CPTS,
384
+				EE_CORE . 'CPTs/',
385
+				EE_CORE . 'data_migration_scripts/',
386
+				EE_CORE . 'request_stack/',
387
+				EE_CORE . 'middleware/',
388
+			]
389
+		);
390
+		// retrieve instantiated class
391
+		return $this->_load(
392
+			$core_paths,
393
+			'EE_',
394
+			$class_name,
395
+			'core',
396
+			$arguments,
397
+			false,
398
+			true,
399
+			$load_only
400
+		);
401
+	}
402
+
403
+
404
+	/**
405
+	 * loads service classes
406
+	 *
407
+	 * @param string $class_name - simple class name ie: session
408
+	 * @param mixed  $arguments
409
+	 * @param bool   $load_only
410
+	 * @return bool|null|object
411
+	 * @throws InvalidInterfaceException
412
+	 * @throws InvalidDataTypeException
413
+	 * @throws EE_Error
414
+	 * @throws ReflectionException
415
+	 * @throws InvalidArgumentException
416
+	 * @deprecated  4.10.33.p
417
+	 */
418
+	public function load_service(string $class_name, $arguments = [], bool $load_only = false)
419
+	{
420
+		$service_paths = (array) apply_filters(
421
+			'FHEE__EE_Registry__load_service__service_paths',
422
+			[
423
+				EE_CORE . 'services/',
424
+			]
425
+		);
426
+		// retrieve instantiated class
427
+		return $this->_load(
428
+			$service_paths,
429
+			'EE_',
430
+			$class_name,
431
+			'class',
432
+			$arguments,
433
+			false,
434
+			true,
435
+			$load_only
436
+		);
437
+	}
438
+
439
+
440
+	/**
441
+	 * loads data_migration_scripts
442
+	 *
443
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
444
+	 * @param mixed  $arguments
445
+	 * @return bool|null|object
446
+	 * @throws InvalidInterfaceException
447
+	 * @throws InvalidDataTypeException
448
+	 * @throws EE_Error
449
+	 * @throws ReflectionException
450
+	 * @throws InvalidArgumentException
451
+	 */
452
+	public function load_dms(string $class_name, $arguments = [])
453
+	{
454
+		// retrieve instantiated class
455
+		return $this->_load(
456
+			EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
457
+			'EE_DMS_',
458
+			$class_name,
459
+			'dms',
460
+			$arguments,
461
+			false,
462
+			false
463
+		);
464
+	}
465
+
466
+
467
+	/**
468
+	 * loads object creating classes - must be singletons
469
+	 *
470
+	 * @param string $class_name - simple class name ie: attendee
471
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
472
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
473
+	 *                           instantiate
474
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
475
+	 *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
476
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
477
+	 *                           (default)
478
+	 * @return bool|null|object
479
+	 * @throws InvalidInterfaceException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws EE_Error
482
+	 * @throws ReflectionException
483
+	 * @throws InvalidArgumentException
484
+	 */
485
+	public function load_class(
486
+		string $class_name,
487
+		$arguments = [],
488
+		bool $from_db = false,
489
+		bool $cache = true,
490
+		bool $load_only = false
491
+	) {
492
+		$paths = (array) apply_filters(
493
+			'FHEE__EE_Registry__load_class__paths',
494
+			[
495
+				EE_CORE,
496
+				EE_CLASSES,
497
+				EE_BUSINESS,
498
+			]
499
+		);
500
+		// retrieve instantiated class
501
+		return $this->_load(
502
+			$paths,
503
+			'EE_',
504
+			$class_name,
505
+			'class',
506
+			$arguments,
507
+			$from_db,
508
+			$cache,
509
+			$load_only
510
+		);
511
+	}
512
+
513
+
514
+	/**
515
+	 * loads helper classes - must be singletons
516
+	 *
517
+	 * @param string $class_name - simple class name ie: price
518
+	 * @param mixed  $arguments
519
+	 * @param bool   $load_only
520
+	 * @return bool|null|object
521
+	 * @throws InvalidInterfaceException
522
+	 * @throws InvalidDataTypeException
523
+	 * @throws EE_Error
524
+	 * @throws ReflectionException
525
+	 * @throws InvalidArgumentException
526
+	 */
527
+	public function load_helper(string $class_name, $arguments = [], bool $load_only = true)
528
+	{
529
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
530
+		$helper_paths = (array) apply_filters('FHEE__EE_Registry__load_helper__helper_paths', [EE_HELPERS]);
531
+		// retrieve instantiated class
532
+		return $this->_load(
533
+			$helper_paths,
534
+			'EEH_',
535
+			$class_name,
536
+			'helper',
537
+			$arguments,
538
+			false,
539
+			true,
540
+			$load_only
541
+		);
542
+	}
543
+
544
+
545
+	/**
546
+	 * loads core classes - must be singletons
547
+	 *
548
+	 * @param string $class_name - simple class name ie: session
549
+	 * @param mixed  $arguments
550
+	 * @param bool   $load_only
551
+	 * @param bool   $cache      whether to cache the object or not.
552
+	 * @return bool|null|object
553
+	 * @throws InvalidInterfaceException
554
+	 * @throws InvalidDataTypeException
555
+	 * @throws EE_Error
556
+	 * @throws ReflectionException
557
+	 * @throws InvalidArgumentException
558
+	 */
559
+	public function load_lib(string $class_name, $arguments = [], bool $load_only = false, bool $cache = true)
560
+	{
561
+		$paths = [
562
+			EE_LIBRARIES,
563
+			EE_LIBRARIES . 'messages/',
564
+			EE_LIBRARIES . 'shortcodes/',
565
+			EE_LIBRARIES . 'qtips/',
566
+			EE_LIBRARIES . 'payment_methods/',
567
+		];
568
+		// retrieve instantiated class
569
+		return $this->_load(
570
+			$paths,
571
+			'EE_',
572
+			$class_name,
573
+			'lib',
574
+			$arguments,
575
+			false,
576
+			$cache,
577
+			$load_only
578
+		);
579
+	}
580
+
581
+
582
+	/**
583
+	 * loads model classes - must be singletons
584
+	 *
585
+	 * @param string $class_name - simple class name ie: price
586
+	 * @param mixed  $arguments
587
+	 * @param bool   $load_only
588
+	 * @return bool|null|object
589
+	 * @throws InvalidInterfaceException
590
+	 * @throws InvalidDataTypeException
591
+	 * @throws EE_Error
592
+	 * @throws ReflectionException
593
+	 * @throws InvalidArgumentException
594
+	 */
595
+	public function load_model(string $class_name, $arguments = [], bool $load_only = false)
596
+	{
597
+		$paths = (array) apply_filters(
598
+			'FHEE__EE_Registry__load_model__paths',
599
+			[
600
+				EE_MODELS,
601
+				EE_CORE,
602
+			]
603
+		);
604
+		// retrieve instantiated class
605
+		return $this->_load(
606
+			$paths,
607
+			'EEM_',
608
+			$class_name,
609
+			'model',
610
+			$arguments,
611
+			false,
612
+			true,
613
+			$load_only
614
+		);
615
+	}
616
+
617
+
618
+	/**
619
+	 * loads model classes - must be singletons
620
+	 *
621
+	 * @param string $class_name - simple class name ie: price
622
+	 * @param mixed  $arguments
623
+	 * @param bool   $load_only
624
+	 * @return bool|null|object
625
+	 * @throws InvalidInterfaceException
626
+	 * @throws InvalidDataTypeException
627
+	 * @throws EE_Error
628
+	 * @throws ReflectionException
629
+	 * @throws InvalidArgumentException
630
+	 * @deprecated  4.10.33.p
631
+	 */
632
+	public function load_model_class(string $class_name, $arguments = [], bool $load_only = true)
633
+	{
634
+		$paths = [
635
+			EE_MODELS . 'fields/',
636
+			EE_MODELS . 'helpers/',
637
+			EE_MODELS . 'relations/',
638
+			EE_MODELS . 'strategies/',
639
+		];
640
+		// retrieve instantiated class
641
+		return $this->_load(
642
+			$paths,
643
+			'EE_',
644
+			$class_name,
645
+			'',
646
+			$arguments,
647
+			false,
648
+			true,
649
+			$load_only
650
+		);
651
+	}
652
+
653
+
654
+	/**
655
+	 * Determines if $model_name is the name of an actual EE model.
656
+	 *
657
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
658
+	 * @return boolean
659
+	 */
660
+	public function is_model_name(string $model_name): bool
661
+	{
662
+		return isset($this->models[ $model_name ]);
663
+	}
664
+
665
+
666
+	/**
667
+	 * generic class loader
668
+	 *
669
+	 * @param string $path_to_file - directory path to file location, not including filename
670
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
671
+	 * @param string $type         - file type - core? class? helper? model?
672
+	 * @param mixed  $arguments
673
+	 * @param bool   $load_only
674
+	 * @return bool|null|object
675
+	 * @throws InvalidInterfaceException
676
+	 * @throws InvalidDataTypeException
677
+	 * @throws EE_Error
678
+	 * @throws ReflectionException
679
+	 * @throws InvalidArgumentException
680
+	 */
681
+	public function load_file(
682
+		string $path_to_file,
683
+		string $file_name,
684
+		string $type = '',
685
+		$arguments = [],
686
+		bool $load_only = true
687
+	) {
688
+		// retrieve instantiated class
689
+		return $this->_load(
690
+			(array) $path_to_file,
691
+			'',
692
+			$file_name,
693
+			$type,
694
+			$arguments,
695
+			false,
696
+			true,
697
+			$load_only
698
+		);
699
+	}
700
+
701
+
702
+	/**
703
+	 * @param string $path_to_file - directory path to file location, not including filename
704
+	 * @param string $class_name   - full class name  ie:  My_Class
705
+	 * @param string $type         - file type - core? class? helper? model?
706
+	 * @param mixed  $arguments
707
+	 * @param bool   $load_only
708
+	 * @return bool|null|object
709
+	 * @throws InvalidInterfaceException
710
+	 * @throws InvalidDataTypeException
711
+	 * @throws EE_Error
712
+	 * @throws ReflectionException
713
+	 * @throws InvalidArgumentException
714
+	 * @deprecated  4.10.33.p
715
+	 */
716
+	public function load_addon(
717
+		string $path_to_file,
718
+		string $class_name,
719
+		string $type = 'class',
720
+		$arguments = [],
721
+		bool $load_only = false
722
+	) {
723
+		// retrieve instantiated class
724
+		return $this->_load(
725
+			(array) $path_to_file,
726
+			'addon',
727
+			$class_name,
728
+			$type,
729
+			$arguments,
730
+			false,
731
+			true,
732
+			$load_only
733
+		);
734
+	}
735
+
736
+
737
+	/**
738
+	 * instantiates, caches, and automatically resolves dependencies
739
+	 * for classes that use a Fully Qualified Class Name.
740
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
741
+	 * then you need to use one of the existing load_*() methods
742
+	 * which can resolve the classname and filepath from the passed arguments
743
+	 *
744
+	 * @param string      $class_name Fully Qualified Class Name
745
+	 * @param array       $arguments  an argument, or array of arguments to pass to the class upon instantiation
746
+	 * @param bool        $cache      whether to cache the instantiated object for reuse
747
+	 * @param bool        $from_db    some classes are instantiated from the db
748
+	 *                                and thus call a different method to instantiate
749
+	 * @param bool        $load_only  if true, will only load the file, but will NOT instantiate an object
750
+	 * @param bool|string $addon      if true, will cache the object in the EE_Registry->$addons array
751
+	 * @return bool|null|mixed     null = failure to load or instantiate class object.
752
+	 *                                object = class loaded and instantiated successfully.
753
+	 *                                bool = fail or success when $load_only is true
754
+	 * @throws InvalidInterfaceException
755
+	 * @throws InvalidDataTypeException
756
+	 * @throws EE_Error
757
+	 * @throws ReflectionException
758
+	 * @throws InvalidArgumentException
759
+	 */
760
+	public function create(
761
+		string $class_name = '',
762
+		array $arguments = [],
763
+		bool $cache = false,
764
+		bool $from_db = false,
765
+		bool $load_only = false,
766
+		bool $addon = false
767
+	) {
768
+		$class_name   = ltrim($class_name, '\\');
769
+		$class_name   = $this->class_cache->getFqnForAlias($class_name);
770
+		$class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
771
+		// if a non-FQCN was passed, then
772
+		// verifyClassExists() might return an object
773
+		// or it could return null if the class just could not be found anywhere
774
+		if ($class_exists instanceof $class_name || $class_exists === null) {
775
+			// either way, return the results
776
+			return $class_exists;
777
+		}
778
+		$class_name = $class_exists;
779
+		// if we're only loading the class and it already exists, then let's just return true immediately
780
+		if ($load_only) {
781
+			return true;
782
+		}
783
+		$addon = $addon ? 'addon' : '';
784
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
785
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
786
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
787
+		if ($this->_cache_on && $cache) {
788
+			// return object if it's already cached
789
+			$cached_class = $this->_get_cached_class($class_name, $addon, $arguments);
790
+			if ($cached_class !== null) {
791
+				return $cached_class;
792
+			}
793
+		}                                                           // obtain the loader method from the dependency map
794
+		$loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
795
+		if ($loader instanceof Closure) {
796
+			$class_obj = $loader($arguments);
797
+		} else {
798
+			if ($loader && method_exists($this, $loader)) {
799
+				$class_obj = $this->{$loader}($class_name, $arguments);
800
+			} else {
801
+				$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
802
+			}
803
+		}
804
+		if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
805
+			// save it for later... kinda like gum  { : $
806
+			$this->_set_cached_class(
807
+				$class_obj,
808
+				$class_name,
809
+				$addon,
810
+				$from_db,
811
+				$arguments
812
+			);
813
+		}
814
+		$this->_cache_on = true;
815
+		return $class_obj;
816
+	}
817
+
818
+
819
+	/**
820
+	 * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
821
+	 *
822
+	 * @param string|mixed $class_name
823
+	 * @param array        $arguments
824
+	 * @param int          $attempt
825
+	 * @return mixed
826
+	 */
827
+	private function loadOrVerifyClassExists($class_name, array $arguments, int $attempt = 1)
828
+	{
829
+		if (is_object($class_name) || class_exists($class_name)) {
830
+			return $class_name;
831
+		}
832
+		switch ($attempt) {
833
+			case 1:
834
+				// if it's a FQCN then maybe the class is registered with a preceding \
835
+				$class_name = strpos($class_name, '\\') !== false
836
+					? '\\' . ltrim($class_name, '\\')
837
+					: $class_name;
838
+				break;
839
+			case 2:
840
+				//
841
+				$loader = $this->_dependency_map->class_loader($class_name);
842
+				if ($loader && method_exists($this, $loader)) {
843
+					return $this->{$loader}($class_name, $arguments);
844
+				}
845
+				break;
846
+			case 3:
847
+			default:
848
+				return null;
849
+		}
850
+		$attempt++;
851
+		return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
852
+	}
853
+
854
+
855
+	/**
856
+	 * instantiates, caches, and injects dependencies for classes
857
+	 *
858
+	 * @param array  $file_paths         an array of paths to folders to look in
859
+	 * @param string $class_prefix       EE  or EEM or... ???
860
+	 * @param string $class_name         $class name
861
+	 * @param string $type               file type - core? class? helper? model?
862
+	 * @param mixed  $arguments          an argument or array of arguments to pass to the class upon instantiation
863
+	 * @param bool   $from_db            some classes are instantiated from the db
864
+	 *                                   and thus call a different method to instantiate
865
+	 * @param bool   $cache              whether to cache the instantiated object for reuse
866
+	 * @param bool   $load_only          if true, will only load the file, but will NOT instantiate an object
867
+	 * @return bool|null|object          null   = failure to load or instantiate class object.
868
+	 *                                   object = class loaded and instantiated successfully.
869
+	 *                                   bool   = fail or success when $load_only is true
870
+	 * @throws EE_Error
871
+	 * @throws ReflectionException
872
+	 * @throws InvalidInterfaceException
873
+	 * @throws InvalidDataTypeException
874
+	 * @throws InvalidArgumentException
875
+	 */
876
+	protected function _load(
877
+		array $file_paths = [],
878
+		string $class_prefix = 'EE_',
879
+		string $class_name = '',
880
+		string $type = 'class',
881
+		array $arguments = [],
882
+		bool $from_db = false,
883
+		bool $cache = true,
884
+		bool $load_only = false
885
+	) {
886
+		$class_name = ltrim($class_name, '\\');
887
+		// strip php file extension
888
+		$class_name = str_replace('.php', '', trim($class_name));
889
+		// does the class have a prefix ?
890
+		if (! empty($class_prefix) && $class_prefix !== 'addon') {
891
+			// make sure $class_prefix is uppercase
892
+			$class_prefix = strtoupper(trim($class_prefix));
893
+			// add class prefix ONCE!!!
894
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
895
+		}
896
+		$class_name   = $this->class_cache->getFqnForAlias($class_name);
897
+		$class_exists = class_exists($class_name, false);
898
+		// if we're only loading the class and it already exists, then let's just return true immediately
899
+		if ($load_only && $class_exists) {
900
+			return true;
901
+		}
902
+		$arguments = is_array($arguments) ? $arguments : [$arguments];
903
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
904
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
905
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
906
+		if ($this->_cache_on && $cache && ! $load_only) {
907
+			// return object if it's already cached
908
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix, $arguments);
909
+			if ($cached_class !== null) {
910
+				return $cached_class;
911
+			}
912
+		}
913
+		// if the class doesn't already exist.. then we need to try and find the file and load it
914
+		if (! $class_exists) {
915
+			// get full path to file
916
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
917
+			// load the file
918
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
919
+			// if we are only loading a file but NOT instantiating an object
920
+			// then return boolean for whether class was loaded or not
921
+			if ($load_only) {
922
+				return $loaded;
923
+			}
924
+			// if an object was expected but loading failed, then return nothing
925
+			if (! $loaded) {
926
+				return null;
927
+			}
928
+		}
929
+		// instantiate the requested object
930
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
931
+		if ($this->_cache_on && $cache) {
932
+			// save it for later... kinda like gum  { : $
933
+			$this->_set_cached_class(
934
+				$class_obj,
935
+				$class_name,
936
+				$class_prefix,
937
+				$from_db,
938
+				$arguments
939
+			);
940
+		}
941
+		$this->_cache_on = true;
942
+		return $class_obj;
943
+	}
944
+
945
+
946
+	/**
947
+	 * @param string $class_name
948
+	 * @param string $default have to specify something, but not anything that will conflict
949
+	 * @return mixed|string
950
+	 */
951
+	protected function get_class_abbreviation(string $class_name, string $default = 'FANCY_BATMAN_PANTS')
952
+	{
953
+		return $this->_class_abbreviations[ $class_name ] ?? $default;
954
+	}
955
+
956
+
957
+	/**
958
+	 * attempts to find a cached version of the requested class
959
+	 * by looking in the following places:
960
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
961
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
962
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
963
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
964
+	 *
965
+	 * @param string $class_name
966
+	 * @param string $class_prefix
967
+	 * @param array  $arguments
968
+	 * @return mixed
969
+	 */
970
+	protected function _get_cached_class(
971
+		string $class_name,
972
+		string $class_prefix = '',
973
+		array $arguments = []
974
+	) {
975
+		if ($class_name === 'EE_Registry') {
976
+			return $this;
977
+		}
978
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
979
+		// check if class has already been loaded, and return it if it has been
980
+		if (isset($this->{$class_abbreviation})) {
981
+			return $this->{$class_abbreviation};
982
+		}
983
+		$class_name = str_replace('\\', '_', $class_name);
984
+		if (isset($this->{$class_name})) {
985
+			return $this->{$class_name};
986
+		}
987
+		if ($class_prefix === 'addon' && $this->addons->has($class_name)) {
988
+			return $this->addons->get($class_name);
989
+		}
990
+		$object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
991
+		if ($this->LIB->has($object_identifier)) {
992
+			return $this->LIB->get($object_identifier);
993
+		}
994
+		foreach ($this->LIB as $key => $object) {
995
+			if (
996
+				// request does not contain new arguments and therefore no args identifier
997
+				! $this->object_identifier->hasArguments($object_identifier)
998
+				// but previously cached class with args was found
999
+				&& $this->object_identifier->fqcnMatchesObjectIdentifier($class_name, $key)
1000
+			) {
1001
+				return $object;
1002
+			}
1003
+		}
1004
+		return null;
1005
+	}
1006
+
1007
+
1008
+	/**
1009
+	 * removes a cached version of the requested class
1010
+	 *
1011
+	 * @param string  $class_name
1012
+	 * @param boolean $addon
1013
+	 * @param array   $arguments
1014
+	 * @return boolean
1015
+	 */
1016
+	public function clear_cached_class(
1017
+		string $class_name,
1018
+		bool $addon = false,
1019
+		array $arguments = []
1020
+	): bool {
1021
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
1022
+		// check if class has already been loaded, and return it if it has been
1023
+		if (isset($this->{$class_abbreviation}) && ! $this->{$class_abbreviation} instanceof InterminableInterface) {
1024
+			$this->{$class_abbreviation} = null;
1025
+			return true;
1026
+		}
1027
+		$class_name = str_replace('\\', '_', $class_name);
1028
+		if (isset($this->{$class_name}) && ! $this->{$class_name} instanceof InterminableInterface) {
1029
+			$this->{$class_name} = null;
1030
+			return true;
1031
+		}
1032
+		if ($addon && $this->addons->has($class_name)) {
1033
+			$this->addons->remove($class_name);
1034
+			return true;
1035
+		}
1036
+		$object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
1037
+		if (
1038
+			$this->LIB->has($object_identifier)
1039
+			&& ! $this->LIB->get($object_identifier) instanceof InterminableInterface
1040
+		) {
1041
+			$this->LIB->remove($object_identifier);
1042
+			return true;
1043
+		}
1044
+		return false;
1045
+	}
1046
+
1047
+
1048
+	/**
1049
+	 * _set_cached_class
1050
+	 * attempts to cache the instantiated class locally
1051
+	 * in one of the following places, in the following order:
1052
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1053
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1054
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1055
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1056
+	 *
1057
+	 * @param object $class_obj
1058
+	 * @param string $class_name
1059
+	 * @param string $class_prefix
1060
+	 * @param bool   $from_db
1061
+	 * @param array  $arguments
1062
+	 * @return void
1063
+	 */
1064
+	protected function _set_cached_class(
1065
+		$class_obj,
1066
+		string $class_name,
1067
+		string $class_prefix = '',
1068
+		bool $from_db = false,
1069
+		array $arguments = []
1070
+	) {
1071
+		if ($class_name === 'EE_Registry' || empty($class_obj)) {
1072
+			return;
1073
+		}
1074
+		// return newly instantiated class
1075
+		$class_abbreviation = $this->get_class_abbreviation($class_name, '');
1076
+		if ($class_abbreviation) {
1077
+			$this->{$class_abbreviation} = $class_obj;
1078
+			return;
1079
+		}
1080
+		$class_name = str_replace('\\', '_', $class_name);
1081
+		if (property_exists($this, $class_name)) {
1082
+			$this->{$class_name} = $class_obj;
1083
+			return;
1084
+		}
1085
+		if ($class_prefix === 'addon') {
1086
+			$this->addons->add($class_name, $class_obj);
1087
+			return;
1088
+		}
1089
+		if (! $from_db) {
1090
+			$class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1091
+			$this->LIB->add($class_name, $class_obj);
1092
+		}
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * attempts to find a full valid filepath for the requested class.
1098
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
1099
+	 * then returns that path if the target file has been found and is readable
1100
+	 *
1101
+	 * @param string $class_name
1102
+	 * @param string $type
1103
+	 * @param array  $file_paths
1104
+	 * @return string | bool
1105
+	 */
1106
+	protected function _resolve_path(string $class_name, string $type = '', array $file_paths = [])
1107
+	{
1108
+		// make sure $file_paths is an array
1109
+		$file_paths = is_array($file_paths)
1110
+			? $file_paths
1111
+			: [$file_paths];
1112
+		// cycle thru paths
1113
+		foreach ($file_paths as $key => $file_path) {
1114
+			// convert all separators to proper /, if no filepath, then use EE_CLASSES
1115
+			$file_path = $file_path
1116
+				? str_replace(['/', '\\'], '/', $file_path)
1117
+				: EE_CLASSES;
1118
+			// prep file type
1119
+			$type = ! empty($type)
1120
+				? trim($type, '.') . '.'
1121
+				: '';
1122
+			// build full file path
1123
+			$file_paths[ $key ] = rtrim($file_path, '/') . '/' . $class_name . '.' . $type . 'php';
1124
+			// does the file exist and can be read ?
1125
+			if (is_readable($file_paths[ $key ])) {
1126
+				return $file_paths[ $key ];
1127
+			}
1128
+		}
1129
+		return false;
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * basically just performs a require_once()
1135
+	 * but with some error handling
1136
+	 *
1137
+	 * @param string $path
1138
+	 * @param string $class_name
1139
+	 * @param string $type
1140
+	 * @param array  $file_paths
1141
+	 * @return bool
1142
+	 * @throws EE_Error
1143
+	 * @throws ReflectionException
1144
+	 */
1145
+	protected function _require_file(string $path, string $class_name, string $type = '', array $file_paths = []): bool
1146
+	{
1147
+		$this->resolve_legacy_class_parent($class_name);
1148
+		// don't give up! you gotta...
1149
+		try {
1150
+			// does the file exist and can it be read ?
1151
+			if (! $path) {
1152
+				// just in case the file has already been autoloaded,
1153
+				// but discrepancies in the naming schema are preventing it from
1154
+				// being loaded via one of the EE_Registry::load_*() methods,
1155
+				// then let's try one last hail mary before throwing an exception
1156
+				// and call class_exists() again, but with autoloading turned ON
1157
+				if (class_exists($class_name)) {
1158
+					return true;
1159
+				}
1160
+				// so sorry, can't find the file
1161
+				throw new EE_Error(
1162
+					sprintf(
1163
+						esc_html__(
1164
+							'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
1165
+							'event_espresso'
1166
+						),
1167
+						trim($type, '.'),
1168
+						$class_name,
1169
+						'<br />' . implode(',<br />', $file_paths)
1170
+					)
1171
+				);
1172
+			}
1173
+			// get the file
1174
+			require_once($path);
1175
+			// if the class isn't already declared somewhere
1176
+			if (class_exists($class_name, false) === false) {
1177
+				// so sorry, not a class
1178
+				throw new EE_Error(
1179
+					sprintf(
1180
+						esc_html__(
1181
+							'The %s file %s does not appear to contain the %s Class.',
1182
+							'event_espresso'
1183
+						),
1184
+						$type,
1185
+						$path,
1186
+						$class_name
1187
+					)
1188
+				);
1189
+			}
1190
+		} catch (EE_Error $e) {
1191
+			$e->get_error();
1192
+			return false;
1193
+		}
1194
+		return true;
1195
+	}
1196
+
1197
+
1198
+	/**
1199
+	 * Some of our legacy classes that extended a parent class would simply use a require() statement
1200
+	 * before their class declaration in order to ensure that the parent class was loaded.
1201
+	 * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1202
+	 * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1203
+	 *
1204
+	 * @param string $class_name
1205
+	 */
1206
+	protected function resolve_legacy_class_parent(string $class_name = '')
1207
+	{
1208
+		try {
1209
+			$legacy_parent_class_map = [
1210
+				'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1211
+			];
1212
+			if (isset($legacy_parent_class_map[ $class_name ])) {
1213
+				require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1214
+			}
1215
+		} catch (Exception $exception) {
1216
+		}
1217
+	}
1218
+
1219
+
1220
+	/**
1221
+	 * _create_object
1222
+	 * Attempts to instantiate the requested class via any of the
1223
+	 * commonly used instantiation methods employed throughout EE.
1224
+	 * The priority for instantiation is as follows:
1225
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1226
+	 *        - model objects via their 'new_instance_from_db' method
1227
+	 *        - model objects via their 'new_instance' method
1228
+	 *        - "singleton" classes" via their 'instance' method
1229
+	 *    - standard instantiable classes via their __constructor
1230
+	 * Prior to instantiation, if the classname exists in the dependency_map,
1231
+	 * then the constructor for the requested class will be examined to determine
1232
+	 * if any dependencies exist, and if they can be injected.
1233
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1234
+	 *
1235
+	 * @param string $class_name
1236
+	 * @param array  $arguments
1237
+	 * @param string $type
1238
+	 * @param bool   $from_db
1239
+	 * @return null|object|bool
1240
+	 * @throws InvalidArgumentException
1241
+	 * @throws InvalidInterfaceException
1242
+	 * @throws EE_Error
1243
+	 * @throws ReflectionException
1244
+	 * @throws InvalidDataTypeException
1245
+	 */
1246
+	protected function _create_object(
1247
+		string $class_name,
1248
+		array $arguments = [],
1249
+		string $type = '',
1250
+		bool $from_db = false
1251
+	) {
1252
+		// create reflection
1253
+		$reflector = $this->mirror->getReflectionClass($class_name);
1254
+		// make sure arguments are an array
1255
+		$arguments = is_array($arguments)
1256
+			? $arguments
1257
+			: [$arguments];
1258
+		// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1259
+		// else wrap it in an additional array so that it doesn't get split into multiple parameters
1260
+		$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1261
+			? $arguments
1262
+			: [$arguments];
1263
+		// attempt to inject dependencies ?
1264
+		if ($this->_dependency_map->has($class_name)) {
1265
+			$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1266
+		}
1267
+		// instantiate the class if possible
1268
+		if ($reflector->isAbstract()) {
1269
+			// nothing to instantiate, loading file was enough
1270
+			// does not throw an exception so $instantiation_mode is unused
1271
+			// $instantiation_mode = "1) no constructor abstract class";
1272
+			return true;
1273
+		}
1274
+		if (
1275
+			empty($arguments)
1276
+			&& $this->mirror->getConstructorFromReflection($reflector) === null
1277
+			&& $reflector->isInstantiable()
1278
+		) {
1279
+			// no constructor = static methods only... nothing to instantiate, loading file was enough
1280
+			// $instantiation_mode = "2) no constructor but instantiable";
1281
+			return $reflector->newInstance();
1282
+		}
1283
+		if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1284
+			// $instantiation_mode = "3) new_instance_from_db()";
1285
+			return call_user_func_array([$class_name, 'new_instance_from_db'], $arguments);
1286
+		}
1287
+		if (method_exists($class_name, 'new_instance')) {
1288
+			// $instantiation_mode = "4) new_instance()";
1289
+			return call_user_func_array([$class_name, 'new_instance'], $arguments);
1290
+		}
1291
+		if (method_exists($class_name, 'instance')) {
1292
+			// $instantiation_mode = "5) instance()";
1293
+			return call_user_func_array([$class_name, 'instance'], $arguments);
1294
+		}
1295
+		if ($reflector->isInstantiable()) {
1296
+			$args_passed_count = count($arguments);
1297
+			$args_required_count = count($this->mirror->getRequiredParameters($class_name));
1298
+			if ($args_passed_count < $args_required_count) {
1299
+				throw new RuntimeException(
1300
+					sprintf(
1301
+						__(
1302
+							'Invalid arguments supplied for the %1$s class, %2$s were required but %3$s were passed.',
1303
+							'event_espresso'
1304
+						),
1305
+						$class_name,
1306
+						$args_required_count,
1307
+						$args_passed_count
1308
+					)
1309
+				);
1310
+			}
1311
+			// $instantiation_mode = "6) constructor";
1312
+			return $reflector->newInstanceArgs($arguments);
1313
+		}
1314
+		// heh ? something's not right !
1315
+		throw new EE_Error(
1316
+			sprintf(
1317
+				esc_html__('The %s file %s could not be instantiated.', 'event_espresso'),
1318
+				$type,
1319
+				$class_name
1320
+			)
1321
+		);
1322
+	}
1323
+
1324
+
1325
+	/**
1326
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1327
+	 * @param array $array
1328
+	 * @return bool
1329
+	 */
1330
+	protected function _array_is_numerically_and_sequentially_indexed(array $array): bool
1331
+	{
1332
+		return empty($array) || array_keys($array) === range(0, count($array) - 1);
1333
+	}
1334
+
1335
+
1336
+	/**
1337
+	 * _resolve_dependencies
1338
+	 * examines the constructor for the requested class to determine
1339
+	 * if any dependencies exist, and if they can be injected.
1340
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1341
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
1342
+	 * For example:
1343
+	 *        if attempting to load a class "Foo" with the following constructor:
1344
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
1345
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
1346
+	 *        but only IF they are NOT already present in the incoming arguments array,
1347
+	 *        and the correct classes can be loaded
1348
+	 *
1349
+	 * @param ReflectionClass $reflector
1350
+	 * @param string          $class_name
1351
+	 * @param array           $arguments
1352
+	 * @return array
1353
+	 * @throws InvalidArgumentException
1354
+	 * @throws InvalidDataTypeException
1355
+	 * @throws InvalidInterfaceException
1356
+	 * @throws ReflectionException
1357
+	 */
1358
+	protected function _resolve_dependencies(
1359
+		ReflectionClass $reflector,
1360
+		string $class_name,
1361
+		array $arguments = []
1362
+	): array {
1363
+		// let's examine the constructor
1364
+		$constructor = $this->mirror->getConstructorFromReflection($reflector);
1365
+		// whu? huh? nothing?
1366
+		if (! $constructor) {
1367
+			return $arguments;
1368
+		}
1369
+		// get constructor parameters
1370
+		$params = $this->mirror->getParametersFromReflection($reflector);
1371
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1372
+		$argument_keys = array_keys($arguments);
1373
+		// now loop thru all of the constructors expected parameters
1374
+		foreach ($params as $index => $param) {
1375
+			try {
1376
+				// is this a dependency for a specific class ?
1377
+				$param_class = $this->mirror->getParameterClassName($param, $class_name, $index);
1378
+			} catch (ReflectionException $exception) {
1379
+				// uh-oh... most likely a legacy class that has not been autoloaded
1380
+				// let's try to derive the classname from what we have now
1381
+				// and hope that the property var name is close to the class name
1382
+				$param_class = $param->getName();
1383
+				$param_class = str_replace('_', ' ', $param_class);
1384
+				$param_class = ucwords($param_class);
1385
+				$param_class = str_replace(' ', '_', $param_class);
1386
+			}
1387
+			// BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1388
+			$param_class = $this->class_cache->getFqnForAlias($param_class, $class_name);
1389
+			if (
1390
+				// param is not even a class
1391
+				($param_class === null || $this->parameterIsPrimitive($param_class))
1392
+				// and something already exists in the incoming arguments for this param
1393
+				&& array_key_exists($index, $argument_keys)
1394
+				&& isset($arguments[ $argument_keys[ $index ] ])
1395
+			) {
1396
+				// so let's skip this argument and move on to the next
1397
+				continue;
1398
+			}
1399
+			// parameter is type hinted as a class
1400
+			if ($param_class !== null) {
1401
+				// parameter exists as an incoming argument, AND it's the correct class
1402
+				if (
1403
+					array_key_exists($index, $argument_keys)
1404
+					&& isset($arguments[ $argument_keys[ $index ] ])
1405
+					&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1406
+				) {
1407
+					// skip this argument and move on to the next
1408
+					continue;
1409
+				}
1410
+				// parameter should be injected
1411
+				if ($this->_dependency_map->has_dependency_for_class($class_name, $param_class)) {
1412
+					$arguments = $this->_resolve_dependency(
1413
+						$class_name,
1414
+						$param_class,
1415
+						$arguments,
1416
+						$index
1417
+					);
1418
+				}
1419
+			}
1420
+			if (empty($arguments[ $index ])) {
1421
+				$default_value = $this->mirror->getParameterDefaultValue(
1422
+					$param,
1423
+					$class_name,
1424
+					$index
1425
+				);
1426
+				// if there's no default value, and the incoming argument is an array (albeit empty), then use that
1427
+				$arguments[ $index ] = $default_value === null
1428
+									   && isset($arguments[ $index ])
1429
+									   && is_array($arguments[ $index ])
1430
+					? $arguments[ $index ]
1431
+					: $default_value;
1432
+			}
1433
+		}
1434
+		return $arguments;
1435
+	}
1436
+
1437
+
1438
+	/**
1439
+	 * @param string $class_name
1440
+	 * @param string $param_class
1441
+	 * @param array  $arguments
1442
+	 * @param mixed  $index
1443
+	 * @return array
1444
+	 * @throws InvalidArgumentException
1445
+	 * @throws InvalidInterfaceException
1446
+	 * @throws InvalidDataTypeException
1447
+	 */
1448
+	protected function _resolve_dependency(string $class_name, string $param_class, array $arguments, $index): array
1449
+	{
1450
+		$dependency = null;
1451
+		// should dependency be loaded from cache ?
1452
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1453
+			$class_name,
1454
+			$param_class
1455
+		);
1456
+		$cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1457
+		// we might have a dependency...
1458
+		// let's MAYBE try and find it in our cache if that's what's been requested
1459
+		$cached_class = $cache_on
1460
+			? $this->_get_cached_class($param_class)
1461
+			: null;
1462
+		// and grab it if it exists
1463
+		if ($cached_class instanceof $param_class) {
1464
+			$dependency = $cached_class;
1465
+		} elseif ($param_class !== $class_name) {
1466
+			// obtain the loader method from the dependency map
1467
+			$loader = $this->_dependency_map->class_loader($param_class);
1468
+			// is loader a custom closure ?
1469
+			if ($loader instanceof Closure) {
1470
+				$dependency = $loader($arguments);
1471
+			} else {
1472
+				// set the cache on property for the recursive loading call
1473
+				$this->_cache_on = $cache_on;
1474
+				// if not, then let's try and load it via the registry
1475
+				if ($loader && method_exists($this, $loader)) {
1476
+					$dependency = $this->{$loader}($param_class);
1477
+				} else {
1478
+					$dependency = LoaderFactory::getLoader()->load(
1479
+						$param_class,
1480
+						[],
1481
+						$cache_on
1482
+					);
1483
+				}
1484
+			}
1485
+		}
1486
+		// did we successfully find the correct dependency ?
1487
+		if ($dependency instanceof $param_class) {
1488
+			// then let's inject it into the incoming array of arguments at the correct location
1489
+			$arguments[ $index ] = $dependency;
1490
+		}
1491
+		return $arguments;
1492
+	}
1493
+
1494
+
1495
+	/**
1496
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1497
+	 *
1498
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1499
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1500
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1501
+	 * @param array  $arguments
1502
+	 * @return mixed
1503
+	 */
1504
+	public static function factory(string $classname, array $arguments = [])
1505
+	{
1506
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1507
+		if ($loader instanceof Closure) {
1508
+			return $loader($arguments);
1509
+		}
1510
+		if (method_exists(self::instance(), $loader)) {
1511
+			return self::instance()->{$loader}($classname, $arguments);
1512
+		}
1513
+		return null;
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * Gets the addon by its class name
1519
+	 *
1520
+	 * @param string $class_name
1521
+	 * @return EE_Addon
1522
+	 */
1523
+	public function getAddon(string $class_name): ?EE_Addon
1524
+	{
1525
+		$class_name = str_replace('\\', '_', $class_name);
1526
+		return $this->addons->{$class_name} ?? null;
1527
+	}
1528
+
1529
+
1530
+	/**
1531
+	 * removes the addon from the internal cache
1532
+	 *
1533
+	 * @param string $class_name
1534
+	 * @return void
1535
+	 */
1536
+	public function removeAddon(string $class_name)
1537
+	{
1538
+		$class_name = str_replace('\\', '_', $class_name);
1539
+		$this->addons->remove($class_name);
1540
+	}
1541
+
1542
+
1543
+	/**
1544
+	 * Gets the addon by its name/slug (not classname. For that, just
1545
+	 * use the get_addon() method above
1546
+	 *
1547
+	 * @param string $name
1548
+	 * @return EE_Addon
1549
+	 */
1550
+	public function get_addon_by_name(string $name): ?EE_Addon
1551
+	{
1552
+		foreach ($this->addons as $addon) {
1553
+			if ($addon->name() === $name) {
1554
+				return $addon;
1555
+			}
1556
+		}
1557
+		return null;
1558
+	}
1559
+
1560
+
1561
+	/**
1562
+	 * Gets an array of all the registered addons, where the keys are their names.
1563
+	 * (ie, what each returns for their name() function)
1564
+	 * They're already available on EE_Registry::instance()->addons as properties,
1565
+	 * where each property's name is the addon's classname,
1566
+	 * So if you just want to get the addon by classname,
1567
+	 * OR use the get_addon() method above.
1568
+	 * PLEASE  NOTE:
1569
+	 * addons with Fully Qualified Class Names
1570
+	 * have had the namespace separators converted to underscores,
1571
+	 * so a classname like Fully\Qualified\ClassName
1572
+	 * would have been converted to Fully_Qualified_ClassName
1573
+	 *
1574
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1575
+	 */
1576
+	public function get_addons_by_name(): array
1577
+	{
1578
+		$addons = [];
1579
+		foreach ($this->addons as $addon) {
1580
+			$addons[ $addon->name() ] = $addon;
1581
+		}
1582
+		return $addons;
1583
+	}
1584
+
1585
+
1586
+	/**
1587
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1588
+	 * a stale copy of it around
1589
+	 *
1590
+	 * @param string $model_name
1591
+	 * @return EEM_Base
1592
+	 * @throws EE_Error
1593
+	 * @throws ReflectionException
1594
+	 */
1595
+	public function reset_model(string $model_name): ?EEM_Base
1596
+	{
1597
+		$model_class_name = strpos($model_name, 'EEM_') !== 0
1598
+			? "EEM_$model_name"
1599
+			: $model_name;
1600
+		if (! $this->LIB->has($model_class_name)) {
1601
+			return null;
1602
+		}
1603
+		$model = $this->LIB->get($model_class_name);
1604
+		if (! $model instanceof EEM_Base) {
1605
+			return null;
1606
+		}
1607
+		// get that model reset it and make sure we nuke the old reference to it
1608
+		if ($model instanceof $model_class_name && is_callable([$model_class_name, 'reset'])) {
1609
+			$this->LIB->remove($model_class_name);
1610
+			$this->LIB->add($model_class_name, $model->reset());
1611
+		} else {
1612
+			throw new EE_Error(
1613
+				sprintf(
1614
+					esc_html__('Model %s does not have a method "reset"', 'event_espresso'),
1615
+					$model_name
1616
+				)
1617
+			);
1618
+		}
1619
+		return $model;
1620
+	}
1621
+
1622
+
1623
+	/**
1624
+	 * Resets the registry.
1625
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when
1626
+	 * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1627
+	 * - $_dependency_map
1628
+	 * - $_class_abbreviations
1629
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1630
+	 * - $REQ:  Still on the same request so no need to change.
1631
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1632
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1633
+	 * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1634
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1635
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1636
+	 *             switch or on the restore.
1637
+	 * - $modules
1638
+	 * - $shortcodes
1639
+	 * - $widgets
1640
+	 *
1641
+	 * @param boolean $hard             [deprecated]
1642
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1643
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1644
+	 *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1645
+	 * @param bool    $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1646
+	 *                                  client
1647
+	 *                                  code instead can just change the model context to a different blog id if
1648
+	 *                                  necessary
1649
+	 * @return EE_Registry
1650
+	 * @throws EE_Error
1651
+	 * @throws ReflectionException
1652
+	 */
1653
+	public static function reset(bool $hard = false, bool $reinstantiate = true, bool $reset_models = true): EE_Registry
1654
+	{
1655
+		$instance            = self::instance();
1656
+		$instance->_cache_on = true;
1657
+		// reset some "special" classes
1658
+		EEH_Activation::reset();
1659
+		$hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1660
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1661
+		$instance->CART = null;
1662
+		$instance->MRM = null;
1663
+		// messages reset
1664
+		EED_Messages::reset();
1665
+		// handle of objects cached on LIB
1666
+		foreach (['LIB', 'modules'] as $cache) {
1667
+			foreach ($instance->{$cache} as $class_name => $class) {
1668
+				if (self::_reset_and_unset_object($class, $reset_models)) {
1669
+					unset($instance->{$cache}->{$class_name});
1670
+				}
1671
+			}
1672
+		}
1673
+		return $instance;
1674
+	}
1675
+
1676
+
1677
+	/**
1678
+	 * if passed object implements ResettableInterface, then call it's reset() method
1679
+	 * if passed object implements InterminableInterface, then return false,
1680
+	 * to indicate that it should NOT be cleared from the Registry cache
1681
+	 *
1682
+	 * @param      $object
1683
+	 * @param bool $reset_models
1684
+	 * @return bool returns true if cached object should be unset
1685
+	 * @throws EE_Error
1686
+	 * @throws ReflectionException
1687
+	 */
1688
+	private static function _reset_and_unset_object($object, bool $reset_models): bool
1689
+	{
1690
+		if (! is_object($object)) {
1691
+			// don't unset anything that's not an object
1692
+			return false;
1693
+		}
1694
+		if ($object instanceof InterminableInterface) {
1695
+			// don't unset anything that's not terminable
1696
+			return false;
1697
+		}
1698
+		if ($object instanceof EED_Module) {
1699
+			$object::reset();
1700
+			// don't unset modules
1701
+			return false;
1702
+		}
1703
+		if ($object instanceof ResettableInterface) {
1704
+			if ($object instanceof EEM_Base) {
1705
+				if ($reset_models) {
1706
+					$object->reset();
1707
+					return true;
1708
+				}
1709
+				return false;
1710
+			}
1711
+			$object->reset();
1712
+			return true;
1713
+		}
1714
+		// at least clear object from cache
1715
+		self::$_instance->clear_cached_class(get_class($object));
1716
+		return false;
1717
+	}
1718
+
1719
+
1720
+	/**
1721
+	 * Gets all the custom post type models defined
1722
+	 *
1723
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1724
+	 */
1725
+	public function cpt_models(): array
1726
+	{
1727
+		$cpt_models = [];
1728
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1729
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1730
+				$cpt_models[ $short_name ] = $classname;
1731
+			}
1732
+		}
1733
+		return $cpt_models;
1734
+	}
1735
+
1736
+
1737
+	/**
1738
+	 * @return EE_Config
1739
+	 */
1740
+	public static function CFG(): EE_Config
1741
+	{
1742
+		return self::instance()->CFG;
1743
+	}
1744
+
1745
+
1746
+	/**
1747
+	 * @param string $class_name
1748
+	 * @return ReflectionClass
1749
+	 * @throws ReflectionException
1750
+	 * @throws InvalidDataTypeException
1751
+	 * @deprecated 4.9.62.p
1752
+	 */
1753
+	public function get_ReflectionClass(string $class_name): ReflectionClass
1754
+	{
1755
+		return $this->mirror->getReflectionClass($class_name);
1756
+	}
1757
+
1758
+	private function parameterIsPrimitive(?string $param_class): bool
1759
+	{
1760
+		return in_array(
1761
+			$param_class,
1762
+			[
1763
+				'array',
1764
+				'bool',
1765
+				'float',
1766
+				'int',
1767
+				'string',
1768
+			]
1769
+		);
1770
+	}
1771 1771
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         foreach ($i18n_js_strings as $key => $value) {
309 309
             if (is_scalar($value)) {
310 310
                 $decoded_value           = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
311
-                $i18n_js_strings[ $key ] = wp_strip_all_tags($decoded_value);
311
+                $i18n_js_strings[$key] = wp_strip_all_tags($decoded_value);
312 312
             }
313 313
         }
314 314
         return $i18n_js_strings;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     public static function localize_i18n_js_strings(): string
324 324
     {
325 325
         $i18n_js_strings = EE_Registry::sanitize_i18n_js_strings();
326
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
326
+        return '/* <![CDATA[ */ var eei18n = '.wp_json_encode($i18n_js_strings).'; /* ]]> */';
327 327
     }
328 328
 
329 329
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             $module_class = get_class($module);
343 343
             $this->modules->add($module_class, $module);
344 344
         } else {
345
-            if (! class_exists('EE_Module_Request_Router', false)) {
345
+            if ( ! class_exists('EE_Module_Request_Router', false)) {
346 346
                 $this->load_core('Module_Request_Router');
347 347
             }
348 348
             EE_Module_Request_Router::module_factory($module);
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
                 EE_CORE,
382 382
                 EE_ADMIN,
383 383
                 EE_CPTS,
384
-                EE_CORE . 'CPTs/',
385
-                EE_CORE . 'data_migration_scripts/',
386
-                EE_CORE . 'request_stack/',
387
-                EE_CORE . 'middleware/',
384
+                EE_CORE.'CPTs/',
385
+                EE_CORE.'data_migration_scripts/',
386
+                EE_CORE.'request_stack/',
387
+                EE_CORE.'middleware/',
388 388
             ]
389 389
         );
390 390
         // retrieve instantiated class
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         $service_paths = (array) apply_filters(
421 421
             'FHEE__EE_Registry__load_service__service_paths',
422 422
             [
423
-                EE_CORE . 'services/',
423
+                EE_CORE.'services/',
424 424
             ]
425 425
         );
426 426
         // retrieve instantiated class
@@ -560,10 +560,10 @@  discard block
 block discarded – undo
560 560
     {
561 561
         $paths = [
562 562
             EE_LIBRARIES,
563
-            EE_LIBRARIES . 'messages/',
564
-            EE_LIBRARIES . 'shortcodes/',
565
-            EE_LIBRARIES . 'qtips/',
566
-            EE_LIBRARIES . 'payment_methods/',
563
+            EE_LIBRARIES.'messages/',
564
+            EE_LIBRARIES.'shortcodes/',
565
+            EE_LIBRARIES.'qtips/',
566
+            EE_LIBRARIES.'payment_methods/',
567 567
         ];
568 568
         // retrieve instantiated class
569 569
         return $this->_load(
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
     public function load_model_class(string $class_name, $arguments = [], bool $load_only = true)
633 633
     {
634 634
         $paths = [
635
-            EE_MODELS . 'fields/',
636
-            EE_MODELS . 'helpers/',
637
-            EE_MODELS . 'relations/',
638
-            EE_MODELS . 'strategies/',
635
+            EE_MODELS.'fields/',
636
+            EE_MODELS.'helpers/',
637
+            EE_MODELS.'relations/',
638
+            EE_MODELS.'strategies/',
639 639
         ];
640 640
         // retrieve instantiated class
641 641
         return $this->_load(
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
      */
660 660
     public function is_model_name(string $model_name): bool
661 661
     {
662
-        return isset($this->models[ $model_name ]);
662
+        return isset($this->models[$model_name]);
663 663
     }
664 664
 
665 665
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
                 return $cached_class;
792 792
             }
793 793
         }                                                           // obtain the loader method from the dependency map
794
-        $loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
794
+        $loader = $this->_dependency_map->class_loader($class_name); // instantiate the requested object
795 795
         if ($loader instanceof Closure) {
796 796
             $class_obj = $loader($arguments);
797 797
         } else {
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
             case 1:
834 834
                 // if it's a FQCN then maybe the class is registered with a preceding \
835 835
                 $class_name = strpos($class_name, '\\') !== false
836
-                    ? '\\' . ltrim($class_name, '\\')
836
+                    ? '\\'.ltrim($class_name, '\\')
837 837
                     : $class_name;
838 838
                 break;
839 839
             case 2:
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
         // strip php file extension
888 888
         $class_name = str_replace('.php', '', trim($class_name));
889 889
         // does the class have a prefix ?
890
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
890
+        if ( ! empty($class_prefix) && $class_prefix !== 'addon') {
891 891
             // make sure $class_prefix is uppercase
892 892
             $class_prefix = strtoupper(trim($class_prefix));
893 893
             // add class prefix ONCE!!!
894
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
894
+            $class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
895 895
         }
896 896
         $class_name   = $this->class_cache->getFqnForAlias($class_name);
897 897
         $class_exists = class_exists($class_name, false);
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
             }
912 912
         }
913 913
         // if the class doesn't already exist.. then we need to try and find the file and load it
914
-        if (! $class_exists) {
914
+        if ( ! $class_exists) {
915 915
             // get full path to file
916 916
             $path = $this->_resolve_path($class_name, $type, $file_paths);
917 917
             // load the file
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
                 return $loaded;
923 923
             }
924 924
             // if an object was expected but loading failed, then return nothing
925
-            if (! $loaded) {
925
+            if ( ! $loaded) {
926 926
                 return null;
927 927
             }
928 928
         }
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
      */
951 951
     protected function get_class_abbreviation(string $class_name, string $default = 'FANCY_BATMAN_PANTS')
952 952
     {
953
-        return $this->_class_abbreviations[ $class_name ] ?? $default;
953
+        return $this->_class_abbreviations[$class_name] ?? $default;
954 954
     }
955 955
 
956 956
 
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
             $this->addons->add($class_name, $class_obj);
1087 1087
             return;
1088 1088
         }
1089
-        if (! $from_db) {
1089
+        if ( ! $from_db) {
1090 1090
             $class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1091 1091
             $this->LIB->add($class_name, $class_obj);
1092 1092
         }
@@ -1117,13 +1117,13 @@  discard block
 block discarded – undo
1117 1117
                 : EE_CLASSES;
1118 1118
             // prep file type
1119 1119
             $type = ! empty($type)
1120
-                ? trim($type, '.') . '.'
1120
+                ? trim($type, '.').'.'
1121 1121
                 : '';
1122 1122
             // build full file path
1123
-            $file_paths[ $key ] = rtrim($file_path, '/') . '/' . $class_name . '.' . $type . 'php';
1123
+            $file_paths[$key] = rtrim($file_path, '/').'/'.$class_name.'.'.$type.'php';
1124 1124
             // does the file exist and can be read ?
1125
-            if (is_readable($file_paths[ $key ])) {
1126
-                return $file_paths[ $key ];
1125
+            if (is_readable($file_paths[$key])) {
1126
+                return $file_paths[$key];
1127 1127
             }
1128 1128
         }
1129 1129
         return false;
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
         // don't give up! you gotta...
1149 1149
         try {
1150 1150
             // does the file exist and can it be read ?
1151
-            if (! $path) {
1151
+            if ( ! $path) {
1152 1152
                 // just in case the file has already been autoloaded,
1153 1153
                 // but discrepancies in the naming schema are preventing it from
1154 1154
                 // being loaded via one of the EE_Registry::load_*() methods,
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
                         ),
1167 1167
                         trim($type, '.'),
1168 1168
                         $class_name,
1169
-                        '<br />' . implode(',<br />', $file_paths)
1169
+                        '<br />'.implode(',<br />', $file_paths)
1170 1170
                     )
1171 1171
                 );
1172 1172
             }
@@ -1209,8 +1209,8 @@  discard block
 block discarded – undo
1209 1209
             $legacy_parent_class_map = [
1210 1210
                 'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1211 1211
             ];
1212
-            if (isset($legacy_parent_class_map[ $class_name ])) {
1213
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1212
+            if (isset($legacy_parent_class_map[$class_name])) {
1213
+                require_once EE_PLUGIN_DIR_PATH.$legacy_parent_class_map[$class_name];
1214 1214
             }
1215 1215
         } catch (Exception $exception) {
1216 1216
         }
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
         // let's examine the constructor
1364 1364
         $constructor = $this->mirror->getConstructorFromReflection($reflector);
1365 1365
         // whu? huh? nothing?
1366
-        if (! $constructor) {
1366
+        if ( ! $constructor) {
1367 1367
             return $arguments;
1368 1368
         }
1369 1369
         // get constructor parameters
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
                 ($param_class === null || $this->parameterIsPrimitive($param_class))
1392 1392
                 // and something already exists in the incoming arguments for this param
1393 1393
                 && array_key_exists($index, $argument_keys)
1394
-                && isset($arguments[ $argument_keys[ $index ] ])
1394
+                && isset($arguments[$argument_keys[$index]])
1395 1395
             ) {
1396 1396
                 // so let's skip this argument and move on to the next
1397 1397
                 continue;
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
                 // parameter exists as an incoming argument, AND it's the correct class
1402 1402
                 if (
1403 1403
                     array_key_exists($index, $argument_keys)
1404
-                    && isset($arguments[ $argument_keys[ $index ] ])
1405
-                    && $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1404
+                    && isset($arguments[$argument_keys[$index]])
1405
+                    && $arguments[$argument_keys[$index]] instanceof $param_class
1406 1406
                 ) {
1407 1407
                     // skip this argument and move on to the next
1408 1408
                     continue;
@@ -1417,17 +1417,17 @@  discard block
 block discarded – undo
1417 1417
                     );
1418 1418
                 }
1419 1419
             }
1420
-            if (empty($arguments[ $index ])) {
1420
+            if (empty($arguments[$index])) {
1421 1421
                 $default_value = $this->mirror->getParameterDefaultValue(
1422 1422
                     $param,
1423 1423
                     $class_name,
1424 1424
                     $index
1425 1425
                 );
1426 1426
                 // if there's no default value, and the incoming argument is an array (albeit empty), then use that
1427
-                $arguments[ $index ] = $default_value === null
1428
-                                       && isset($arguments[ $index ])
1429
-                                       && is_array($arguments[ $index ])
1430
-                    ? $arguments[ $index ]
1427
+                $arguments[$index] = $default_value === null
1428
+                                       && isset($arguments[$index])
1429
+                                       && is_array($arguments[$index])
1430
+                    ? $arguments[$index]
1431 1431
                     : $default_value;
1432 1432
             }
1433 1433
         }
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
         // did we successfully find the correct dependency ?
1487 1487
         if ($dependency instanceof $param_class) {
1488 1488
             // then let's inject it into the incoming array of arguments at the correct location
1489
-            $arguments[ $index ] = $dependency;
1489
+            $arguments[$index] = $dependency;
1490 1490
         }
1491 1491
         return $arguments;
1492 1492
     }
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
     {
1578 1578
         $addons = [];
1579 1579
         foreach ($this->addons as $addon) {
1580
-            $addons[ $addon->name() ] = $addon;
1580
+            $addons[$addon->name()] = $addon;
1581 1581
         }
1582 1582
         return $addons;
1583 1583
     }
@@ -1597,11 +1597,11 @@  discard block
 block discarded – undo
1597 1597
         $model_class_name = strpos($model_name, 'EEM_') !== 0
1598 1598
             ? "EEM_$model_name"
1599 1599
             : $model_name;
1600
-        if (! $this->LIB->has($model_class_name)) {
1600
+        if ( ! $this->LIB->has($model_class_name)) {
1601 1601
             return null;
1602 1602
         }
1603 1603
         $model = $this->LIB->get($model_class_name);
1604
-        if (! $model instanceof EEM_Base) {
1604
+        if ( ! $model instanceof EEM_Base) {
1605 1605
             return null;
1606 1606
         }
1607 1607
         // get that model reset it and make sure we nuke the old reference to it
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
      */
1688 1688
     private static function _reset_and_unset_object($object, bool $reset_models): bool
1689 1689
     {
1690
-        if (! is_object($object)) {
1690
+        if ( ! is_object($object)) {
1691 1691
             // don't unset anything that's not an object
1692 1692
             return false;
1693 1693
         }
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
         $cpt_models = [];
1728 1728
         foreach ($this->non_abstract_db_models as $short_name => $classname) {
1729 1729
             if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1730
-                $cpt_models[ $short_name ] = $classname;
1730
+                $cpt_models[$short_name] = $classname;
1731 1731
             }
1732 1732
         }
1733 1733
         return $cpt_models;
Please login to merge, or discard this patch.