thecodingmachine/safe
All PHP functions, rewritten to throw exceptions instead of returning false observed · 2026-08-28
Health v2 · maintenance only
89/100
- Activity 98
- Release rhythm 71
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: 12
- age_days: 2921
- days_rel: 199
- days_push: 16
- n_releases_24m: 8
Adoption not part of the score
2496 stars · 169 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
Safe-PHP redeclares PHP core functions in a Safe namespace so they throw exceptions instead of returning false on error. It also provides Safe DateTime classes and a PHPStan rule to enforce usage of the safe variants.
Use cases
- replace php functions that return false with exception-throwing versions
- avoid silently ignoring errors from file_get_contents or json_decode
- enforce safe function usage with phpstan
- write cleaner php error handling without manual false checks
- get exception-throwing datetime classes
When to choose
- you want exceptions instead of false return values from PHP core functions
- you use PHPStan and want automated enforcement of safe function imports
- you are starting a new PHP project and want robust error handling by default
When to avoid
- you cannot change function calls in a large legacy codebase
- you need minimal dependencies and prefer manual error checking
- your framework already wraps core functions with its own error handling
Facets
library · maturity active
error-handling developer-tools developer-tools programming-languages php exceptions php-core-functions phpstan static-analysis
1 source
- readme: https://github.com/thecodingmachine/safe · fetched 2026-08-28 · 1abf27ccbb8e
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| thecodingmachine/safe | main | 89 |
For agents
markdown · JSON · MCP: product_card(name="thecodingmachine/safe")
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem