gosuperscript/monads
gosuperscript/monads is a lightweight functional programming library for PHP and Laravel, offering Option, Result, and related monads to handle nullable values and errors safely through clean, chainable APIs.
Scope of change (v1.3.0). The release adds a PHPStan extension that bans "panicking" monad unwraps — i.e. calls that extract a value from a Left/None by throwing or aborting. This is a tooling and governance change, not an API change. No breaking changes, no new runtime behaviour, no new runtime dependency implied. The material point is that the single largest usage risk identified in the prior assessment — discipline erosion and silent failure swallowing — now has a shipped, first-party enforcement mechanism rather than something we would have had to build ourselves.
Architecture fit. Unchanged. Monads remain a domain-layer utility that sits alongside idiomatic, exception-driven Laravel rather than inside it. What changes is the shape of the fit: the package now ships a quality gate as well as an abstraction, which means it can be made self-policing at the CI boundary. That is a meaningfully better architectural story than "here is an abstraction, please use it carefully." It also strengthens the case for confining it to a bounded context, because the rule only protects code that is actually analysed and that actually uses the package's types.
Integration feasibility. Mechanical integration remains composer require. The new work is small and lives in the build, not the application: registering the extension (likely via phpstan/extension-installer or an explicit includes: entry), confirming the rule fires at our configured PHPStan level, and deciding whether it is an error or a warning in CI. The semantic integration cost — the ADR that says when Either/Option is mandatory and when exceptions remain correct — is not eliminated, but it is now partially executable rather than purely documentary. That converts a convention that erodes under team churn into a check that fails a pull request.
Technical risk (revised). The overall rating moves from high to moderate, with the caveats below. The prior assessment's top risks and their current status:
gosuperscript/monads-php) is now confirmed against a real tag history (v1.2.0 → v1.3.0). The prior "treat the release date as unconfirmed metadata" caveat is now resolved. A contributor is not a governance model or a security policy, but it is better evidence than a solo commit stream.Key questions (updated).
require rather than require-dev?@phpstan-ignore and baseline files? (If it does, the guardrail is advisory; plan accordingly.)Either was the most dangerous failure mode in the prior assessment.Either<Foo, Bar> — or does type information still degrade to mixed?Either/Option?Stack fit. Neutral-to-positive, upgraded from poor-to-neutral for a new bounded context. The package still has no service provider, facade, or container bindings, and that remains correct — it should not. But it now has a place in a part of our stack we actually control uniformly: the PHPStan job in CI. That is a genuinely better integration surface than the application layer, because it is identical for every service and does not depend on developer discipline.
Migration path. Unchanged: greenfield, one bounded context, prove ergonomics over a quarter. The release does not make retrofit any more attractive — retrofitting monads is still a whole-codebase conversion with no incremental payoff, and a lint rule makes retrofitting harder, not easier, because it will flag existing panicking unwraps the moment it is enabled.
Compatibility. Verify before committing:
Pipeline with monadic short-circuiting in one chain, unchanged.Sequencing. The prior plan holds with two adjustments:
Maintenance. Runtime maintenance remains effectively zero. The convention-drift burden — previously described as the real ongoing cost, requiring us to author and maintain a custom PHPStan rule — is now substantially offloaded to the package. What replaces it is a smaller, sharper obligation: keep the guardrail working across PHPStan upgrades. That means a pinned version, a canary fixture, and a line in the dependency-upgrade runbook. This is a strictly better maintenance profile than before: a bounded, testable build concern in place of an unbounded, social one.
Support. Marginally improved but still the primary risk. There is now evidence of a second contributor and a real release cadence, which is more than most single-maintainer packages offer. There is still no Stack Overflow corpus, no tutorials, and no peer users to consult; onboarding material remains in-house work. Containment to one bounded context remains the load-bearing operational control, and should be stated as a hard architectural constraint rather than a preference.
Scaling. Runtime cost still negligible. The cognitive scaling concern is partially mitigated: a reviewer who does not know monad idioms can still trust that CI blocks the dangerous patterns, and a junior engineer gets feedback at commit time rather than in review. The comprehension tax on readers remains — the rule prevents misuse, not unfamiliarity — so gating adoption on team tenure and PHP sophistication is still correct.
Failure modes (updated).
@phpstan-ignore comments. Treat the rule as a strong default, not a proof.includes:, or a forgotten canary silently disables enforcement. This is the failure mode to instrument; it fails quietly and everyone believes they are protected.Ramp-up. Roughly 2–4 weeks to productivity for a mid-level engineer new to functional patterns, unchanged in magnitude, though the shipped rule shortens the feedback loop considerably — learners get corrected by tooling instead of by reviewers, which compresses the tail of the learning curve. Senior engineers with Scala/Kotlin/Rust exposure still take days. Keep the half-day workshop and living cookbook. Remember the cost is paid by readers as well as writers.
Recommendation for the TPM. The prior recommendation holds with a firmer footing and a slightly better risk profile. Do not adopt as a platform standard. Run the two-week spike — with the PHPStan guardrail wired and proven to fail — and complete the provenance audit in parallel. A positive pilot licenses use in one bounded context only, with the rule enforced at error level and a canary test protecting it from toolchain drift. This release materially reduces the strongest objection to the package (unpoliced usage) and provides the first real evidence of a functioning project rather than a personal repository. It does not change the core judgement: with a small dependent base and a single maintainer, this remains a bet on an unproven library. Keep the commitment reversible, contained, and cheap to unwind — and add "re-verify the guardrail fires" to the quarterly dependency review.
How can I help you explore Laravel packages today?