flow-php/types
Flow PHP type system library with typed value objects and type definitions for consistent, safe data handling across the Flow ecosystem. Designed for ETL pipelines, it helps enforce data contracts and reduce runtime type errors.
Illuminate\Support\Collection, Carbon), this package could complement:
array/mixed with strongly typed objects).Email, UUID).flow-php/flow suggests it’s part of a larger ecosystem (e.g., Flow PHP’s ETL tools). If the Laravel app interacts with Flow PHP’s other packages (e.g., flow-php/flow), this could enable seamless type sharing.mixed/array types would require refactoring to adopt the package’s value objects (e.g., replacing string with Email).UUID fields), but would need custom accessors/mutators or model traits to bridge Laravel’s ORM and the package’s types.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Type Migration Cost | High | Incremental adoption (start with DTOs/Requests). |
| Tooling Dependency | Medium | Ensure PHPStan/Psalm are configured pre-integration. |
| Laravel-Specific Gaps | Medium | Extend package types with Laravel traits/interfaces (e.g., JsonSerializable). |
| Performance Overhead | Low | Value objects are lightweight; benchmark critical paths. |
| Ecosystem Lock-in | Low | MIT license; no vendor lock-in. |
Carbon) or augment them?UUID vs. string)?level: 8).string to Email).array request data with typed value objects (e.g., CreateUserRequest with Email, Password fields).ProcessOrderJob with OrderId type).use FlowTypes\Email;
use FlowTypes\UUID;
class UserRequest {
public function __construct(
public Email $email,
public string $name,
) {}
}
string → Email).// rector.php
return [
TypeHintingRule::TYPE_HINT_PARAMETER_TO_TYPE_OBJECT(
Email::class,
'string'
),
];
trait CastsFlowTypes {
protected function castEmailAttribute(string $value): Email {
return new Email($value);
}
}
# phpstan.neon
level: 8
types:
- FlowTypes/
JsonSerializable for API responses).Ramsey/UUID vs. FlowTypes\UUID).expect($userRequest->email)->toBeInstanceOf(Email::class);
mixed/array with typed alternatives.#[Deprecated('Use Email type instead')]
public function setEmail(string $email): void { ... }
Email vs. string).Email validation rules), Laravel code must adapt.Argument 1 passed to User::setEmail() must be FlowTypes\Email, string given.
if (!$email instanceof Email) {
throw new InvalidArgumentException('Email must be a FlowTypes\Email');
}
| Scenario | Impact | Mitigation |
|---|---|---|
| Type Mismatch in Production | API failures, data corruption | Strict CI |
How can I help you explore Laravel packages today?