Completed
Push — develop ( b0603d...210c13 )
by
unknown
23:33 queued 03:35
created
trustedlogin/trustedlogin/client/src/Encryption.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 namespace GravityView\TrustedLogin;
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined('ABSPATH') ) {
16
+if ( ! defined( 'ABSPATH' ) ) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		}
144 144
 
145 145
 		try {
146
-			$hash_bin = sodium_crypto_generichash( $string, '', (int) $length );
146
+			$hash_bin = sodium_crypto_generichash( $string, '', (int)$length );
147 147
 			$hash     = sodium_bin2hex( $hash_bin );
148 148
 		} catch ( \TypeError $e ) {
149 149
 			return new WP_Error(
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 
252 252
 		if ( is_wp_error( $response_json ) ) {
253 253
 
254
-			if ( 'not_found' == $response_json->get_error_code() ){
254
+			if ( 'not_found' == $response_json->get_error_code() ) {
255 255
 				return new WP_Error( 'not_found', __( 'Encryption key could not be fetched, Vendor site returned 404.', 'gravityview' ) );
256 256
 			}
257 257
 
258 258
 			return $response_json;
259 259
 		}
260 260
 
261
-		return $response_json['publicKey'];
261
+		return $response_json[ 'publicKey' ];
262 262
 	}
263 263
 
264 264
 	/**
@@ -366,6 +366,6 @@  discard block
 block discarded – undo
366 366
 			'privateKey' => sodium_crypto_box_secretkey( $aliceKeypair )
367 367
 		);
368 368
 
369
-		return (object) $alice_keys;
369
+		return (object)$alice_keys;
370 370
 	}
371 371
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
 
252 252
 		if ( is_wp_error( $response_json ) ) {
253 253
 
254
-			if ( 'not_found' == $response_json->get_error_code() ){
254
+			if ( 'not_found' == $response_json->get_error_code() ) {
255 255
 				return new WP_Error( 'not_found', __( 'Encryption key could not be fetched, Vendor site returned 404.', 'gravityview' ) );
256 256
 			}
257 257
 
Please login to merge, or discard this patch.
trustedlogin/trustedlogin/client/src/Remote.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 namespace GravityView\TrustedLogin;
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined('ABSPATH') ) {
16
+if ( ! defined( 'ABSPATH' ) ) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		);
150 150
 
151 151
 		if ( ! empty( $data ) && ! in_array( $method, array( 'GET', 'HEAD' ), true ) ) {
152
-			$request_options['body'] = wp_json_encode( $data );
152
+			$request_options[ 'body' ] = wp_json_encode( $data );
153 153
 		}
154 154
 
155 155
 		try {
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				return new WP_Error( 'invalid_response', esc_html__( 'Invalid response.', 'gravityview' ), $api_response );
262 262
 
263 263
 			default:
264
-				return (int) $response_code;
264
+				return (int)$response_code;
265 265
 		}
266 266
 	}
267 267
 
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
 			return new WP_Error( 'invalid_response', esc_html__( 'Invalid response.', 'gravityview' ), $response_body );
305 305
 		}
306 306
 
307
-		if ( isset( $response_json['errors'] ) ) {
307
+		if ( isset( $response_json[ 'errors' ] ) ) {
308 308
 
309 309
 			$errors = '';
310 310
 
311 311
 			// Multi-dimensional; we flatten.
312
-			foreach ( $response_json['errors'] as $key => $error ) {
313
-				$error  = is_array( $error ) ? reset( $error ) : $error;
312
+			foreach ( $response_json[ 'errors' ] as $key => $error ) {
313
+				$error = is_array( $error ) ? reset( $error ) : $error;
314 314
 				$errors .= $error;
315 315
 			}
316 316
 
317 317
 			return new WP_Error( 'errors_in_response', esc_html( $errors ), $response_body );
318 318
 		}
319 319
 
320
-		foreach ( (array) $required_keys as $required_key ) {
320
+		foreach ( (array)$required_keys as $required_key ) {
321 321
 			if ( ! isset( $response_json[ $required_key ] ) ) {
322 322
 				return new WP_Error( 'missing_required_key', sprintf( esc_html__( 'Invalid response. Missing key: %s', 'gravityview' ), $required_key ), $response_body );
323 323
 			}
Please login to merge, or discard this patch.
future/lib/class-gamajo-template-loader.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 		public function set_template_data( $data, $var_name = 'data' ) {
132 132
 			global $wp_query;
133 133
 
134
-			$wp_query->query_vars[ $var_name ] = (object) $data;
134
+			$wp_query->query_vars[ $var_name ] = (object)$data;
135 135
 
136 136
 			// Add $var_name to custom variable store if not default value.
137 137
 			if ( 'data' !== $var_name ) {
138
-				$this->template_data_var_names[] = $var_name;
138
+				$this->template_data_var_names[ ] = $var_name;
139 139
 			}
140 140
 
141 141
 			return $this;
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 		protected function get_template_file_names( $slug, $name ) {
179 179
 			$templates = array();
180 180
 			if ( isset( $name ) ) {
181
-				$templates[] = $slug . '-' . $name . '.php';
181
+				$templates[ ] = $slug . '-' . $name . '.php';
182 182
 			}
183
-			$templates[] = $slug . '.php';
183
+			$templates[ ] = $slug . '.php';
184 184
 
185 185
 			/**
186 186
 			 * Allow template choices to be filtered.
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 				$located = false;
227 227
 
228 228
 				// Remove empty entries.
229
-				$template_names = array_filter( (array) $template_names );
229
+				$template_names = array_filter( (array)$template_names );
230 230
 				$template_paths = $this->get_template_paths();
231 231
 
232 232
 				// Try to find a template file.
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 				}
247 247
 
248 248
 				// The templates weren't found; don't look this up again.
249
-				if( ! $located ) {
249
+				if ( ! $located ) {
250 250
 					$template_path_cache[ $this->filter_prefix ][ $cache_key ] = false;
251 251
 				}
252 252
 			}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
 			// Only add this conditionally, so non-child themes don't redundantly check active theme twice.
287 287
 			if ( get_stylesheet_directory() !== get_template_directory() ) {
288
-				$file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory;
288
+				$file_paths[ 1 ] = trailingslashit( get_stylesheet_directory() ) . $theme_directory;
289 289
 			}
290 290
 
291 291
 			/**
Please login to merge, or discard this patch.
includes/class-gravityview-bulk-actions.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 		$gv_bulk_action = false;
56 56
 
57
-		if( version_compare( GFForms::$version, '2.0', '>=' ) ) {
57
+		if ( version_compare( GFForms::$version, '2.0', '>=' ) ) {
58 58
 			$bulk_action = ( '-1' !== \GV\Utils::_POST( 'action' ) ) ? \GV\Utils::_POST( 'action' ) : \GV\Utils::_POST( 'action2' );
59 59
 		} else {
60 60
 			// GF 1.9.x - Bulk action 2 is the bottom bulk action select form.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		}
63 63
 
64 64
 		// Check the $bulk_action value against GV actions, see if they're the same. I hate strpos().
65
-		if( ! empty( $bulk_action ) && preg_match( '/^('. implode( '|', self::$bulk_action_prefixes ) .')/ism', $bulk_action ) ) {
65
+		if ( ! empty( $bulk_action ) && preg_match( '/^(' . implode( '|', self::$bulk_action_prefixes ) . ')/ism', $bulk_action ) ) {
66 66
 			$gv_bulk_action = $bulk_action;
67 67
 		}
68 68
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 		// gforms_entry_list is the nonce that confirms we're on the right page
88 88
 		// gforms_update_note is sent when bulk editing entry notes. We don't want to process then.
89
-		if ( $bulk_action && \GV\Utils::_POST( 'gforms_entry_list' ) && empty( $_POST['gforms_update_note'] ) ) {
89
+		if ( $bulk_action && \GV\Utils::_POST( 'gforms_entry_list' ) && empty( $_POST[ 'gforms_update_note' ] ) ) {
90 90
 
91 91
 			check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' );
92 92
 
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 			}
105 105
 
106 106
 			// All entries are set to be updated, not just the visible ones
107
-			if ( ! empty( $_POST['all_entries'] ) ) {
107
+			if ( ! empty( $_POST[ 'all_entries' ] ) ) {
108 108
 
109 109
 				// Convert the current entry search into GF-formatted search criteria
110 110
 				$search = array(
111
-					'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0,
112
-					'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '',
113
-					'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains',
111
+					'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0,
112
+					'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '',
113
+					'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains',
114 114
 				);
115 115
 
116 116
 				$search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id );
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			} else {
122 122
 
123 123
 				// Changed from 'lead' to 'entry' in 2.0
124
-				$entries = isset( $_POST['lead'] ) ? $_POST['lead'] : $_POST['entry'];
124
+				$entries = isset( $_POST[ 'lead' ] ) ? $_POST[ 'lead' ] : $_POST[ 'entry' ];
125 125
 
126 126
 			}
127 127
 
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 			$entry_count = count( $entries ) > 1 ? sprintf( __( '%d entries', 'gravityview' ), count( $entries ) ) : __( '1 entry', 'gravityview' );
134 134
 
135 135
 			switch ( $approved_status ) {
136
-				case self::$bulk_action_prefixes['approve']:
136
+				case self::$bulk_action_prefixes[ 'approve' ]:
137 137
 					GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::APPROVED, $form_id );
138 138
 					self::$bulk_update_message = sprintf( __( '%s approved.', 'gravityview' ), $entry_count );
139 139
 					break;
140
-				case self::$bulk_action_prefixes['unapprove']:
140
+				case self::$bulk_action_prefixes[ 'unapprove' ]:
141 141
 					GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::UNAPPROVED, $form_id );
142 142
 					self::$bulk_update_message = sprintf( __( '%s unapproved.', 'gravityview' ), $entry_count );
143 143
 					break;
144
-				case self::$bulk_action_prefixes['disapprove']:
144
+				case self::$bulk_action_prefixes[ 'disapprove' ]:
145 145
 					GravityView_Entry_Approval::update_bulk( $entries, GravityView_Entry_Approval_Status::DISAPPROVED, $form_id );
146 146
 					self::$bulk_update_message = sprintf( __( '%s disapproved.', 'gravityview' ), $entry_count );
147 147
 					break;
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
 		$bulk_actions = array(
165 165
 			'GravityView' => array(
166 166
 				array(
167
-					'label' => GravityView_Entry_Approval_Status::get_string('approved', 'action'),
168
-					'value' => sprintf( '%s-%d', self::$bulk_action_prefixes['approve'], $form_id ),
167
+					'label' => GravityView_Entry_Approval_Status::get_string( 'approved', 'action' ),
168
+					'value' => sprintf( '%s-%d', self::$bulk_action_prefixes[ 'approve' ], $form_id ),
169 169
 				),
170 170
 				array(
171
-					'label' => GravityView_Entry_Approval_Status::get_string('disapproved', 'action'),
172
-					'value' => sprintf( '%s-%d', self::$bulk_action_prefixes['disapprove'], $form_id ),
171
+					'label' => GravityView_Entry_Approval_Status::get_string( 'disapproved', 'action' ),
172
+					'value' => sprintf( '%s-%d', self::$bulk_action_prefixes[ 'disapprove' ], $form_id ),
173 173
 				),
174 174
 				array(
175
-					'label' => GravityView_Entry_Approval_Status::get_string('unapproved', 'action'),
176
-					'value' => sprintf( '%s-%d', self::$bulk_action_prefixes['unapprove'], $form_id ),
175
+					'label' => GravityView_Entry_Approval_Status::get_string( 'unapproved', 'action' ),
176
+					'value' => sprintf( '%s-%d', self::$bulk_action_prefixes[ 'unapprove' ], $form_id ),
177 177
 				),
178 178
 			),
179 179
 		);
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 		// Sanitize the values, just to be sure.
191 191
 		foreach ( $bulk_actions as $key => $group ) {
192 192
 
193
-			if( empty( $group ) ) {
193
+			if ( empty( $group ) ) {
194 194
 				continue;
195 195
 			}
196 196
 
197 197
 			foreach ( $group as $i => $action ) {
198
-				$bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] );
199
-				$bulk_actions[ $key ][ $i ]['value'] = esc_attr( $bulk_actions[ $key ][ $i ]['value'] );
198
+				$bulk_actions[ $key ][ $i ][ 'label' ] = esc_html( $bulk_actions[ $key ][ $i ][ 'label' ] );
199
+				$bulk_actions[ $key ][ $i ][ 'value' ] = esc_attr( $bulk_actions[ $key ][ $i ][ 'value' ] );
200 200
 			}
201 201
 		}
202 202
 
Please login to merge, or discard this patch.
includes/class-admin-approve-entries.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 	/**
251 251
 	 * update_approved function.
252 252
 	 *
253
-     * @since 1.18 Moved to GravityView_Entry_Approval::update_approved
253
+	 * @since 1.18 Moved to GravityView_Entry_Approval::update_approved
254 254
 	 * @see GravityView_Entry_Approval::update_approved
255
-     *
255
+	 *
256 256
 	 * @param int $entry_id (default: 0)
257 257
 	 * @param int $approved (default: 0)
258 258
 	 * @param int $form_id (default: 0)
259 259
 	 * @param int $approvedcolumn (default: 0)
260
-     *
260
+	 *
261 261
 	 * @return boolean True: It worked; False: it failed
262 262
 	 */
263 263
 	public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) {
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 	/**
268 268
 	 * Calculate the approve field.input id
269 269
 	 *
270
-     * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column
271
-     * @see GravityView_Entry_Approval::get_approved_column
272
-     *
270
+	 * @since 1.18 Moved to GravityView_Entry_Approval::get_approved_column
271
+	 * @see GravityView_Entry_Approval::get_approved_column
272
+	 *
273 273
 	 * @param mixed $form GF Form or Form ID
274 274
 	 * @return false|null|string Returns the input ID of the approved field. Returns NULL if no approved fields were found. Returns false if $form_id wasn't set.
275 275
 	 */
@@ -394,37 +394,37 @@  discard block
 block discarded – undo
394 394
 			'bulk_actions' => GravityView_Bulk_Actions::get_bulk_actions( $form_id ),
395 395
 			'bulk_message' => $this->bulk_update_message,
396 396
 			'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'),
397
-            'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'),
397
+			'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'),
398 398
 			'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'),
