Skip to content

Commit

Permalink
fix bug added in b6ceeef
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Nov 30, 2023
1 parent a09d7af commit 869c0ff
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,11 @@ public function __invoke( RegistrationInterface $registration, ?SimpleXMLElement
$base_dir = getcwd();
}

/**
* @var array<string, array{name: string, recursive?: string}> $hook_data
*/
foreach ( $config->hooks as $hook_data ) {
foreach ( $hook_data as $type => $data ) {
if ( $type === 'file' ) {
$file = $data['name'];
// this is a SimpleXmlElement, therefore we need to cast it to string!
$file = (string) $data['name'];
if ( $file[0] !== '/' ) {
$file = $base_dir . '/' . $file;
}
Expand All @@ -131,7 +129,7 @@ public function __invoke( RegistrationInterface $registration, ?SimpleXMLElement
// File as key, to avoid loading the same hooks multiple times.
$hooks[ $file ] = $file;
} elseif ( $type === 'directory' ) {
$directory = rtrim( $data['name'], '/' );
$directory = rtrim( (string) $data['name'], '/' );
if ( $directory[0] !== '/' ) {
$directory = $base_dir . '/' . $directory;
}
Expand All @@ -142,7 +140,7 @@ public function __invoke( RegistrationInterface $registration, ?SimpleXMLElement
);
}

if ( isset( $data['recursive'] ) && $data['recursive'] === 'true' ) {
if ( isset( $data['recursive'] ) && (string) $data['recursive'] === 'true' ) {
$directories = glob( $directory . '/*', GLOB_ONLYDIR );
}

Expand Down

0 comments on commit 869c0ff

Please sign in to comment.