azjezz/psl
PSL is a modern, well-typed standard library for PHP 8.4+, inspired by HHVM’s HSL. It offers safer, predictable APIs for async, collections, networking, I/O, crypto, terminal UI, and robust data validation—replacing brittle built-ins with consistent alternatives.
The Interoperability component provides a set of interfaces for converting between PSL types and their PHP standard library (stdlib) or intl extension equivalents.
These interfaces establish a uniform contract for bidirectional conversion, allowing PSL types to interoperate seamlessly with native PHP types.
@example('other/interoperability-conversion.php')
The component defines four interfaces covering all conversion directions:
ToStdlib -- convert a PSL type to its PHP standard library equivalent (e.g. PSL DateTime to DateTimeImmutable)FromStdlib -- create a PSL type from its PHP standard library equivalent (e.g. DateTimeImmutable to PSL DateTime)ToIntl -- convert a PSL type to its intl extension equivalent (e.g. PSL Timezone to IntlTimeZone)FromIntl -- create a PSL type from its intl extension equivalent (e.g. IntlTimeZone to PSL Timezone)The following PSL types implement these interfaces:
| PSL Type | ToStdlib | FromStdlib | ToIntl | FromIntl |
|---|---|---|---|---|
DateTime\DateTime |
DateTimeImmutable |
DateTimeImmutable |
IntlCalendar |
IntlCalendar |
DateTime\Timestamp |
DateTimeImmutable |
DateTimeImmutable |
- | - |
DateTime\Duration |
DateInterval |
- | - | - |
DateTime\Timezone |
DateTimeZone |
DateTimeZone |
IntlTimeZone |
IntlTimeZone |
See src/Psl/Interoperability/ for the full API.
How can I help you explore Laravel packages today?