Skip to content

Commit

Permalink
use strict type checks for in_array() in autoloader function (#222)
Browse files Browse the repository at this point in the history
Update instances of in_array() to use strict checks to prevent odd
results in some cases and add wp-cli comment till 
wp-cli/wp-cli#4862 is closed.

Co-authored-by: Stefan Kalscheuer <stefan@stklcode.de>
  • Loading branch information
timse201 and stklcode committed Oct 28, 2021
1 parent e8f081a commit cc298c4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cachify.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
)
);

/* WP-CLI */
/* WP-CLI - cli_init does loading checks itself */
add_action(
'cli_init',
array(
Expand All @@ -82,7 +82,7 @@
)
);

/* Autoload Init */
/* Register autoload */
spl_autoload_register( 'cachify_autoload' );

/**
Expand All @@ -91,13 +91,11 @@
* @param string $class the class name.
*/
function cachify_autoload( $class ) {
if ( in_array( $class, array( 'Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_CLI' ) ) ) {
require_once(
sprintf(
'%s/inc/class-%s.php',
CACHIFY_DIR,
strtolower( str_replace( '_', '-', $class ) )
)
if ( in_array( $class, array( 'Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_CLI' ), true ) ) {
require_once sprintf(
'%s/inc/class-%s.php',
CACHIFY_DIR,
strtolower( str_replace( '_', '-', $class ) )
);
}
}

0 comments on commit cc298c4

Please sign in to comment.