399 399
 			'column_title' => __( 'Show entry in directory view?', 'gravityview'),
400 400
 			'column_link' => esc_url( $this->get_sort_link() ),
401
-            'status_popover_template' => GravityView_Entry_Approval::get_popover_template(),
401
+			'status_popover_template' => GravityView_Entry_Approval::get_popover_template(),
402 402
 			'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(),
403 403
 		) );
404 404
 
405 405
 	}
406 406
 
407 407
 	/**
408
-     * Generate a link to sort by approval status
409
-     *
410
-     * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as
411
-     * numeric, but it does group the approved entries together.
412
-     *
413
-     * @since 2.0.14 Remove need for approval field for sorting by approval status
414
-     *
408
+	 * Generate a link to sort by approval status
409
+	 *
410
+	 * Note: Sorting by approval will never be great because it's not possible currently to declare the sorting as
411
+	 * numeric, but it does group the approved entries together.
412
+	 *
413
+	 * @since 2.0.14 Remove need for approval field for sorting by approval status
414
+	 *
415 415
 	 * @param int $form_id [NO LONGER USED]
416 416
 	 *
417 417
 	 * @return string Sorting link
418 418
 	 */
419 419
 	private function get_sort_link( $form_id = 0 ) {
420 420
 
421
-	    $args = array(
422
-		    'orderby' => 'is_approved',
423
-            'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc',
424
-        );
421
+		$args = array(
422
+			'orderby' => 'is_approved',
423
+			'order' => ( 'desc' === \GV\Utils::_GET( 'order' ) ) ? 'asc' : 'desc',
424
+		);
425 425
 
426 426
 		return add_query_arg( $args );
427
-    }
427
+	}
428 428
 
429 429
 	/**
430 430
 	 * Should the Approve/Reject Entry column be shown in the GF Entries page?
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips' ) );
50 50
 
51 51
 		// adding styles and scripts
52
-		add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') );
52
+		add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) );
53 53
 		// bypass Gravity Forms no-conflict mode
54 54
 		add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) );
55 55
 		add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) );
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		 * @param bool $show_filter_links True: show the "approved"/"disapproved" filter links. False: hide them.
79 79
 		 * @param array $form GF Form object of current form
80 80
 		 */
81
-		if( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) {
81
+		if ( false === apply_filters( 'gravityview/approve_entries/show_filter_links_entry_list', true, $form ) ) {
82 82
 			return $filter_links;
83 83
 		}
84 84
 
@@ -106,27 +106,27 @@  discard block
 block discarded – undo
106 106
 		$approved_count = $disapproved_count = $unapproved_count = 0;
107 107
 
108 108
 		// Only count if necessary
109
-		if( $include_counts ) {
110
-			$approved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) );
111
-			$disapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) );
112
-			$unapproved_count = count( gravityview_get_entry_ids( $form['id'], array( 'status' => 'active', 'field_filters' => $field_filters_unapproved ) ) );
109
+		if ( $include_counts ) {
110
+			$approved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_approved ) ) );
111
+			$disapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_disapproved ) ) );
112
+			$unapproved_count = count( gravityview_get_entry_ids( $form[ 'id' ], array( 'status' => 'active', 'field_filters' => $field_filters_unapproved ) ) );
113 113
 		}
114 114
 
115
-		$filter_links[] = array(
115
+		$filter_links[ ] = array(
116 116
 			'id'            => 'gv_approved',
117 117
 			'field_filters' => $field_filters_approved,
118 118
 			'count'         => $approved_count,
119 119
 			'label'         => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::APPROVED ),
120 120
 		);
121 121
 
122
-		$filter_links[] = array(
122
+		$filter_links[ ] = array(
123 123
 			'id'            => 'gv_disapproved',
124 124
 			'field_filters' => $field_filters_disapproved,
125 125
 			'count'         => $disapproved_count,
126 126
 			'label'         => GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::DISAPPROVED ),
127 127
 		);
128 128
 
