create-prisma-php-app 1.26.526 → 1.26.528

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -706,49 +706,54 @@ register_shutdown_function(function () {
706
706
  }
707
707
  });
708
708
 
709
- spl_autoload_register(function ($class) {
710
- // Path to the log file
711
- $logFile = SETTINGS_PATH . '/class-log.json';
709
+ spl_autoload_register(
710
+ function ($class) {
711
+ // Path to the log file
712
+ $logFile = SETTINGS_PATH . "/class-log.json";
712
713
 
713
- // Check if the file exists
714
- if (!file_exists($logFile)) {
715
- // Create an empty JSON file
716
- file_put_contents($logFile, json_encode([]));
717
- }
714
+ // Ensure the log file exists
715
+ if (!file_exists($logFile)) {
716
+ file_put_contents($logFile, json_encode([]));
717
+ }
718
+
719
+ // Read the existing log data
720
+ $logData = json_decode(file_get_contents($logFile), true) ?? [];
718
721
 
719
- // Read the current log data
720
- $logData = json_decode(file_get_contents($logFile), true) ?? [];
722
+ // Determine the file path for the class
723
+ $classParts = explode('\\', $class);
724
+ $filePath = __DIR__ . '/src/' . implode('/', $classParts) . '.php';
721
725
 
722
- // Attempt to load the class file and get the file path
723
- $classParts = explode('\\', $class);
724
- $filePath = __DIR__ . '/src/' . implode('/', $classParts) . '.php';
726
+ // Attempt to load the file
727
+ if (file_exists($filePath)) {
728
+ // Track previously declared classes
729
+ $previousClasses = get_declared_classes();
725
730
 
726
- // Require the file if it exists
727
- if (file_exists($filePath)) {
728
- require_once $filePath;
731
+ // Require the file
732
+ require_once $filePath;
729
733
 
730
- // After loading the file, check all declared classes
731
- $declaredClasses = get_declared_classes();
732
- foreach ($declaredClasses as $declaredClass) {
733
- $reflectionClass = new ReflectionClass($declaredClass);
734
+ // Find newly declared classes
735
+ $newClasses = array_diff(get_declared_classes(), $previousClasses);
736
+
737
+ // Process all new classes from the file
738
+ foreach ($newClasses as $newClass) {
739
+ $reflectionClass = new ReflectionClass($newClass);
734
740
 
735
- // Ensure the class is in the same namespace as the loaded class
736
- $classNamespace = implode('\\', $classParts);
737
- if (strpos($declaredClass, $classNamespace) === 0) {
738
741
  // Check if the class implements IPHPX
739
742
  if ($reflectionClass->implementsInterface(IPHPX::class)) {
740
- $logData[$declaredClass] = [
741
- 'class_name' => $declaredClass,
743
+ $logData[$newClass] = [
744
+ 'class_name' => $newClass,
742
745
  'file_path' => $filePath,
743
746
  ];
744
747
  }
745
748
  }
746
749
  }
747
- }
748
750
 
749
- // Save back to the JSON file
750
- file_put_contents($logFile, json_encode($logData, JSON_PRETTY_PRINT));
751
- }, true, true);
751
+ // Save back to the JSON file
752
+ file_put_contents($logFile, json_encode($logData, JSON_PRETTY_PRINT));
753
+ },
754
+ true,
755
+ true
756
+ );
752
757
 
753
758
  try {
754
759
  $_determineContentToInclude = determineContentToInclude();