From 60a0c5fa1fb29f28d9499f1d93124dcf291ba0ac Mon Sep 17 00:00:00 2001 From: Kaiser <24-7@gmx.net> Date: Fri, 23 Jan 2015 11:52:42 +0100 Subject: [PATCH] Update command loader to 5.3+ FilesystemIterator Use the `\FilesystemIterator` as we live in a PHP 5.3 world --- php/utils.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/php/utils.php b/php/utils.php index 79b055b4ae..f30c2303f7 100644 --- a/php/utils.php +++ b/php/utils.php @@ -50,15 +50,11 @@ function load_command( $name ) { } function load_all_commands() { - $cmd_dir = WP_CLI_ROOT . '/php/commands'; - - $iterator = new \DirectoryIterator( $cmd_dir ); - - foreach ( $iterator as $filename ) { - if ( '.php' != substr( $filename, -4 ) ) - continue; - - include_once "$cmd_dir/$filename"; + $files = new \FilesystemIterator( WP_CLI_ROOT . '/php/commands', \FilesystemIterator::SKIP_DOTS ); + foreach ( $files as $file ) + { + /** @noinspection PhpIncludeInspection */ + ! $files->isDir() and include_once $files->getRealPath(); } }