129
-		$filter_links[] = array(
129
+		$filter_links[ ] = array(
130 130
 			'id'            => 'gv_unapproved',
131 131
 			'field_filters' => $field_filters_unapproved,
132 132
 			'count'         => $unapproved_count,
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	function tooltips( $tooltips ) {
147 147
 
148
-		$tooltips['form_gravityview_fields'] = array(
149
-			'title' => __('GravityView Fields', 'gravityview'),
150
-			'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'),
148
+		$tooltips[ 'form_gravityview_fields' ] = array(
149
+			'title' => __( 'GravityView Fields', 'gravityview' ),
150
+			'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ),
151 151
 		);
152 152
 
153 153
 		return $tooltips;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      *
261 261
 	 * @return boolean True: It worked; False: it failed
262 262
 	 */
263
-	public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) {
263
+	public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) {
264 264
 		return GravityView_Entry_Approval::update_approved( $entry_id, $approved, $form_id, $approvedcolumn );
265 265
 	}
266 266
 
@@ -290,20 +290,20 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return void
292 292
 	 */
293
-	static public function add_entry_approved_hidden_input(  $form_id, $field_id, $value, $entry, $query_string ) {
293
+	static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) {
294 294
 
295
-		if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) {
295
+		if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) {
296 296
 			return;
297 297
 		}
298 298
 
299
-		if( empty( $entry['id'] ) ) {
299
+		if ( empty( $entry[ 'id' ] ) ) {
300 300
 			return;
301 301
 		}
302 302
 
303 303
 		$status_value = GravityView_Entry_Approval::get_entry_status( $entry, 'value' );
304 304
 
305
-		if( $status_value ) {
306
-			echo '<input type="hidden" class="entry_approval" id="entry_approved_'. $entry['id'] .'" value="' . esc_attr( $status_value ) . '" />';
305
+		if ( $status_value ) {
306
+			echo '<input type="hidden" class="entry_approval" id="entry_approved_' . $entry[ 'id' ] . '" value="' . esc_attr( $status_value ) . '" />';
307 307
 		}
308 308
 	}
309 309
 
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	private function get_form_id() {
318 318
 
319
-		$form_id = GFForms::get('id');
319
+		$form_id = GFForms::get( 'id' );
320 320
 
321 321
 		// If there are no forms identified, use the first form. That's how GF does it.
322
-		if( empty( $form_id ) && class_exists('RGFormsModel') ) {
322
+		if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) {
323 323
 			$form_id = $this->get_first_form_id();
324 324
 		}
325 325
 
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 
340 340
 		$forms = RGFormsModel::get_forms( null, 'title' );
341 341
 
342
-		if( ! isset( $forms[0] ) ) {
342
+		if ( ! isset( $forms[ 0 ] ) ) {
343 343
 			gravityview()->log->error( 'No forms were found' );
344 344
 			return 0;
345 345
 		}
346 346
 
347
-		$first_form = $forms[0];
347
+		$first_form = $forms[ 0 ];
348 348
 
349
-		$form_id = is_object( $forms[0] ) ? $first_form->id : $first_form['id'];
349
+		$form_id = is_object( $forms[ 0 ] ) ? $first_form->id : $first_form[ 'id' ];
350 350
 
351 351
 		return intval( $form_id );
352 352
 	}
@@ -354,37 +354,37 @@  discard block
 block discarded – undo
354 354
 
355 355
 	function add_scripts_and_styles( $hook ) {
356 356
 
357
-		if( ! class_exists( 'GFForms' ) ) {
357
+		if ( ! class_exists( 'GFForms' ) ) {
358 358
 			gravityview()->log->error( 'GFForms does not exist.' );
359 359
 			return;
360 360
 		}
361 361
 
362 362
 		// enqueue styles & scripts gf_entries
363 363
 		// But only if we're on the main Entries page, not on reports pages
364
-		if( GFForms::get_page() !== 'entry_list' ) {
364
+		if ( GFForms::get_page() !== 'entry_list' ) {
365 365
 			return;
366 366
 		}
367 367
 
368 368
 		$form_id = $this->get_form_id();
369 369
 
370 370
 		// Things are broken; no forms were found
371
-		if( empty( $form_id ) ) {
371
+		if ( empty( $form_id ) ) {
372 372
 			return;
373 373
 		}
374 374
 
375
-		wp_enqueue_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version );
375
+		wp_enqueue_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
376 376
 
377
-		$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
377
+		$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
378 378
 
379
-		wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version );
379
+		wp_enqueue_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version );
380 380
 
381 381
 		wp_enqueue_script( 'gravityview_entries_list-popper', plugins_url( 'assets/lib/tippy/popper.min.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
382 382
 		wp_enqueue_script( 'gravityview_entries_list-tippy', plugins_url( 'assets/lib/tippy/tippy.min.js', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
383 383
 		wp_enqueue_style( 'gravityview_entries_list-tippy', plugins_url( 'assets/lib/tippy/tippy.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version );
384 384
 
385 385
 		wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array(
386
-			'nonce' => wp_create_nonce( 'gravityview_entry_approval'),
387
-			'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval'),
386
+			'nonce' => wp_create_nonce( 'gravityview_entry_approval' ),
387
+			'admin_nonce' => wp_create_nonce( 'gravityview_admin_entry_approval' ),
388 388
 			'form_id' => $form_id,
389 389
 			'show_column' => (int)$this->show_approve_entry_column( $form_id ),
390 390
 			'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ),
@@ -393,10 +393,10 @@  discard block
 block discarded – undo
393 393
 			'status_unapproved' => GravityView_Entry_Approval_Status::UNAPPROVED,
394 394
 			'bulk_actions' => GravityView_Bulk_Actions::get_bulk_actions( $form_id ),
395 395
 			'bulk_message' => $this->bulk_update_message,
396
-			'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('unapproved'),
397
-            'approve_title' => GravityView_Entry_Approval_Status::get_title_attr('disapproved'),
398
-			'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr('approved'),
399
-			'column_title' => __( 'Show entry in directory view?', 'gravityview'),
396
+			'unapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'unapproved' ),
397
+            'approve_title' => GravityView_Entry_Approval_Status::get_title_attr( 'disapproved' ),
398
+			'disapprove_title' => GravityView_Entry_Approval_Status::get_title_attr( 'approved' ),
399
+			'column_title' => __( 'Show entry in directory view?', 'gravityview' ),
400 400
 			'column_link' => esc_url( $this->get_sort_link() ),
401 401
             'status_popover_template' => GravityView_Entry_Approval::get_popover_template(),
402 402
 			'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(),
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 		 * @since 1.7.2
445 445
 		 * @param boolean $hide_if_no_connections
446 446
 		 */
447
-		$hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false );
447
+		$hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false );
448 448
 
449
-		if( $hide_if_no_connections ) {
449
+		if ( $hide_if_no_connections ) {
450 450
 
451 451
 			$connected_views = gravityview_get_connected_views( $form_id );
452 452
 
453
-			if( empty( $connected_views ) ) {
453
+			if ( empty( $connected_views ) ) {
454 454
 				$show_approve_column = false;
455 455
 			}
456 456
 		}
@@ -460,21 +460,21 @@  discard block
 block discarded – undo
460 460
 		 * @param boolean $show_approve_column Whether the column will be shown
461 461
 		 * @param int $form_id The ID of the Gravity Forms form for which entries are being shown
462 462
 		 */
463
-		$show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id );
463
+		$show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id );
464 464
 
465 465
 		return $show_approve_column;
466 466
 	}
467 467
 
468 468
 	function register_gform_noconflict_script( $scripts ) {
469
-		$scripts[] = 'gravityview_gf_entries_scripts';
470
-		$scripts[] = 'gravityview_entries_list-popper';
471
-		$scripts[] = 'gravityview_entries_list-tippy';
469
+		$scripts[ ] = 'gravityview_gf_entries_scripts';
470
+		$scripts[ ] = 'gravityview_entries_list-popper';
471
+		$scripts[ ] = 'gravityview_entries_list-tippy';
472 472
 		return $scripts;
473 473
 	}
474 474
 
475 475
 	function register_gform_noconflict_style( $styles ) {
476
-		$styles[] = 'gravityview_entries_list';
477
-		$styles[] = 'gravityview_entries_list-tippy';
476
+		$styles[ ] = 'gravityview_entries_list';
477
+		$styles[ ] = 'gravityview_entries_list-tippy';
478 478
 		return $styles;
479 479
 	}
480 480
 
Please login to merge, or discard this patch.
lightbox/fancybox/class-gravityview-lightbox-provider-fancybox.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function allowed_atts( $atts = array() ) {
110 110
 
111
-		$atts['data-fancybox']         = null;
112
-		$atts['data-fancybox-trigger'] = null;
113
-		$atts['data-fancybox-index']   = null;
114
-		$atts['data-src']              = null;
115
-		$atts['data-type']             = null;
116
-		$atts['data-width']            = null;
117
-		$atts['data-height']           = null;
118
-		$atts['data-srcset']           = null;
119
-		$atts['data-caption']          = null;
120
-		$atts['data-options']          = null;
121
-		$atts['data-filter']           = null;
111
+		$atts[ 'data-fancybox' ]         = null;
112
+		$atts[ 'data-fancybox-trigger' ] = null;
113
+		$atts[ 'data-fancybox-index' ]   = null;
114
+		$atts[ 'data-src' ]              = null;
115
+		$atts[ 'data-type' ]             = null;
116
+		$atts[ 'data-width' ]            = null;
117
+		$atts[ 'data-height' ]           = null;
118
+		$atts[ 'data-srcset' ]           = null;
119
+		$atts[ 'data-caption' ]          = null;
120
+		$atts[ 'data-options' ]          = null;
121
+		$atts[ 'data-filter' ]           = null;
122 122
 
123 123
 		return $atts;
124 124
 	}
@@ -133,23 +133,23 @@  discard block
 block discarded – undo
133 133
 		}
134 134
 
135 135
 		// Prevent empty content from getting added to the lightbox gallery
136
-		if ( is_array( $additional_details ) && empty( $additional_details['file_path'] ) ) {
136
+		if ( is_array( $additional_details ) && empty( $additional_details[ 'file_path' ] ) ) {
137 137
 			return $link_atts;
138 138
 		}
139 139
 
140 140
 		// Prevent empty content from getting added to the lightbox gallery
141
-		if ( is_array( $additional_details ) && ! empty( $additional_details['disable_lightbox'] ) ) {
141
+		if ( is_array( $additional_details ) && ! empty( $additional_details[ 'disable_lightbox' ] ) ) {
142 142
 			return $link_atts;
143 143
 		}
144 144
 
145
-		$link_atts['class'] = \GV\Utils::get( $link_atts, 'class' ) . ' gravityview-fancybox';
145
+		$link_atts[ 'class' ] = \GV\Utils::get( $link_atts, 'class' ) . ' gravityview-fancybox';
146 146
 
147
-		$link_atts['class'] = gravityview_sanitize_html_class( $link_atts['class'] );
147
+		$link_atts[ 'class' ] = gravityview_sanitize_html_class( $link_atts[ 'class' ] );
148 148
 
149 149
 		if ( $context && ! empty( $context->field->field ) ) {
150 150
 			if ( $context->field->field->multipleFiles ) {
151 151
 				$entry = $context->entry->as_entry();
152
-				$link_atts['data-fancybox'] = 'gallery-' . sprintf( "%s-%s-%s", $entry['form_id'], $context->field->ID, $context->entry->get_slug() );
152
+				$link_atts[ 'data-fancybox' ] = 'gallery-' . sprintf( "%s-%s-%s", $entry[ 'form_id' ], $context->field->ID, $context->entry->get_slug() );
153 153
 			}
154 154
 		}
155 155
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		 * @see https://fancyapps.com/docs/ui/fancybox#media-types
161 161
 		 */
162 162
 		if ( false !== strpos( $file_path, 'gv-iframe' ) ) {
163
-			$link_atts['data-type'] = 'pdf';
163
+			$link_atts[ 'data-type' ] = 'pdf';
164 164
 		}
165 165
 
166 166
 		return $link_atts;
Please login to merge, or discard this patch.
includes/wordpress-widgets/class-gravityview-recent-entries-widget.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 	function __construct( ) {
14 14
 
15
-		$name = __('GravityView Recent Entries', 'gravityview');
15
+		$name = __( 'GravityView Recent Entries', 'gravityview' );
16 16
 
17 17
 		$widget_options = array(
18 18
 			'description' => __( 'Display the most recent entries for a View', 'gravityview' ),
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 	private function initialize() {
27 27
 
28
-		add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') );
28
+		add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
29 29
 
30 30
 		add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) );
31 31
 
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	function ajax_get_view_merge_tag_data() {
40 40
 
41
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) {
41
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajax_widget' ) ) {
42 42
 			exit( false );
43 43
 		}
44 44
 
45
-		$form_id  = gravityview_get_form_id( $_POST['view_id'] );
45
+		$form_id = gravityview_get_form_id( $_POST[ 'view_id' ] );
46 46
 
47 47
 		$form = RGFormsModel::get_form_meta( $form_id );
48 48
 
49 49
 		$output = array(
50 50
 			'form' => array(
51
-				'id' => $form['id'],
52
-				'title' => $form['title'],
53
-				'fields' => $form['fields'],
51
+				'id' => $form[ 'id' ],
52
+				'title' => $form[ 'title' ],
53
+				'fields' => $form[ 'fields' ],
54 54
 			),
55
-			'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ),
55
+			'mergeTags' => GFCommon::get_merge_tags( $form[ 'fields' ], '', false ),
56 56
 		);
57 57
 
58 58
 		echo json_encode( $output );
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
 	function admin_enqueue_scripts() {
69 69
 		global $pagenow;
70 70
 
71
-		if( $pagenow === 'widgets.php' ) {
71
+		if ( $pagenow === 'widgets.php' ) {
72 72
 
73
-			$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
73
+			$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
74 74
 
75
-			wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version );
75
+			wp_enqueue_script( 'gravityview_widgets', plugins_url( 'assets/js/admin-widgets' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version );
76 76
 
77 77
 			wp_localize_script( 'gravityview_widgets', 'GVWidgets', array(
78 78
 				'nonce' => wp_create_nonce( 'gravityview_ajax_widget' )
79
-			));
79
+			) );
80 80
 
81
-			wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version );
81
+			wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons' ), GravityView_Plugin::version );
82 82
 		}
83 83
 
84 84
 	}
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	function widget( $args, $instance ) {
94 94
 
95 95
 		// Don't have the Customizer render too soon.
96
-		if( empty( $instance['view_id'] ) ) {
96
+		if ( empty( $instance[ 'view_id' ] ) ) {
97 97
 			return;
98 98
 		}
99 99
 
100
-		$args['id']        = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries';
101
-		$instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : '';
100
+		$args[ 'id' ]        = ( isset( $args[ 'id' ] ) ) ? $args[ 'id' ] : 'gv_recent_entries';
101
+		$instance[ 'title' ] = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : '';
102 102
 
103
-		$title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] );
103
+		$title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args[ 'id' ] );
104 104
 
105
-		echo $args['before_widget'];
105
+		echo $args[ 'before_widget' ];
106 106
 
107
-		if ( !empty( $title ) ) {
108
-			echo $args['before_title'] . $title . $args['after_title'];
107
+		if ( ! empty( $title ) ) {
108
+			echo $args[ 'before_title' ] . $title . $args[ 'after_title' ];
109 109
 		}
110 110
 
111 111
 		/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		 */
126 126
 		do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance );
127 127
 
128
-		echo $args['after_widget'];
128
+		echo $args[ 'after_widget' ];
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	private function get_output( $instance ) {
141 141
 
142
-		$form_id = gravityview_get_form_id( $instance['view_id'] );
142
+		$form_id = gravityview_get_form_id( $instance[ 'view_id' ] );
143 143
 
144 144
 		$form = gravityview_get_form( $form_id );
145 145
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 		 * @since 1.6.1
150 150
 		 * @var int $entry_link_post_id The ID to use as the parent post for the entry
151 151
 		 */
152
-		$entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id'];
152
+		$entry_link_post_id = ( empty( $instance[ 'error_post_id' ] ) && ! empty( $instance[ 'post_id' ] ) ) ? $instance[ 'post_id' ] : $instance[ 'view_id' ];
153 153
 
154 154
 		/**
155 155
 		 * Generate list output
156 156
 		 * @since 1.7.2
157 157
 		 */
158
-		$List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget', null, $instance['view_id'] );
158
+		$List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance[ 'link_format' ], $instance[ 'after_link' ], 'recent-entries-widget', null, $instance[ 'view_id' ] );
159 159
 
160 160
 		$output = $List->get_output();
161 161
 
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	private function get_entries( $instance, $form_id ) {
182 182
 
183
-		$view = \GV\View::by_id( $instance['view_id'] );
183
+		$view = \GV\View::by_id( $instance[ 'view_id' ] );
184 184
 
185
-		$limit = isset( $instance['limit'] ) ? $instance['limit'] : 10;
185
+		$limit = isset( $instance[ 'limit' ] ) ? $instance[ 'limit' ] : 10;
186 186
 
187 187
 		$view->settings->set( 'page_size', $limit );
188 188
 
@@ -205,23 +205,23 @@  discard block
 block discarded – undo
205 205
 		$instance = $new_instance;
206 206
 
207 207
 		// Force positive number
208
-		$instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] );
208
+		$instance[ 'limit' ] = empty( $instance[ 'limit' ] ) ? 10 : absint( $instance[ 'limit' ] );
209 209
 
210
-		$instance['view_id'] = intval( $instance['view_id'] );
210
+		$instance[ 'view_id' ] = intval( $instance[ 'view_id' ] );
211 211
 
212
-		$instance['link_format'] = trim( rtrim( $instance['link_format'] ) );
212
+		$instance[ 'link_format' ] = trim( rtrim( $instance[ 'link_format' ] ) );
213 213
 
214
-		$instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format'];
214
+		$instance[ 'link_format' ] = empty( $instance[ 'link_format' ] ) ? $old_instance[ 'link_format' ] : $instance[ 'link_format' ];
215 215
 
216
-		$instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] );
216
+		$instance[ 'post_id' ] = empty( $instance[ 'post_id' ] ) ? '' : intval( $instance[ 'post_id' ] );
217 217
 
218
-		$is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'], true );
218
+		$is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ], true );
219 219
 
220 220
 		//check if post_id is a valid post with embedded View
221
-		$instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL;
221
+		$instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL;
222 222
 
223 223
 		// Share that the widget isn't brand new
224
-		$instance['updated']  = 1;
224
+		$instance[ 'updated' ] = 1;
225 225
 
226 226
 		/**
227 227
 		 * Modify the updated instance. This will allow for validating any added instance settings externally.
@@ -243,22 +243,22 @@  discard block
 block discarded – undo
243 243
 
244 244
 		// Set up some default widget settings.
245 245
 		$defaults = array(
246
-			'title' 			=> __('Recent Entries', 'gravityview'),
246
+			'title' 			=> __( 'Recent Entries', 'gravityview' ),
247 247
 			'view_id'           => NULL,
248 248
 			'post_id'           => NULL,
249 249
 			'limit'            => 10,
250
-			'link_format'       => __('Entry #{entry_id}', 'gravityview'),
250
+			'link_format'       => __( 'Entry #{entry_id}', 'gravityview' ),
251 251
 			'after_link'        => ''
252 252
 		);
253 253
 
254
-		$instance = wp_parse_args( (array) $instance, $defaults );
254
+		$instance = wp_parse_args( (array)$instance, $defaults );
255 255
 
256 256
 		?>
257 257
 
258 258
 		<!-- Title -->
259 259
 		<p>
260 260
 			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label>
261
-			<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
261
+			<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" />
262 262
 		</p>
263 263
 
264 264
 		<!-- Download -->
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		$views = get_posts( $args );
272 272
 
273 273
 		// If there are no views set up yet, we get outta here.
274
-		if( empty( $views ) ) {
274
+		if ( empty( $views ) ) {
275 275
 			echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>';
276 276
 			return;
277 277
 		}
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 		 * Display errors generated for invalid embed IDs
284 284
 		 * @see GravityView_View_Data::is_valid_embed_id
285 285
 		 */
286
-		if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) {
286
+		if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) {
287 287
 			?>
288 288
 			<div class="error inline hide-on-view-change">
289
-				<p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p>
289
+				<p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p>
290 290
 			</div>
291 291
 			<?php
292 292
 			unset ( $error );
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 		?>
295 295
 
296 296
 		<p>
297
-			<label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label>
297
+			<label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label>
298 298
 			<select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>">
299 299
 				<option value=""><?php esc_html_e( '&mdash; Select a View as Entries Source &mdash;', 'gravityview' ); ?></option>
300 300
 				<?php
301 301
 
302
-				foreach( $views as $view ) {
303
-					$title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title;
304
-					echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>';
302
+				foreach ( $views as $view ) {
303
+					$title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title;
304
+					echo '<option value="' . $view->ID . '"' . selected( absint( $instance[ 'view_id' ] ), $view->ID ) . '>' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>';
305 305
 				}
306 306
 
307 307
 				?>
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 		 * Display errors generated for invalid embed IDs
314 314
 		 * @see GravityView_View_Data::is_valid_embed_id
315 315
 		 */
316
-		if( !empty( $instance['error_post_id'] ) ) {
316
+		if ( ! empty( $instance[ 'error_post_id' ] ) ) {
317 317
 			?>
318 318
 			<div class="error inline">
319
-				<p><?php echo $instance['error_post_id']; ?></p>
319
+				<p><?php echo $instance[ 'error_post_id' ]; ?></p>
320 320
 			</div>
321 321
 			<?php
322 322
 			unset ( $error );
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 		?>
325 325
 
326 326
 		<p>
327
-			<label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label>
328
-			<input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" />
327
+			<label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label>
328
+			<input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'post_id' ] ); ?>" />
329 329
 			<span class="howto"><?php
330
-				esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' );
331
-				echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more&hellip;', 'gravityview' ), 'target=_blank' );
330
+				esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' );
331
+				echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more&hellip;', 'gravityview' ), 'target=_blank' );
332 332
 				?></span>
333 333
 		</p>
334 334
 
@@ -336,21 +336,21 @@  discard block
 block discarded – undo
336 336
 			<label for="<?php echo $this->get_field_id( 'limit' ); ?>">
337 337
 				<span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span>
338 338
 			</label>
339
-			<input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" />
339
+			<input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance[ 'limit' ] ); ?>" size="3" />
340 340
 		</p>
341 341
 
342 342
 		<p>
343 343
 			<label for="<?php echo $this->get_field_id( 'link_format' ); ?>">
344 344
 				<span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span>
345 345
 			</label>
346
-			<input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" />
346
+			<input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'link_format' ] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" />
347 347
 		</p>
348 348
 
349 349
 		<p>
350 350
 			<label for="<?php echo $this->get_field_id( 'after_link' ); ?>">
351 351
 				<span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span>
352 352
 			</label>
353
-			<textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea>
353
+			<textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance[ 'after_link' ] ); ?></textarea>
354 354
 		</p>
