Code Quality & Maintainability:
Adopting elasticms/helpers enables teams to eliminate PHPStan false positives for dynamic PHP functions (e.g., array_*, str_*) by wrapping them in type-safe alternatives. This directly supports:
Str, Arr, and Collection utilities.Build vs. Buy: A clear "buy" decision for teams already using PHPStan or planning to adopt it. The package eliminates the need to:
@phpstan-ignore).Roadmap Priorities:
array_is_list) without breaking changes.pestphp/pest or spatie/laravel-test-factory for type-safe testing.Use Cases:
json_encode without type hints) in PHPStan-compliant versions to enable static analysis without rewriting business logic.
Example: Replace json_encode($data) with Helpers::jsonEncode(array $data): string to catch serialization errors early.Helpers::arrayMerge(array $arrays): array instead of native array_merge to ensure non-null returns.file_get_contents) with typed alternatives for security-critical paths (e.g., file handling).
Example: Replace file_get_contents($path) with Helpers::fileGetContents(string $path): string|false to handle false returns explicitly.Adopt if:
array_map, str_replace).Look elsewhere if:
Str::, Arr::) or custom type-safe wrappers already meet your needs with lower risk.*"This package automates type safety for PHP functions, cutting bugs and developer friction in Laravel applications. By replacing loose functions like array_merge with PHPStan-compliant wrappers, we can:
*"This solves a critical gap in PHPStan adoption: dynamic PHP functions (e.g., json_encode, array_filter) often trigger false positives or require verbose workarounds. The elasticms/helpers package:
Helpers::strContains(string $haystack, string $needle): bool).collect() or Str:: helpers.*"Tired of PHPStan screaming at you for using array_map without type hints? This package auto-fixes it:
array_map(fn($x) => $x, $data) with Helpers::arrayMap(callable $callback, array $array): array.@phpstan-ignore—just type-safe, drop-in helpers.collect() for consistency.
How to start:composer.json: composer require elasticms/helpers.Helpers:: equivalents.Str:: helpers for string ops to avoid duplication."**"This package reduces flaky builds caused by PHPStan errors in utility functions. By standardizing helpers like file_get_contents or json_decode, we:
How can I help you explore Laravel packages today?