$file_metadata) { // Check if it's a PHP file in the same directory if (dirname($path) !== $dir_path) { continue; } // Check if it's a bundle class if (isset($file_metadata['class']) && isset($file_metadata['extends'])) { $file_extends = $file_metadata['extends']; if ($file_extends === 'Rsx_Bundle_Abstract' || $file_extends === 'App\\RSpade\\Core\\Bundle\\Rsx_Bundle_Abstract') { $bundles_in_same_dir[] = basename($path, '.php'); } } } // If there's more than one bundle in this directory, throw an exception if (count($bundles_in_same_dir) > 1) { $error_message = "Code Quality Violation (CONV-BUNDLE-03) - Multiple Bundles in Same Directory\n\n"; $error_message .= "Module directory '{$dir_path}' has multiple bundle files:\n"; foreach ($bundles_in_same_dir as $bundle_name) { $error_message .= " - {$bundle_name}.php\n"; } $error_message .= "\nCRITICAL: Each module directory should have only ONE bundle.\n\n"; $error_message .= "Resolution:\n"; $error_message .= "1. Consolidate these bundles into a single bundle file\n"; $error_message .= "2. OR move extra bundles to their own module directories\n"; $error_message .= "3. OR move them to ./rsx/app/ (which allows multiple bundles)\n\n"; $error_message .= "This convention ensures clean module organization and predictable bundle loading."; throw new \App\RSpade\CodeQuality\RuntimeChecks\YoureDoingItWrongException( $error_message, 0, null, $file_path, 1 ); } } }