# 致命错误: 未捕获的错误: 不能将 'App\Models\User' 用作 trait，位于 /var/www/app/src/Models/Admin.php:10

- **ID:** `php/class-not-final-extends`
- **领域:** php
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

PHP 的 use 语句被误解为 trait 上下文，通常是因为开发者在类体内错误地写了 'use App\Models\User;' 而不是继承它，或者该类未声明为 trait。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| PHP 8.0 | active | — | — |
| PHP 8.1 | active | — | — |
| PHP 8.2 | active | — | — |
| PHP 8.3 | active | — | — |

## 解决方案

1. ```
   Replace 'use App\Models\User;' inside the class body with 'class Admin extends \App\Models\User' to properly inherit from the class.
   ```
2. ```
   If the intent is to use a trait, ensure the source file defines a trait (e.g., 'trait User { }') and then use 'use User;' inside the class.
   ```
3. ```
   Check for typos: verify that the class file at src/Models/User.php declares 'class User' not 'trait User' or 'interface User'.
   ```

## 无效尝试

- **** — Adding a 'use' statement at the top of the file for the class does not fix the error because the problem is the misuse of 'use' inside the class body to import a class, not a trait. (85% 失败率)
- **** — Renaming the class to a trait by adding 'trait User { }' works but changes the design incorrectly; the class should be extended with 'extends'. (60% 失败率)
