Skip to content

Commit

Permalink
Revert Abstract_File_Check changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshpanchal27 committed Nov 8, 2023
1 parent aff7d05 commit 6c6c3df
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions includes/Checker/Checks/Abstract_File_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Exception;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use WordPress\Plugin_Check\Checker\Check_Context;
use WordPress\Plugin_Check\Checker\Check_Result;
use WordPress\Plugin_Check\Checker\Static_Check;
use WordPress\Plugin_Check\Utilities\Plugin_Request_Utility;
Expand Down Expand Up @@ -48,7 +49,7 @@ abstract class Abstract_File_Check implements Static_Check {
* the check).
*/
final public function run( Check_Result $result ) {
$files = self::get_files( $result );
$files = self::get_files( $result->plugin() );
$this->check_files( $result, $files );
}

Expand Down Expand Up @@ -188,11 +189,11 @@ private static function file_get_contents( $file ) {
*
* @since n.e.x.t
*
* @param Check_Result $result The Check Result to amend.
* @param Check_Context $plugin Context for the plugin to check.
* @return array List of absolute file paths.
*/
private static function get_files( Check_Result $result ) {
$location = $result->plugin()->location();
private static function get_files( Check_Context $plugin ) {
$location = $plugin->location();

if ( isset( self::$file_list_cache[ $location ] ) ) {
return self::$file_list_cache[ $location ];
Expand All @@ -202,9 +203,7 @@ private static function get_files( Check_Result $result ) {

// If the location is a plugin folder, get all its files.
// Otherwise, it is a single-file plugin.
if ( Plugin_Request_Utility::is_single_file_plugin( $result ) ) {
self::$file_list_cache[ $location ][] = $location;
} else {
if ( $plugin->path() === $location ) {
$iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $location ) );
foreach ( $iterator as $file ) {
if ( ! $file->isFile() ) {
Expand All @@ -230,6 +229,8 @@ private static function get_files( Check_Result $result ) {
self::$file_list_cache[ $location ][] = $file_path;
}
}
} else {
self::$file_list_cache[ $location ][] = $location;
}

return self::$file_list_cache[ $location ];
Expand Down

0 comments on commit 6c6c3df

Please sign in to comment.