355 355
 
356 356
 		<?php
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 		 * @param GravityView_Recent_Entries_Widget $this WP_Widget object
361 361
 		 * @param array $instance Current widget instance
362 362
 		 */
363
-		do_action( 'gravityview_recent_entries_widget_form' , $this, $instance );
363
+		do_action( 'gravityview_recent_entries_widget_form', $this, $instance );
364 364
 
365 365
 		?>
366 366
 
Please login to merge, or discard this patch.
trustedlogin/trustedlogin/client/src/Cron.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 namespace GravityView\TrustedLogin;
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined('ABSPATH') ) {
12
+if ( ! defined( 'ABSPATH' ) ) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 		$unschedule_expiration = wp_clear_scheduled_hook( $this->hook_name, array( $site_identifier_hash ) );
92 92
 
93
-		if ( false === $unschedule_expiration ){
93
+		if ( false === $unschedule_expiration ) {
94 94
 			$this->logging->log( sprintf( 'Could not unschedule event for %s', $this->hook_name ), __METHOD__, 'error' );
95 95
 			return false;
96 96
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 
91 91
 		$unschedule_expiration = wp_clear_scheduled_hook( $this->hook_name, array( $site_identifier_hash ) );
92 92
 
93
-		if ( false === $unschedule_expiration ){
93
+		if ( false === $unschedule_expiration ) {
94 94
 			$this->logging->log( sprintf( 'Could not unschedule event for %s', $this->hook_name ), __METHOD__, 'error' );
95 95
 			return false;
96 96
 		}
Please login to merge, or discard this patch.
vendor/composer/ClassLoader.php 3 patches
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     /**
104 104
      * @param ?string $vendorDir
105 105
      */
106
-    public function __construct($vendorDir = null)
106
+    public function __construct( $vendorDir = null )
107 107
     {
108 108
         $this->vendorDir = $vendorDir;
109 109
     }
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getPrefixes()
115 115
     {
116
-        if (!empty($this->prefixesPsr0)) {
117
-            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
116
+        if ( ! empty( $this->prefixesPsr0 ) ) {
117
+            return call_user_func_array( 'array_merge', array_values( $this->prefixesPsr0 ) );
118 118
         }
119 119
 
120 120
         return array();
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
      *
163 163
      * @return void
164 164
      */
165
-    public function addClassMap(array $classMap)
165
+    public function addClassMap( array $classMap )
166 166
     {
167
-        if ($this->classMap) {
168
-            $this->classMap = array_merge($this->classMap, $classMap);
167
+        if ( $this->classMap ) {
168
+            $this->classMap = array_merge( $this->classMap, $classMap );
169 169
         } else {
170 170
             $this->classMap = $classMap;
171 171
         }
@@ -181,39 +181,39 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @return void
183 183
      */
184
-    public function add($prefix, $paths, $prepend = false)
184
+    public function add( $prefix, $paths, $prepend = false )
185 185
     {
186
-        if (!$prefix) {
187
-            if ($prepend) {
186
+        if ( ! $prefix ) {
187
+            if ( $prepend ) {
188 188
                 $this->fallbackDirsPsr0 = array_merge(
189
-                    (array) $paths,
189
+                    (array)$paths,
190 190
                     $this->fallbackDirsPsr0
191 191
                 );
192 192
             } else {
193 193
                 $this->fallbackDirsPsr0 = array_merge(
194 194
                     $this->fallbackDirsPsr0,
195
-                    (array) $paths
195
+                    (array)$paths
196 196
                 );
197 197
             }
198 198
 
199 199
             return;
200 200
         }
201 201
 
202
-        $first = $prefix[0];
203
-        if (!isset($this->prefixesPsr0[$first][$prefix])) {
204
-            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
202
+        $first = $prefix[ 0 ];
203
+        if ( ! isset( $this->prefixesPsr0[ $first ][ $prefix ] ) ) {
204
+            $this->prefixesPsr0[ $first ][ $prefix ] = (array)$paths;
205 205
 
206 206
             return;
207 207
         }
208
-        if ($prepend) {
209
-            $this->prefixesPsr0[$first][$prefix] = array_merge(
210
-                (array) $paths,
211
-                $this->prefixesPsr0[$first][$prefix]
208
+        if ( $prepend ) {
209
+            $this->prefixesPsr0[ $first ][ $prefix ] = array_merge(
210
+                (array)$paths,
211
+                $this->prefixesPsr0[ $first ][ $prefix ]
212 212
             );
213 213
         } else {
214
-            $this->prefixesPsr0[$first][$prefix] = array_merge(
215
-                $this->prefixesPsr0[$first][$prefix],
216
-                (array) $paths
214
+            $this->prefixesPsr0[ $first ][ $prefix ] = array_merge(
215
+                $this->prefixesPsr0[ $first ][ $prefix ],
216
+                (array)$paths
217 217
             );
218 218
         }
219 219
     }
@@ -230,40 +230,40 @@  discard block
 block discarded – undo
230 230
      *
231 231
      * @return void
232 232
      */
233
-    public function addPsr4($prefix, $paths, $prepend = false)
233
+    public function addPsr4( $prefix, $paths, $prepend = false )
234 234
     {
235
-        if (!$prefix) {
235
+        if ( ! $prefix ) {
236 236
             // Register directories for the root namespace.
237
-            if ($prepend) {
237
+            if ( $prepend ) {
238 238
                 $this->fallbackDirsPsr4 = array_merge(
239
-                    (array) $paths,
239
+                    (array)$paths,
240 240
                     $this->fallbackDirsPsr4
241 241
                 );
242 242
             } else {
243 243
                 $this->fallbackDirsPsr4 = array_merge(
244 244
                     $this->fallbackDirsPsr4,
245
-                    (array) $paths
245
+                    (array)$paths
246 246
                 );
247 247
             }
248
-        } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
248
+        } elseif ( ! isset( $this->prefixDirsPsr4[ $prefix ] ) ) {
249 249
             // Register directories for a new namespace.
250
-            $length = strlen($prefix);
251
-            if ('\\' !== $prefix[$length - 1]) {
252
-                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
250
+            $length = strlen( $prefix );
251
+            if ( '\\' !== $prefix[ $length - 1 ] ) {
252
+                throw new \InvalidArgumentException( "A non-empty PSR-4 prefix must end with a namespace separator." );
253 253
             }
254
-            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
255
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
256
-        } elseif ($prepend) {
254
+            $this->prefixLengthsPsr4[ $prefix[ 0 ] ][ $prefix ] = $length;
255
+            $this->prefixDirsPsr4[ $prefix ] = (array)$paths;
256
+        } elseif ( $prepend ) {
257 257
             // Prepend directories for an already registered namespace.
258
-            $this->prefixDirsPsr4[$prefix] = array_merge(
259
-                (array) $paths,
260
-                $this->prefixDirsPsr4[$prefix]
258
+            $this->prefixDirsPsr4[ $prefix ] = array_merge(
259
+                (array)$paths,
260
+                $this->prefixDirsPsr4[ $prefix ]
261 261
             );
262 262
         } else {
263 263
             // Append directories for an already registered namespace.
264
-            $this->prefixDirsPsr4[$prefix] = array_merge(
265
-                $this->prefixDirsPsr4[$prefix],
266
-                (array) $paths
264
+            $this->prefixDirsPsr4[ $prefix ] = array_merge(
265
+                $this->prefixDirsPsr4[ $prefix ],
266
+                (array)$paths
267 267
             );
268 268
         }
269 269
     }
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
      *
278 278
      * @return void
279 279
      */
280
-    public function set($prefix, $paths)
280
+    public function set( $prefix, $paths )
281 281
     {
282
-        if (!$prefix) {
283
-            $this->fallbackDirsPsr0 = (array) $paths;
282
+        if ( ! $prefix ) {
283
+            $this->fallbackDirsPsr0 = (array)$paths;
284 284
         } else {
285
-            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
285
+            $this->prefixesPsr0[ $prefix[ 0 ] ][ $prefix ] = (array)$paths;
286 286
         }
287 287
     }
288 288
 
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
      *
298 298
      * @return void
299 299
      */
300
-    public function setPsr4($prefix, $paths)
300
+    public function setPsr4( $prefix, $paths )
301 301
     {
302
-        if (!$prefix) {
303
-            $this->fallbackDirsPsr4 = (array) $paths;
302
+        if ( ! $prefix ) {
303
+            $this->fallbackDirsPsr4 = (array)$paths;
304 304
         } else {
305
-            $length = strlen($prefix);
306
-            if ('\\' !== $prefix[$length - 1]) {
307
-                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
305
+            $length = strlen( $prefix );
306
+            if ( '\\' !== $prefix[ $length - 1 ] ) {
307
+                throw new \InvalidArgumentException( "A non-empty PSR-4 prefix must end with a namespace separator." );
308 308
             }
309
-            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
310
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
309
+            $this->prefixLengthsPsr4[ $prefix[ 0 ] ][ $prefix ] = $length;
310
+            $this->prefixDirsPsr4[ $prefix ] = (array)$paths;
311 311
         }
312 312
     }
313 313
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      *
319 319
      * @return void
320 320
      */
321
-    public function setUseIncludePath($useIncludePath)
321
+    public function setUseIncludePath( $useIncludePath )
322 322
     {
323 323
         $this->useIncludePath = $useIncludePath;
324 324
     }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      *
343 343
      * @return void
344 344
      */
345
-    public function setClassMapAuthoritative($classMapAuthoritative)
345
+    public function setClassMapAuthoritative( $classMapAuthoritative )
346 346
     {
347 347
         $this->classMapAuthoritative = $classMapAuthoritative;
348 348
     }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
      *
365 365
      * @return void
366 366
      */
367
-    public function setApcuPrefix($apcuPrefix)
367
+    public function setApcuPrefix( $apcuPrefix )
368 368
     {
369
-        $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
369
+        $this->apcuPrefix = function_exists( 'apcu_fetch' ) && filter_var( ini_get( 'apc.enabled' ), FILTER_VALIDATE_BOOLEAN ) ? $apcuPrefix : null;
370 370
     }
371 371
 
372 372
     /**
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
      *
387 387
      * @return void
388 388
      */
389
-    public function register($prepend = false)
389
+    public function register( $prepend = false )
390 390
     {
391
-        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
391
+        spl_autoload_register( array( $this, 'loadClass' ), true, $prepend );
392 392
 
393
-        if (null === $this->vendorDir) {
393
+        if ( null === $this->vendorDir ) {
394 394
             return;
395 395
         }
396 396
 
397
-        if ($prepend) {
398
-            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
397
+        if ( $prepend ) {
398
+            self::$registeredLoaders = array( $this->vendorDir => $this ) + self::$registeredLoaders;
399 399
         } else {
400
-            unset(self::$registeredLoaders[$this->vendorDir]);
401
-            self::$registeredLoaders[$this->vendorDir] = $this;
400
+            unset( self::$registeredLoaders[ $this->vendorDir ] );
401
+            self::$registeredLoaders[ $this->vendorDir ] = $this;
402 402
         }
403 403
     }
404 404
 
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
      */
410 410
     public function unregister()
411 411
     {
412
-        spl_autoload_unregister(array($this, 'loadClass'));
412
+        spl_autoload_unregister( array( $this, 'loadClass' ) );
413 413
 
414
-        if (null !== $this->vendorDir) {
415
-            unset(self::$registeredLoaders[$this->vendorDir]);
414
+        if ( null !== $this->vendorDir ) {
415
+            unset( self::$registeredLoaders[ $this->vendorDir ] );
416 416
         }
417 417
     }
418 418
 
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
      * @param  string    $class The name of the class
423 423
      * @return true|null True if loaded, null otherwise
424 424
      */
425
-    public function loadClass($class)
425
+    public function loadClass( $class )
426 426
     {
427
-        if ($file = $this->findFile($class)) {
428
-            includeFile($file);
427
+        if ( $file = $this->findFile( $class ) ) {
428
+            includeFile( $file );
429 429
 
430 430
             return true;
431 431
         }
@@ -440,36 +440,36 @@  discard block
 block discarded – undo
440 440
      *
441 441
      * @return string|false The path if found, false otherwise
442 442
      */
443
-    public function findFile($class)
443
+    public function findFile( $class )
444 444
     {
445 445
         // class map lookup
446
-        if (isset($this->classMap[$class])) {
447
-            return $this->classMap[$class];
446
+        if ( isset( $this->classMap[ $class ] ) ) {
447
+            return $this->classMap[ $class ];
448 448
         }
449
-        if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
449
+        if ( $this->classMapAuthoritative || isset( $this->missingClasses[ $class ] ) ) {
450 450
             return false;
451 451
         }
452
-        if (null !== $this->apcuPrefix) {
453
-            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
454
-            if ($hit) {
452
+        if ( null !== $this->apcuPrefix ) {
453
+            $file = apcu_fetch( $this->apcuPrefix . $class, $hit );
454
+            if ( $hit ) {
455 455
                 return $file;
456 456
             }
457 457
         }
458 458
 
459
-        $file = $this->findFileWithExtension($class, '.php');
459
+        $file = $this->findFileWithExtension( $class, '.php' );
460 460
 
461 461
         // Search for Hack files if we are running on HHVM
462
-        if (false === $file && defined('HHVM_VERSION')) {
463
-            $file = $this->findFileWithExtension($class, '.hh');
462
+        if ( false === $file && defined( 'HHVM_VERSION' ) ) {
463
+            $file = $this->findFileWithExtension( $class, '.hh' );
464 464
         }
465 465
 
466
-        if (null !== $this->apcuPrefix) {
467
-            apcu_add($this->apcuPrefix.$class, $file);
466
+        if ( null !== $this->apcuPrefix ) {
467
+            apcu_add( $this->apcuPrefix . $class, $file );
468 468
         }
469 469
 
470
-        if (false === $file) {
470
+        if ( false === $file ) {
471 471
             // Remember that this class does not exist.
472
-            $this->missingClasses[$class] = true;
472
+            $this->missingClasses[ $class ] = true;
473 473
         }
474 474
 
475 475
         return $file;
@@ -490,21 +490,21 @@  discard block
 block discarded – undo
490 490
      * @param  string       $ext
491 491
      * @return string|false
492 492
      */
493
-    private function findFileWithExtension($class, $ext)
493
+    private function findFileWithExtension( $class, $ext )
494 494
     {
495 495
         // PSR-4 lookup
496
-        $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
496
+        $logicalPathPsr4 = strtr( $class, '\\', DIRECTORY_SEPARATOR ) . $ext;
497 497
 
498
-        $first = $class[0];
499
-        if (isset($this->prefixLengthsPsr4[$first])) {
498
+        $first = $class[ 0 ];
499
+        if ( isset( $this->prefixLengthsPsr4[ $first ] ) ) {
500 500
             $subPath = $class;
501
-            while (false !== $lastPos = strrpos($subPath, '\\')) {
502
-                $subPath = substr($subPath, 0, $lastPos);
501
+            while ( false !== $lastPos = strrpos( $subPath, '\\' ) ) {
502
+                $subPath = substr( $subPath, 0, $lastPos );
503 503
                 $search = $subPath . '\\';
504
-                if (isset($this->prefixDirsPsr4[$search])) {
505
-                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
506
-                    foreach ($this->prefixDirsPsr4[$search] as $dir) {
507
-                        if (file_exists($file = $dir . $pathEnd)) {
504
+                if ( isset( $this->prefixDirsPsr4[ $search ] ) ) {
505
+                    $pathEnd = DIRECTORY_SEPARATOR . substr( $logicalPathPsr4, $lastPos + 1 );
506
+                    foreach ( $this->prefixDirsPsr4[ $search ] as $dir ) {
507
+                        if ( file_exists( $file = $dir . $pathEnd ) ) {
508 508
                             return $file;
509 509
                         }
510 510
                     }
@@ -513,27 +513,27 @@  discard block
 block discarded – undo
513 513
         }
514 514
 
515 515
         // PSR-4 fallback dirs
516
-        foreach ($this->fallbackDirsPsr4 as $dir) {
517
-            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
516
+        foreach ( $this->fallbackDirsPsr4 as $dir ) {
517
+            if ( file_exists( $file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4 ) ) {
518 518
                 return $file;
519 519
             }
520 520
         }
521 521
 
522 522
         // PSR-0 lookup
523
-        if (false !== $pos = strrpos($class, '\\')) {
523
+        if ( false !== $pos = strrpos( $class, '\\' ) ) {
524 524
             // namespaced class name
525
-            $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
526
-                . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
525
+            $logicalPathPsr0 = substr( $logicalPathPsr4, 0, $pos + 1 )
526
+                . strtr( substr( $logicalPathPsr4, $pos + 1 ), '_', DIRECTORY_SEPARATOR );
527 527
         } else {
528 528
             // PEAR-like class name
529
-            $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
529
+            $logicalPathPsr0 = strtr( $class, '_', DIRECTORY_SEPARATOR ) . $ext;
530 530
         }
531 531
 
532
-        if (isset($this->prefixesPsr0[$first])) {
533
-            foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
534
-                if (0 === strpos($class, $prefix)) {
535
-                    foreach ($dirs as $dir) {
536
-                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
532
+        if ( isset( $this->prefixesPsr0[ $first ] ) ) {
533
+            foreach ( $this->prefixesPsr0[ $first ] as $prefix => $dirs ) {
534
+                if ( 0 === strpos( $class, $prefix ) ) {
535
+                    foreach ( $dirs as $dir ) {
536
+                        if ( file_exists( $file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0 ) ) {
537 537
                             return $file;
538 538
                         }
539 539
                     }
@@ -542,14 +542,14 @@  discard block
 block discarded – undo
542 542
         }
543 543
 
544 544
         // PSR-0 fallback dirs
545
-        foreach ($this->fallbackDirsPsr0 as $dir) {
546
-            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
545
+        foreach ( $this->fallbackDirsPsr0 as $dir ) {
546
+            if ( file_exists( $file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0 ) ) {
547 547
                 return $file;
548 548
             }
549 549
         }
550 550
 
551 551
         // PSR-0 include paths.
552
-        if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
552
+        if ( $this->useIncludePath && $file = stream_resolve_include_path( $logicalPathPsr0 ) ) {
553 553
             return $file;
554 554
         }
555 555
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
  * @return void
567 567
  * @private
568 568
  */
569
-function includeFile($file)
569
+function includeFile( $file )
570 570
 {
571 571
     include $file;
572 572
 }
Please login to merge, or discard this patch.
Indentation   +514 added lines, -514 removed lines patch added patch discarded remove patch
@@ -42,519 +42,519 @@  discard block
 block discarded – undo
42 42
  */
43 43
 class ClassLoader
44 44
 {
45
-    /** @var ?string */
46
-    private $vendorDir;
47
-
48
-    // PSR-4
49
-    /**
50
-     * @var array[]
51
-     * @psalm-var array<string, array<string, int>>
52
-     */
53
-    private $prefixLengthsPsr4 = array();
54
-    /**
55
-     * @var array[]
56
-     * @psalm-var array<string, array<int, string>>
57
-     */
58
-    private $prefixDirsPsr4 = array();
59
-    /**
60
-     * @var array[]
61
-     * @psalm-var array<string, string>
62
-     */
63
-    private $fallbackDirsPsr4 = array();
64
-
65
-    // PSR-0
66
-    /**
67
-     * @var array[]
68
-     * @psalm-var array<string, array<string, string[]>>
69
-     */
70
-    private $prefixesPsr0 = array();
71
-    /**
72
-     * @var array[]
73
-     * @psalm-var array<string, string>
74
-     */
75
-    private $fallbackDirsPsr0 = array();
76
-
77
-    /** @var bool */
78
-    private $useIncludePath = false;
79
-
80
-    /**
81
-     * @var string[]
82
-     * @psalm-var array<string, string>
83
-     */
84
-    private $classMap = array();
85
-
86
-    /** @var bool */
87
-    private $classMapAuthoritative = false;
88
-
89
-    /**
90
-     * @var bool[]
91
-     * @psalm-var array<string, bool>
92
-     */
93
-    private $missingClasses = array();
94
-
95
-    /** @var ?string */
96
-    private $apcuPrefix;
97
-
98
-    /**
99
-     * @var self[]
100
-     */
101
-    private static $registeredLoaders = array();
102
-
103
-    /**
104
-     * @param ?string $vendorDir
105
-     */
106
-    public function __construct($vendorDir = null)
107
-    {
108
-        $this->vendorDir = $vendorDir;
109
-    }
110
-
111
-    /**
112
-     * @return string[]
113
-     */
114
-    public function getPrefixes()
115
-    {
116
-        if (!empty($this->prefixesPsr0)) {
117
-            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
118
-        }
119
-
120
-        return array();
121
-    }
122
-
123
-    /**
124
-     * @return array[]
125
-     * @psalm-return array<string, array<int, string>>
126
-     */
127
-    public function getPrefixesPsr4()
128
-    {
129
-        return $this->prefixDirsPsr4;
130
-    }
131
-
132
-    /**
133
-     * @return array[]
134
-     * @psalm-return array<string, string>
135
-     */
136
-    public function getFallbackDirs()
137
-    {
138
-        return $this->fallbackDirsPsr0;
139
-    }
140
-
141
-    /**
142
-     * @return array[]
143
-     * @psalm-return array<string, string>
144
-     */
145
-    public function getFallbackDirsPsr4()
146
-    {
147
-        return $this->fallbackDirsPsr4;
148
-    }
149
-
150
-    /**
151
-     * @return string[] Array of classname => path
152
-     * @psalm-return array<string, string>
153
-     */
154
-    public function getClassMap()
155
-    {
156
-        return $this->classMap;
157
-    }
158
-
159
-    /**
160
-     * @param string[] $classMap Class to filename map
161
-     * @psalm-param array<string, string> $classMap
162
-     *
163
-     * @return void
164
-     */
165
-    public function addClassMap(array $classMap)
166
-    {
167
-        if ($this->classMap) {
168
-            $this->classMap = array_merge($this->classMap, $classMap);
169
-        } else {
170
-            $this->classMap = $classMap;
171
-        }
172
-    }
173
-
174
-    /**
175
-     * Registers a set of PSR-0 directories for a given prefix, either
176
-     * appending or prepending to the ones previously set for this prefix.
177
-     *
178
-     * @param string          $prefix  The prefix
179
-     * @param string[]|string $paths   The PSR-0 root directories
180
-     * @param bool            $prepend Whether to prepend the directories
181
-     *
182
-     * @return void
183
-     */
184
-    public function add($prefix, $paths, $prepend = false)
185
-    {
186
-        if (!$prefix) {
187
-            if ($prepend) {
188
-                $this->fallbackDirsPsr0 = array_merge(
189
-                    (array) $paths,
190
-                    $this->fallbackDirsPsr0
191
-                );
192
-            } else {
193
-                $this->fallbackDirsPsr0 = array_merge(
194
-                    $this->fallbackDirsPsr0,
195
-                    (array) $paths
196
-                );
197
-            }
198
-
199
-            return;
200
-        }
201
-
202
-        $first = $prefix[0];
203
-        if (!isset($this->prefixesPsr0[$first][$prefix])) {
204
-            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
205
-
206
-            return;
207
-        }
208
-        if ($prepend) {
209
-            $this->prefixesPsr0[$first][$prefix] = array_merge(
210
-                (array) $paths,
211
-                $this->prefixesPsr0[$first][$prefix]
212
-            );
213
-        } else {
214
-            $this->prefixesPsr0[$first][$prefix] = array_merge(
215
-                $this->prefixesPsr0[$first][$prefix],
216
-                (array) $paths
217
-            );
218
-        }
219
-    }
220
-
221
-    /**
222
-     * Registers a set of PSR-4 directories for a given namespace, either
223
-     * appending or prepending to the ones previously set for this namespace.
224
-     *
225
-     * @param string          $prefix  The prefix/namespace, with trailing '\\'
226
-     * @param string[]|string $paths   The PSR-4 base directories
227
-     * @param bool            $prepend Whether to prepend the directories
228
-     *
229
-     * @throws \InvalidArgumentException
230
-     *
231
-     * @return void
232
-     */
233
-    public function addPsr4($prefix, $paths, $prepend = false)
234
-    {
235
-        if (!$prefix) {
236
-            // Register directories for the root namespace.
237
-            if ($prepend) {
238
-                $this->fallbackDirsPsr4 = array_merge(
239
-                    (array) $paths,
240
-                    $this->fallbackDirsPsr4
241
-                );
242
-            } else {
243
-                $this->fallbackDirsPsr4 = array_merge(
244
-                    $this->fallbackDirsPsr4,
245
-                    (array) $paths
246
-                );
247
-            }
248
-        } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
249
-            // Register directories for a new namespace.
250
-            $length = strlen($prefix);
251
-            if ('\\' !== $prefix[$length - 1]) {
252
-                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
253
-            }
254
-            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
255
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
256
-        } elseif ($prepend) {
257
-            // Prepend directories for an already registered namespace.
258
-            $this->prefixDirsPsr4[$prefix] = array_merge(
259
-                (array) $paths,
260
-                $this->prefixDirsPsr4[$prefix]
261
-            );
262
-        } else {
263
-            // Append directories for an already registered namespace.
264
-            $this->prefixDirsPsr4[$prefix] = array_merge(
265
-                $this->prefixDirsPsr4[$prefix],
266
-                (array) $paths
267
-            );
268
-        }
269
-    }
270
-
271
-    /**
272
-     * Registers a set of PSR-0 directories for a given prefix,
273
-     * replacing any others previously set for this prefix.
274
-     *
275
-     * @param string          $prefix The prefix
276
-     * @param string[]|string $paths  The PSR-0 base directories
277
-     *
278
-     * @return void
279
-     */
280
-    public function set($prefix, $paths)
281
-    {
282
-        if (!$prefix) {
283
-            $this->fallbackDirsPsr0 = (array) $paths;
284
-        } else {
285
-            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
286
-        }
287
-    }
288
-
289
-    /**
290
-     * Registers a set of PSR-4 directories for a given namespace,
291
-     * replacing any others previously set for this namespace.
292
-     *
293
-     * @param string          $prefix The prefix/namespace, with trailing '\\'
294
-     * @param string[]|string $paths  The PSR-4 base directories
295
-     *
296
-     * @throws \InvalidArgumentException
297
-     *
298
-     * @return void
299
-     */
300
-    public function setPsr4($prefix, $paths)
301
-    {
302
-        if (!$prefix) {
303
-            $this->fallbackDirsPsr4 = (array) $paths;
304
-        } else {
305
-            $length = strlen($prefix);
306
-            if ('\\' !== $prefix[$length - 1]) {
307
-                throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
308
-            }
309
-            $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
310
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
311
-        }
312
-    }
313
-
314
-    /**
315
-     * Turns on searching the include path for class files.
316
-     *
317
-     * @param bool $useIncludePath
318
-     *
319
-     * @return void
320
-     */
321
-    public function setUseIncludePath($useIncludePath)
322
-    {
323
-        $this->useIncludePath = $useIncludePath;
324
-    }
325
-
326
-    /**
327
-     * Can be used to check if the autoloader uses the include path to check
328
-     * for classes.
329
-     *
330
-     * @return bool
331
-     */
332
-    public function getUseIncludePath()
333
-    {
334
-        return $this->useIncludePath;
335
-    }
336
-
337
-    /**
338
-     * Turns off searching the prefix and fallback directories for classes
339
-     * that have not been registered with the class map.
340
-     *
341
-     * @param bool $classMapAuthoritative
342
-     *
343
-     * @return void
344
-     */
345
-    public function setClassMapAuthoritative($classMapAuthoritative)
346
-    {
347
-        $this->classMapAuthoritative = $classMapAuthoritative;
348
-    }
349
-
350
-    /**
351
-     * Should class lookup fail if not found in the current class map?
352
-     *
353
-     * @return bool
354
-     */
355
-    public function isClassMapAuthoritative()
356
-    {
357
-        return $this->classMapAuthoritative;
358
-    }
359
-
360
-    /**
361
-     * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362
-     *
363
-     * @param string|null $apcuPrefix
364
-     *
365
-     * @return void
366
-     */
367
-    public function setApcuPrefix($apcuPrefix)
368
-    {
369
-        $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
370
-    }
371
-
372
-    /**
373
-     * The APCu prefix in use, or null if APCu caching is not enabled.
374
-     *
375
-     * @return string|null
376
-     */
377
-    public function getApcuPrefix()
378
-    {
379
-        return $this->apcuPrefix;
380
-    }
381
-
382
-    /**
383
-     * Registers this instance as an autoloader.
384
-     *
385
-     * @param bool $prepend Whether to prepend the autoloader or not
386
-     *
387
-     * @return void
388
-     */
389
-    public function register($prepend = false)
390
-    {
391
-        spl_autoload_register(array($this, 'loadClass'), true, $prepend);
392
-
393
-        if (null === $this->vendorDir) {
394
-            return;
395
-        }
396
-
397
-        if ($prepend) {
398
-            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
399
-        } else {
400
-            unset(self::$registeredLoaders[$this->vendorDir]);
401
-            self::$registeredLoaders[$this->vendorDir] = $this;
402
-        }
403
-    }
404
-
405
-    /**
406
-     * Unregisters this instance as an autoloader.
407
-     *
408
-     * @return void
409
-     */
410
-    public function unregister()
411
-    {
412
-        spl_autoload_unregister(array($this, 'loadClass'));
413
-
414
-        if (null !== $this->vendorDir) {
415
-            unset(self::$registeredLoaders[$this->vendorDir]);
416
-        }
417
-    }
418
-
419
-    /**
420
-     * Loads the given class or interface.
421
-     *
422
-     * @param  string    $class The name of the class
423
-     * @return true|null True if loaded, null otherwise
424
-     */
425
-    public function loadClass($class)
426
-    {
427
-        if ($file = $this->findFile($class)) {
428
-            includeFile($file);
429
-
430
-            return true;
431
-        }
432
-
433
-        return null;
434
-    }
435
-
436
-    /**
437
-     * Finds the path to the file where the class is defined.
438
-     *
439
-     * @param string $class The name of the class
440
-     *
441
-     * @return string|false The path if found, false otherwise
442
-     */
443
-    public function findFile($class)
444
-    {
445
-        // class map lookup
446
-        if (isset($this->classMap[$class])) {
447
-            return $this->classMap[$class];
448
-        }
449
-        if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
450
-            return false;
451
-        }
452
-        if (null !== $this->apcuPrefix) {
453
-            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
454
-            if ($hit) {
455
-                return $file;
456
-            }
457
-        }
458
-
459
-        $file = $this->findFileWithExtension($class, '.php');
460
-
461
-        // Search for Hack files if we are running on HHVM
462
-        if (false === $file && defined('HHVM_VERSION')) {
463
-            $file = $this->findFileWithExtension($class, '.hh');
464
-        }
465
-
466
-        if (null !== $this->apcuPrefix) {
467
-            apcu_add($this->apcuPrefix.$class, $file);
468
-        }
469
-
470
-        if (false === $file) {
471
-            // Remember that this class does not exist.
472
-            $this->missingClasses[$class] = true;
473
-        }
474
-
475
-        return $file;
476
-    }
477
-
478
-    /**
479
-     * Returns the currently registered loaders indexed by their corresponding vendor directories.
480
-     *
481
-     * @return self[]
482
-     */
483
-    public static function getRegisteredLoaders()
484
-    {
485
-        return self::$registeredLoaders;
486
-    }
487
-
488
-    /**
489
-     * @param  string       $class
490
-     * @param  string       $ext
491
-     * @return string|false
492
-     */
493
-    private function findFileWithExtension($class, $ext)
494
-    {
495
-        // PSR-4 lookup
496
-        $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
497
-
498
-        $first = $class[0];
499
-        if (isset($this->prefixLengthsPsr4[$first])) {
500
-            $subPath = $class;
501
-            while (false !== $lastPos = strrpos($subPath, '\\')) {
502
-                $subPath = substr($subPath, 0, $lastPos);
503
-                $search = $subPath . '\\';
504
-                if (isset($this->prefixDirsPsr4[$search])) {
505
-                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
506
-                    foreach ($this->prefixDirsPsr4[$search] as $dir) {
507
-                        if (file_exists($file = $dir . $pathEnd)) {
508
-                            return $file;
509
-                        }
510
-                    }
511
-                }
512
-            }
513
-        }
514
-
515
-        // PSR-4 fallback dirs
516
-        foreach ($this->fallbackDirsPsr4 as $dir) {
517
-            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
518
-                return $file;
519
-            }
520
-        }
521
-
522
-        // PSR-0 lookup
523
-        if (false !== $pos = strrpos($class, '\\')) {
524
-            // namespaced class name
525
-            $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
526
-                . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
527
-        } else {
528
-            // PEAR-like class name
529
-            $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
530
-        }
531
-
532
-        if (isset($this->prefixesPsr0[$first])) {
533
-            foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
534
-                if (0 === strpos($class, $prefix)) {
535
-                    foreach ($dirs as $dir) {
536
-                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
537
-                            return $file;
538
-                        }
539
-                    }
540
-                }
541
-            }
542
-        }
543
-
544
-        // PSR-0 fallback dirs
545
-        foreach ($this->fallbackDirsPsr0 as $dir) {
546
-            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
547
-                return $file;
548
-            }
549
-        }
550
-
551
-        // PSR-0 include paths.
552
-        if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
553
-            return $file;
554
-        }
555
-
556
-        return false;
557
-    }
45
+	/** @var ?string */
46
+	private $vendorDir;
47
+
48
+	// PSR-4
49
+	/**
50
+	 * @var array[]
51
+	 * @psalm-var array<string, array<string, int>>
52
+	 */
53
+	private $prefixLengthsPsr4 = array();
54
+	/**
55
+	 * @var array[]
56
+	 * @psalm-var array<string, array<int, string>>
57
+	 */
58
+	private $prefixDirsPsr4 = array();
59
+	/**
60
+	 * @var array[]
61
+	 * @psalm-var array<string, string>
62
+	 */
63
+	private $fallbackDirsPsr4 = array();
64
+
65
+	// PSR-0
66
+	/**
67
+	 * @var array[]
68
+	 * @psalm-var array<string, array<string, string[]>>
69
+	 */
70
+	private $prefixesPsr0 = array();
71
+	/**
72
+	 * @var array[]
73
+	 * @psalm-var array<string, string>
74
+	 */
75
+	private $fallbackDirsPsr0 = array();
76
+
77
+	/** @var bool */
78
+	private $useIncludePath = false;
79
+
80
+	/**
81
+	 * @var string[]
82
+	 * @psalm-var array<string, string>
83
+	 */
84
+	private $classMap = array();
85
+
86
+	/** @var bool */
87
+	private $classMapAuthoritative = false;
88
+
89
+	/**
90
+	 * @var bool[]
91
+	 * @psalm-var array<string, bool>
92
+	 */
93
+	private $missingClasses = array();
94
+
95
+	/** @var ?string */
96
+	private $apcuPrefix;
97
+
98
+	/**
99
+	 * @var self[]
100
+	 */
101
+	private static $registeredLoaders = array();
102
+
103
+	/**
104
+	 * @param ?string $vendorDir
105
+	 */
106
+	public function __construct($vendorDir = null)
107
+	{
108
+		$this->vendorDir = $vendorDir;
109
+	}
110
+
111
+	/**
112
+	 * @return string[]
113
+	 */
114
+	public function getPrefixes()
115
+	{
116
+		if (!empty($this->prefixesPsr0)) {
117
+			return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
118
+		}
119
+
120
+		return array();
121
+	}
122
+
123
+	/**
124
+	 * @return array[]
125
+	 * @psalm-return array<string, array<int, string>>
126
+	 */
127
+	public function getPrefixesPsr4()
128
+	{
129
+		return $this->prefixDirsPsr4;
130
+	}
131
+
132
+	/**
133
+	 * @return array[]
134
+	 * @psalm-return array<string, string>
135
+	 */
136
+	public function getFallbackDirs()
137
+	{
138
+		return $this->fallbackDirsPsr0;
139
+	}
140
+
141
+	/**
142
+	 * @return array[]
143
+	 * @psalm-return array<string, string>
144
+	 */
145
+	public function getFallbackDirsPsr4()
146
+	{
147
+		return $this->fallbackDirsPsr4;
148
+	}
149
+
150
+	/**
151
+	 * @return string[] Array of classname => path
152
+	 * @psalm-return array<string, string>
153
+	 */
154
+	public function getClassMap()
155
+	{
156
+		return $this->classMap;
157
+	}
158
+
159
+	/**
160
+	 * @param string[] $classMap Class to filename map
161
+	 * @psalm-param array<string, string> $classMap
162
+	 *
163
+	 * @return void
164
+	 */
165
+	public function addClassMap(array $classMap)
166
+	{
167
+		if ($this->classMap) {
168
+			$this->classMap = array_merge($this->classMap, $classMap);
169
+		} else {
170
+			$this->classMap = $classMap;
171
+		}
172
+	}
173
+
174
+	/**
175
+	 * Registers a set of PSR-0 directories for a given prefix, either
176
+	 * appending or prepending to the ones previously set for this prefix.
177
+	 *
178
+	 * @param string          $prefix  The prefix
179
+	 * @param string[]|string $paths   The PSR-0 root directories
180
+	 * @param bool            $prepend Whether to prepend the directories
181
+	 *
182
+	 * @return void
183
+	 */
184
+	public function add($prefix, $paths, $prepend = false)
185
+	{
186
+		if (!$prefix) {
187
+			if ($prepend) {
188
+				$this->fallbackDirsPsr0 = array_merge(
189
+					(array) $paths,
190
+					$this->fallbackDirsPsr0
191
+				);
192
+			} else {
193
+				$this->fallbackDirsPsr0 = array_merge(
194
+					$this->fallbackDirsPsr0,
195
+					(array) $paths
196
+				);
197
+			}
198
+
199
+			return;
200
+		}
201
+
202
+		$first = $prefix[0];
203
+		if (!isset($this->prefixesPsr0[$first][$prefix])) {
204
+			$this->prefixesPsr0[$first][$prefix] = (array) $paths;
205
+
206
+			return;
207
+		}
208
+		if ($prepend) {
209
+			$this->prefixesPsr0[$first][$prefix] = array_merge(
210
+				(array) $paths,
211
+				$this->prefixesPsr0[$first][$prefix]
212
+			);
213
+		} else {
214
+			$this->prefixesPsr0[$first][$prefix] = array_merge(
215
+				$this->prefixesPsr0[$first][$prefix],
216
+				(array) $paths
217
+			);
218
+		}
219
+	}
220
+
221
+	/**
222
+	 * Registers a set of PSR-4 directories for a given namespace, either
223
+	 * appending or prepending to the ones previously set for this namespace.
224
+	 *
225
+	 * @param string          $prefix  The prefix/namespace, with trailing '\\'
226
+	 * @param string[]|string $paths   The PSR-4 base directories
227
+	 * @param bool            $prepend Whether to prepend the directories
228
+	 *
229
+	 * @throws \InvalidArgumentException
230
+	 *
231
+	 * @return void
232
+	 */
233
+	public function addPsr4($prefix, $paths, $prepend = false)
234
+	{
235
+		if (!$prefix) {
236
+			// Register directories for the root namespace.
237
+			if ($prepend) {
238
+				$this->fallbackDirsPsr4 = array_merge(
239
+					(array) $paths,
240
+					$this->fallbackDirsPsr4
241
+				);
242
+			} else {
243
+				$this->fallbackDirsPsr4 = array_merge(
244
+					$this->fallbackDirsPsr4,
245
+					(array) $paths
246
+				);
247
+			}
248
+		} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
249
+			// Register directories for a new namespace.
250
+			$length = strlen($prefix);
251
+			if ('\\' !== $prefix[$length - 1]) {
252
+				throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
253
+			}
254
+			$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
255
+			$this->prefixDirsPsr4[$prefix] = (array) $paths;
256
+		} elseif ($prepend) {
257
+			// Prepend directories for an already registered namespace.
258
+			$this->prefixDirsPsr4[$prefix] = array_merge(
259
+				(array) $paths,
260
+				$this->prefixDirsPsr4[$prefix]
261
+			);
262
+		} else {
263
+			// Append directories for an already registered namespace.
264
+			$this->prefixDirsPsr4[$prefix] = array_merge(
265
+				$this->prefixDirsPsr4[$prefix],
266
+				(array) $paths
267
+			);
268
+		}
269
+	}
270
+
271
+	/**
272
+	 * Registers a set of PSR-0 directories for a given prefix,
273
+	 * replacing any others previously set for this prefix.
274
+	 *
275
+	 * @param string          $prefix The prefix
276
+	 * @param string[]|string $paths  The PSR-0 base directories
277
+	 *
278
+	 * @return void
279
+	 */
280
+	public function set($prefix, $paths)
281
+	{
282
+		if (!$prefix) {
283
+			$this->fallbackDirsPsr0 = (array) $paths;
284
+		} else {
285
+			$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
286
+		}
287
+	}
288
+
289
+	/**
290
+	 * Registers a set of PSR-4 directories for a given namespace,
291
+	 * replacing any others previously set for this namespace.
292
+	 *
293
+	 * @param string          $prefix The prefix/namespace, with trailing '\\'
294
+	 * @param string[]|string $paths  The PSR-4 base directories
295
+	 *
296
+	 * @throws \InvalidArgumentException
297
+	 *
298
+	 * @return void
299
+	 */
300
+	public function setPsr4($prefix, $paths)
301
+	{
302
+		if (!$prefix) {
303
+			$this->fallbackDirsPsr4 = (array) $paths;
304
+		} else {
305
+			$length = strlen($prefix);
306
+			if ('\\' !== $prefix[$length - 1]) {
307
+				throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
308
+			}
309
+			$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
310
+			$this->prefixDirsPsr4[$prefix] = (array) $paths;
311
+		}
312
+	}
313
+
314
+	/**
315
+	 * Turns on searching the include path for class files.
316
+	 *
317
+	 * @param bool $useIncludePath
318
+	 *
319
+	 * @return void
320
+	 */
321
+	public function setUseIncludePath($useIncludePath)
322
+	{
323
+		$this->useIncludePath = $useIncludePath;
324
+	}
325
+
326
+	/**
327
+	 * Can be used to check if the autoloader uses the include path to check
328
+	 * for classes.
329
+	 *
330
+	 * @return bool
331
+	 */
332
+	public function getUseIncludePath()
333
+	{
334
+		return $this->useIncludePath;
335
+	}
336
+
337
+	/**
338
+	 * Turns off searching the prefix and fallback directories for classes
339
+	 * that have not been registered with the class map.
340
+	 *
341
+	 * @param bool $classMapAuthoritative
342
+	 *
343
+	 * @return void
344
+	 */
345
+	public function setClassMapAuthoritative($classMapAuthoritative)
346
+	{
347
+		$this->classMapAuthoritative = $classMapAuthoritative;
348
+	}
349
+
350
+	/**
351
+	 * Should class lookup fail if not found in the current class map?
352
+	 *
353
+	 * @return bool
354
+	 */
355
+	public function isClassMapAuthoritative()
356
+	{
357
+		return $this->classMapAuthoritative;
358
+	}
359
+
360
+	/**
361
+	 * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362
+	 *
363
+	 * @param string|null $apcuPrefix
364
+	 *
365
+	 * @return void
366
+	 */
367
+	public function setApcuPrefix($apcuPrefix)
368
+	{
369
+		$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
370
+	}
371
+
372
+	/**
373
+	 * The APCu prefix in use, or null if APCu caching is not enabled.
374
+	 *
375
+	 * @return string|null
376
+	 */
377
+	public function getApcuPrefix()
378
+	{
379
+		return $this->apcuPrefix;
380
+	}
381
+
382
+	/**
383
+	 * Registers this instance as an autoloader.
384
+	 *
385
+	 * @param bool $prepend Whether to prepend the autoloader or not
386
+	 *
387
+	 * @return void
388
+	 */
389
+	public function register($prepend = false)
390
+	{
391
+		spl_autoload_register(array($this, 'loadClass'), true, $prepend);
392
+
393
+		if (null === $this->vendorDir) {
394
+			return;
395
+		}
396
+
397
+		if ($prepend) {
398
+			self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
399
+		} else {
400
+			unset(self::$registeredLoaders[$this->vendorDir]);
401
+			self::$registeredLoaders[$this->vendorDir] = $this;
402
+		}
403
+	}
404
+
405
+	/**
406
+	 * Unregisters this instance as an autoloader.
407
+	 *
408
+	 * @return void
409
+	 */
410
+	public function unregister()
411
+	{
412
+		spl_autoload_unregister(array($this, 'loadClass'));
413
+
414
+		if (null !== $this->vendorDir) {
415
+			unset(self::$registeredLoaders[$this->vendorDir]);
416
+		}
417
+	}
418
+
419
+	/**
420
+	 * Loads the given class or interface.
421
+	 *
422
+	 * @param  string    $class The name of the class
423
+	 * @return true|null True if loaded, null otherwise
424
+	 */
425
+	public function loadClass($class)
426
+	{
427
+		if ($file = $this->findFile($class)) {
428
+			includeFile($file);
429
+
430
+			return true;
431
+		}
432
+
433
+		return null;
434
+	}
435
+
436
+	/**
437
+	 * Finds the path to the file where the class is defined.
438
+	 *
439
+	 * @param string $class The name of the class
440
+	 *
441
+	 * @return string|false The path if found, false otherwise
442
+	 */
443
+	public function findFile($class)
444
+	{
445
+		// class map lookup
446
+		if (isset($this->classMap[$class])) {
447
+			return $this->classMap[$class];
448
+		}
449
+		if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
450
+			return false;
451
+		}
452
+		if (null !== $this->apcuPrefix) {
453
+			$file = apcu_fetch($this->apcuPrefix.$class, $hit);
454
+			if ($hit) {
455
+				return $file;
456
+			}
457
+		}
458
+
459
+		$file = $this->findFileWithExtension($class, '.php');
460
+
461
+		// Search for Hack files if we are running on HHVM
462
+		if (false === $file && defined('HHVM_VERSION')) {
463
+			$file = $this->findFileWithExtension($class, '.hh');
464
+		}
465
+
466
+		if (null !== $this->apcuPrefix) {
467
+			apcu_add($this->apcuPrefix.$class, $file);
468
+		}
469
+
470
+		if (false === $file) {
471
+			// Remember that this class does not exist.
472
+			$this->missingClasses[$class] = true;
473
+		}
474
+
475
+		return $file;
476
+	}
477
+
478
+	/**
479
+	 * Returns the currently registered loaders indexed by their corresponding vendor directories.
480
+	 *
481
+	 * @return self[]
482
+	 */
483
+	public static function getRegisteredLoaders()
484
+	{
485
+		return self::$registeredLoaders;
486
+	}
487
+
488
+	/**
489
+	 * @param  string       $class
490
+	 * @param  string       $ext
491
+	 * @return string|false
492
+	 */
493
+	private function findFileWithExtension($class, $ext)
494
+	{
495
+		// PSR-4 lookup
496
+		$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
497
+
498
+		$first = $class[0];
499
+		if (isset($this->prefixLengthsPsr4[$first])) {
500
+			$subPath = $class;
501
+			while (false !== $lastPos = strrpos($subPath, '\\')) {
502
+				$subPath = substr($subPath, 0, $lastPos);
503
+				$search = $subPath . '\\';
504
+				if (isset($this->prefixDirsPsr4[$search])) {
505
+					$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
506
+					foreach ($this->prefixDirsPsr4[$search] as $dir) {
507
+						if (file_exists($file = $dir . $pathEnd)) {
508
+							return $file;
509
+						}
510
+					}
511
+				}
512
+			}
513
+		}
514
+
515
+		// PSR-4 fallback dirs
516
+		foreach ($this->fallbackDirsPsr4 as $dir) {
517
+			if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
518
+				return $file;
519
+			}
520
+		}
521
+
522
+		// PSR-0 lookup
523
+		if (false !== $pos = strrpos($class, '\\')) {
524
+			// namespaced class name
525
+			$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
526
+				. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
527
+		} else {
528
+			// PEAR-like class name
529
+			$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
530
+		}
531
+
532
+		if (isset($this->prefixesPsr0[$first])) {
533
+			foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
534
+				if (0 === strpos($class, $prefix)) {
535
+					foreach ($dirs as $dir) {
536
+						if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
537
+							return $file;
538
+						}
539
+					}
540
+				}
541
+			}
542
+		}
543
+
544
+		// PSR-0 fallback dirs
545
+		foreach ($this->fallbackDirsPsr0 as $dir) {
546
+			if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
547
+				return $file;
548
+			}
549
+		}
550
+
551
+		// PSR-0 include paths.
552
+		if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
553
+			return $file;
554
+		}
555
+
556
+		return false;
557
+	}
558 558
 }
559 559
 
560 560
 /**
@@ -568,5 +568,5 @@  discard block
 block discarded – undo
568 568
  */
569 569
 function includeFile($file)
570 570
 {
571
-    include $file;
571
+	include $file;
572 572
 }
Please login to merge, or discard this patch.
Braces   +25 added lines, -50 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
  * @see    https://www.php-fig.org/psr/psr-0/
41 41
  * @see    https://www.php-fig.org/psr/psr-4/
42 42
  */
43
-class ClassLoader
44
-{
43
+class ClassLoader {
45 44
     /** @var ?string */
46 45
     private $vendorDir;
47 46
 
@@ -103,16 +102,14 @@  discard block
 block discarded – undo
103 102
     /**
104 103
      * @param ?string $vendorDir
105 104
      */
106
-    public function __construct($vendorDir = null)
107
-    {
105
+    public function __construct($vendorDir = null) {
108 106
         $this->vendorDir = $vendorDir;
109 107
     }
110 108
 
111 109
     /**
112 110
      * @return string[]
113 111
      */
114
-    public function getPrefixes()
115
-    {
112
+    public function getPrefixes() {
116 113
         if (!empty($this->prefixesPsr0)) {
117 114
             return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
118 115
         }
@@ -124,8 +121,7 @@  discard block
 block discarded – undo
124 121
      * @return array[]
125 122
      * @psalm-return array<string, array<int, string>>
126 123
      */
127
-    public function getPrefixesPsr4()
128
-    {
124
+    public function getPrefixesPsr4() {
129 125
         return $this->prefixDirsPsr4;
130 126
     }
131 127
 
@@ -133,8 +129,7 @@  discard block
 block discarded – undo
133 129
      * @return array[]
134 130
      * @psalm-return array<string, string>
135 131
      */
136
-    public function getFallbackDirs()
137
-    {
132
+    public function getFallbackDirs() {
138 133
         return $this->fallbackDirsPsr0;
139 134
     }
140 135
 
@@ -142,8 +137,7 @@  discard block
 block discarded – undo
142 137
      * @return array[]
143 138
      * @psalm-return array<string, string>
144 139
      */
145
-    public function getFallbackDirsPsr4()
146
-    {
140
+    public function getFallbackDirsPsr4() {
147 141
         return $this->fallbackDirsPsr4;
148 142
     }
149 143
 
@@ -151,8 +145,7 @@  discard block
 block discarded – undo
151 145
      * @return string[] Array of classname => path
152 146
      * @psalm-return array<string, string>
153 147
      */
154
-    public function getClassMap()
155
-    {
148
+    public function getClassMap() {
156 149
         return $this->classMap;
157 150
     }
158 151
 
@@ -162,8 +155,7 @@  discard block
 block discarded – undo
162 155
      *
163 156
      * @return void
164 157
      */
165
-    public function addClassMap(array $classMap)
166
-    {
158
+    public function addClassMap(array $classMap) {
167 159
         if ($this->classMap) {
168 160
             $this->classMap = array_merge($this->classMap, $classMap);
169 161
         } else {
@@ -181,8 +173,7 @@  discard block
 block discarded – undo
181 173
      *
182 174
      * @return void
183 175
      */
184
-    public function add($prefix, $paths, $prepend = false)
185
-    {
176
+    public function add($prefix, $paths, $prepend = false) {
186 177
         if (!$prefix) {
187 178
             if ($prepend) {
188 179
                 $this->fallbackDirsPsr0 = array_merge(
@@ -230,8 +221,7 @@  discard block
 block discarded – undo
230 221
      *
231 222
      * @return void
232 223
      */
233
-    public function addPsr4($prefix, $paths, $prepend = false)
234
-    {
224
+    public function addPsr4($prefix, $paths, $prepend = false) {
235 225
         if (!$prefix) {
236 226
             // Register directories for the root namespace.
237 227
             if ($prepend) {
@@ -277,8 +267,7 @@  discard block
 block discarded – undo
277 267
      *
278 268
      * @return void
279 269
      */
280
-    public function set($prefix, $paths)
281
-    {
270
+    public function set($prefix, $paths) {
282 271
         if (!$prefix) {
283 272
             $this->fallbackDirsPsr0 = (array) $paths;
284 273
         } else {
@@ -297,8 +286,7 @@  discard block
 block discarded – undo
297 286
      *
298 287
      * @return void
299 288
      */
300
-    public function setPsr4($prefix, $paths)
301
-    {
289
+    public function setPsr4($prefix, $paths) {
302 290
         if (!$prefix) {
303 291
             $this->fallbackDirsPsr4 = (array) $paths;
304 292
         } else {
@@ -318,8 +306,7 @@  discard block
 block discarded – undo
318 306
      *
319 307
      * @return void
320 308
      */
321
-    public function setUseIncludePath($useIncludePath)
322
-    {
309
+    public function setUseIncludePath($useIncludePath) {
323 310
         $this->useIncludePath = $useIncludePath;
324 311
     }
325 312
 
@@ -329,8 +316,7 @@  discard block
 block discarded – undo
329 316
      *
330 317
      * @return bool
331 318
      */
332
-    public function getUseIncludePath()
333
-    {
319
+    public function getUseIncludePath() {
334 320
         return $this->useIncludePath;
335 321
     }
336 322
 
@@ -342,8 +328,7 @@  discard block
 block discarded – undo
342 328
      *
343 329
      * @return void
344 330
      */
345
-    public function setClassMapAuthoritative($classMapAuthoritative)
346
-    {
331
+    public function setClassMapAuthoritative($classMapAuthoritative) {
347 332
         $this->classMapAuthoritative = $classMapAuthoritative;
348 333
     }
349 334
 
@@ -352,8 +337,7 @@  discard block
 block discarded – undo
352 337
      *
353 338
      * @return bool
354 339
      */
355
-    public function isClassMapAuthoritative()
356
-    {
340
+    public function isClassMapAuthoritative() {
357 341
         return $this->classMapAuthoritative;
358 342
     }
359 343
 
@@ -364,8 +348,7 @@  discard block
 block discarded – undo
364 348
      *
365 349
      * @return void
366 350
      */
367
-    public function setApcuPrefix($apcuPrefix)
368
-    {
351
+    public function setApcuPrefix($apcuPrefix) {
369 352
         $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
370 353
     }
371 354
 
@@ -374,8 +357,7 @@  discard block
 block discarded – undo
374 357
      *
375 358
      * @return string|null
376 359
      */
377
-    public function getApcuPrefix()
378
-    {
360
+    public function getApcuPrefix() {
379 361
         return $this->apcuPrefix;
380 362
     }
381 363
 
@@ -386,8 +368,7 @@  discard block
 block discarded – undo
386 368
      *
387 369
      * @return void
388 370
      */
389
-    public function register($prepend = false)
390
-    {
371
+    public function register($prepend = false) {
391 372
         spl_autoload_register(array($this, 'loadClass'), true, $prepend);
392 373
 
393 374
         if (null === $this->vendorDir) {
@@ -407,8 +388,7 @@  discard block
 block discarded – undo
407 388
      *
408 389
      * @return void
409 390
      */
410
-    public function unregister()
411
-    {
391
+    public function unregister() {
412 392
         spl_autoload_unregister(array($this, 'loadClass'));
413 393
 
414 394
         if (null !== $this->vendorDir) {
@@ -422,8 +402,7 @@  discard block
 block discarded – undo
422 402
      * @param  string    $class The name of the class
423 403
      * @return true|null True if loaded, null otherwise
424 404
      */
425
-    public function loadClass($class)
426
-    {
405
+    public function loadClass($class) {
427 406
         if ($file = $this->findFile($class)) {
428 407
             includeFile($file);
429 408
 
@@ -440,8 +419,7 @@  discard block
 block discarded – undo
440 419
      *
441 420
      * @return string|false The path if found, false otherwise
442 421
      */
443
-    public function findFile($class)
444
-    {
422
+    public function findFile($class) {
445 423
         // class map lookup
446 424
         if (isset($this->classMap[$class])) {
447 425
             return $this->classMap[$class];
@@ -480,8 +458,7 @@  discard block
 block discarded – undo
480 458
      *
481 459
      * @return self[]
482 460
      */
483
-    public static function getRegisteredLoaders()
484
-    {
461
+    public static function getRegisteredLoaders() {
485 462
         return self::$registeredLoaders;
486 463
     }
487 464
 
@@ -490,8 +467,7 @@  discard block
 block discarded – undo
490 467
      * @param  string       $ext
491 468
      * @return string|false
492 469
      */
493
-    private function findFileWithExtension($class, $ext)
494
-    {
470
+    private function findFileWithExtension($class, $ext) {
495 471
         // PSR-4 lookup
496 472
         $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
497 473
 
@@ -566,7 +542,6 @@  discard block
 block discarded – undo
566 542
  * @return void
567 543
  * @private
568 544
  */
569
-function includeFile($file)
570
-{
545
+function includeFile($file) {
571 546
     include $file;
572 547
 }
Please login to merge, or discard this patch.