# Trait

The `Trait` component provides type-safe wrappers around PHP's built-in trait reflection and existence checks. It replaces loose `trait_exists()` calls with a consistent, intention-revealing API.

## Usage

PSL separates existence checks into two distinct functions -- `exists()` (triggers autoloading) and `defined()` (checks only already-loaded definitions) -- so the intent is always clear.

```php
use Psl\Interface;
use Psl\IO;
use Psl\Trait;

IO\write_line('JsonSerializable exists: %s', Interface\exists(JsonSerializable::class) ? 'yes' : 'no');
IO\write_line('JsonSerializable defined: %s', Interface\defined(JsonSerializable::class) ? 'yes' : 'no');

// Check a non-existent trait
IO\write_line('NonExistentTrait exists: %s', Trait\exists('NonExistentTrait') ? 'yes' : 'no');
```

See [src/Psl/Trait/](https://github.com/php-standard-library/php-standard-library/tree/6.2.1/packages/trait/src/Psl/Trait/) for the full API.
