# 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"

- **ID:** `php/composer-outdated-autoload`
- **Domain:** php
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| composer 2.6 | active | — | — |
| composer 2.7 | active | — | — |
| php 8.1 | active | — | — |
| php 8.2 | active | — | — |

## Workarounds

1. **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.** (90% success)
   ```
   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.
   ```
2. **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.** (95% success)
   ```
   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.
   ```

## Dead Ends

- **Clearing the Composer cache with `composer clear-cache`** — The cache clear does not fix the underlying duplicate class mapping; it only removes cached metadata. (80% fail)
- **Renaming one of the files without updating the namespace** — 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. (95% fail)
