diff --git a/phpBB/phpbb/finder/factory.php b/phpBB/phpbb/finder/factory.php index 3022f5ea9d..0ce087b061 100644 --- a/phpBB/phpbb/finder/factory.php +++ b/phpBB/phpbb/finder/factory.php @@ -13,6 +13,8 @@ namespace phpbb\finder; +use phpbb\cache\service; + /** * The finder provides a simple way to locate files in the core and a set of extensions */ @@ -26,12 +28,12 @@ class factory /** * Creates a new finder instance with its dependencies * - * @param \phpbb\cache\service $cache A cache instance or null + * @param service|null $cache A cache instance or null * @param bool $use_cache Use cache or not * @param string $phpbb_root_path Path to the phpbb root directory * @param string $php_ext php file extension */ - public function __construct(/*\phpbb\cache\service */ $cache, $use_cache, $phpbb_root_path, $php_ext) + public function __construct(?service $cache, bool $use_cache, string $phpbb_root_path, string $php_ext) { $this->cache = $cache; $this->use_cache = $use_cache; @@ -44,10 +46,10 @@ class factory * * Allows the use of multiple differently configured finders with the same cache. * - * @param string $cache_name The name of the cache variable, defaults to - * _ext_finder + * @param string $cache_name The name of the cache variable, defaults to _ext_finder + * @return finder New instance of finder */ - public function get($cache_name = '_ext_finder') + public function get(string $cache_name = '_ext_finder'): finder { return new finder($this->cache, $this->use_cache, $this->phpbb_root_path, $this->php_ext, $cache_name); } diff --git a/phpBB/phpbb/finder/finder.php b/phpBB/phpbb/finder/finder.php index 5c88396299..6b0baef19f 100644 --- a/phpBB/phpbb/finder/finder.php +++ b/phpBB/phpbb/finder/finder.php @@ -13,6 +13,7 @@ namespace phpbb\finder; +use phpbb\cache\service; use phpbb\filesystem\helper as filesystem_helper; /** @@ -51,12 +52,13 @@ class finder * Creates a new finder instance with its dependencies * * @param string $phpbb_root_path Path to the phpbb root directory - * @param \phpbb\cache\service|null $cache A cache instance or null + * @param service|null $cache A cache instance or null + * @param bool $use_cache Flag whether cache should be used * @param string $php_ext php file extension * @param string $cache_name The name of the cache variable, defaults to - * _ext_finder + * _ext_finder */ - public function __construct(/*\phpbb\cache\service */ $cache, $use_cache, $phpbb_root_path, $php_ext, $cache_name = '_ext_finder') + public function __construct(?service $cache, bool $use_cache, string $phpbb_root_path, string $php_ext, string $cache_name = '_ext_finder') { $this->phpbb_root_path = $phpbb_root_path; $this->cache = $cache; diff --git a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php index 695ec86143..984ca3461e 100644 --- a/phpBB/phpbb/install/module/install_database/task/create_schema_file.php +++ b/phpBB/phpbb/install/module/install_database/task/create_schema_file.php @@ -46,7 +46,7 @@ class create_schema_file extends \phpbb\install\task_base protected $php_ext; /** - * @var string + * @var bool */ protected $finder_cache; @@ -58,6 +58,7 @@ class create_schema_file extends \phpbb\install\task_base * @param \phpbb\filesystem\filesystem_interface $filesystem Filesystem service * @param string $phpbb_root_path Path phpBB's root * @param string $php_ext Extension of PHP files + * @param bool $finder_cache Flag whether to cache finder */ public function __construct(\phpbb\install\helper\config $config, \phpbb\install\helper\database $db_helper, @@ -124,7 +125,8 @@ class create_schema_file extends \phpbb\install\task_base include ($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); } - $finder = new \phpbb\finder\finder(null, $this->finder_cache, $this->phpbb_root_path, $this->php_ext); + $finder_factory = new \phpbb\finder\factory(null, $this->finder_cache, $this->phpbb_root_path, $this->php_ext); + $finder = $finder_factory->get(); $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($this->db, true);