{
  "id": "php/composer-outdated-autoload",
  "signature": "Warning: Ambiguous class resolution, \"App\\Models\\User\" was found in both \"/var/www/app/src/Models/User.php\" and \"/var/www/app/src/Models/Admin/User.php\"",
  "signature_zh": "警告：类名解析歧义，“App\\Models\\User”同时存在于“/var/www/app/src/Models/User.php”和“/var/www/app/src/Models/Admin/User.php”中",
  "regex": "Warning: Ambiguous class resolution, \"[A-Za-z0-9\\\\]+\\\" was found in both \"[^\"]+\" and \"[^\"]+\"",
  "domain": "php",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "Composer's autoloader detects two files that both declare the same fully-qualified class name due to overlapping namespace-to-directory mappings or duplicate class definitions in different files.",
  "root_cause_type": "generic",
  "root_cause_zh": "Composer 自动加载器检测到两个文件声明了相同的完全限定类名，原因是命名空间到目录的映射重叠或不同文件中存在重复的类定义。",
  "versions": [
    {
      "version": "composer 2.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "composer 2.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "php 8.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "php 8.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Clearing the Composer cache with `composer clear-cache`",
      "why_fails": "The cache clear does not fix the underlying duplicate class mapping; it only removes cached metadata.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Renaming one of the files without updating the namespace",
      "why_fails": "The class name is defined by the namespace and class declaration in the file, not the filename; renaming the file without changing the class declaration does not resolve the ambiguity.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Run `composer dump-autoload -o` to regenerate the optimized autoload map, then check the generated `vendor/composer/autoload_classmap.php` for duplicate entries and remove the incorrect one.",
      "success_rate": 0.9,
      "how": "Run `composer dump-autoload -o` to regenerate the optimized autoload map, then check the generated `vendor/composer/autoload_classmap.php` for duplicate entries and remove the incorrect one.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Refactor the namespace: move `App\\Models\\Admin\\User` to a distinct namespace like `App\\Models\\AdminUser` or adjust the PSR-4 prefix in `composer.json` to avoid overlap.",
      "success_rate": 0.95,
      "how": "Refactor the namespace: move `App\\Models\\Admin\\User` to a distinct namespace like `App\\Models\\AdminUser` or adjust the PSR-4 prefix in `composer.json` to avoid overlap.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Run `composer dump-autoload -o` to regenerate the optimized autoload map, then check the generated `vendor/composer/autoload_classmap.php` for duplicate entries and remove the incorrect one.",
    "Refactor the namespace: move `App\\Models\\Admin\\User` to a distinct namespace like `App\\Models\\AdminUser` or adjust the PSR-4 prefix in `composer.json` to avoid overlap."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://getcomposer.org/doc/04-schema.md#autoload",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}