[php-src] Issue #21106: Missing trait is E_ERROR but missing extends/implements is Exception when autoloaded?

[email protected] (kkmuffme)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21106
Author: kkmuffme

### Description

The following code:

```php
<?php
spl_autoload_register( function ( $class_name ) { 
    if ( $class_name === 'Foo' ) {
        require __DIR__ . '/foo.php';
    }
} );
try {
    class_exists( Foo::class );
} catch ( Throwable $e ) {
    echo 'catch' . PHP_EOL;
}
```

foo.php
```
class Foo {
    use Bar;
}
```

Resulted in this output:
```
Trait "Bar" not found
```

But I expected this output instead:
```
catch
```

Change foo.php to
```
class Foo extends Bar {}
```

and you will get the expected output. It's not consistent/illogical that traits behave differently in this regard?

### PHP Version

```plain
PHP 8.5
```

### Operating System

_No response_
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.