manychois / php-strong
A utility library for PHP to help you write strong-typed code.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/manychois/php-strong
Requires
- php: >=8.4
- psr/clock: ^1
- psr/container: ^2.0.2
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.16
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.1.39
- phpstan/phpstan-phpunit: ^2.0.15
- phpstan/phpstan-strict-rules: ^2.0.10
- phpunit/phpunit: ^12.5.11
- slevomat/coding-standard: ^8.22.1
- squizlabs/php_codesniffer: ^3.13.5
This package is auto-updated.
Last update: 2026-02-12 11:05:38 UTC
README
A utility library for PHP 8.4+ that helps you write strong-typed code with confidence.
Key Features:
-
Type-Safe Array Access -
ArrayAccessorprovides strongly-typed methods to retrieve array values (asString, asInt, asBool, etc.) -
Comparison Interfaces -
EqualInterfaceandComparableInterfaceenable value-based equality and ordering comparisons for custom objects, similar to Java/.NET patterns -
Strong PSR Container -
StrongContainerInterfacewraps PSR-11 containers with type-safegetObject()method, ensuring you get the exact class you expect -
Object-Oriented Regex -
Regexclass provides a clean, exception-based API for regular expressions with type-safe match results and captures -
Type-Safe Sessions -
PhpSessionextendsArrayAccessorto manage PHP sessions with strong typing, preventing session data type mismatches -
PSR Clock Implementation -
UtcClockprovides PSR-20 compliant time handling for testable, timezone-aware applications
Why Use It?
php-strong brings the reliability of static typing to PHP's dynamic features (arrays, sessions, containers), catching type errors at the point of access rather than deep in your application logic. Perfect for teams wanting C#/Java-style type safety in modern PHP.
Installation:
composer require manychois/php-strong