ciaranmcnulty/phpspec-typehintedmethods
PhpSpec extension that generates typehinted methods for your collaborators, so spec-generated stubs and mocks include proper parameter and return types. Keeps specs clean while producing type-safe, IDE-friendly code.
Architecture fit. phpspec-typehintedmethods is a phpspec extension — a Composer package implementing PhpSpec\Extension\ExtensionInterface that hooks phpspec's generation pipeline to emit type-hinted method signatures (parameter and, where the API allows, return types) instead of untyped stubs. Architecturally it slots cleanly into the phpspec console via the extensions: config key; no runtime coupling to application code, no service container changes, no production surface. It is a developer-tooling concern only, which makes the blast radius small.
Integration feasibility. Low effort in principle: composer require --dev ciaranmcnulty/phpspec-typehintedmethods, register in phpspec.yml/phpspec.yml.dist, regenerate a spec and inspect output. The real feasibility question is version alignment — the last release is 2018-07-15, predating PHP 8 and several phpspec majors. The extension API changed across phpspec 3.x → 4.x → 5.x/6.x (namespaces, Generator/Resource interfaces, console wiring), so a working install is likely contingent on pinning an older phpspec. Feasibility is therefore medium-low, dominated by compatibility rather than integration mechanics.
Technical risk. High relative to the value delivered:
static return, nullsafe handling, and deprecations in reflection are all likely gaps, and typed signatures are exactly the feature surface that changed most in PHP 8.1–8.3.opportunity: 10.85 score against a 1.21 composite signals a niche gap (there is little competition because there is little demand), not a hidden gem.Key questions.
static/self, nullable and default-valued parameters — or only parameter hints?ObjectProphecy, untyped spec params)?Verdict as a leverage decision. This is a nice-to-have codegen polish tool, not infrastructure. Recommend evaluating it only if the team is already phpspec-centric and codegen velocity is a real pain point; otherwise the maintenance liability outweighs the benefit.
Stack fit. Only relevant to PHP shops using phpspec as a spec/codegen tool. Teams on PHPUnit or Pest get zero value. Where phpspec is used, the extension is additive: it changes generated output, not test semantics, and imposes no runtime dependency (dev-only autoload).
Migration path. Non-breaking by construction. Adopt as a dev dependency on a spike branch, regenerate one or two specs, and diff the output against untyped generation. Because it is dev-only and config-gated, rollback is a one-line removal from phpspec.yml plus composer remove; no data, schema, or deploy migration is involved. There is no "cutover" — adoption is per-developer or per-repo opt-in.
Compatibility. This is the gating step, and must be sequenced first:
composer.json constraints and CI if present).Sequencing.
static cases.phpspec.yml template if the pilot shows clean output; otherwise archive the finding.
Never sequence this ahead of a static-analysis baseline — the payoff depends on PHPStan/Psalm actually consuming the generated hints.Maintenance. Effectively ownerless upstream. Budget for self-maintenance: either freeze to an old phpspec/PHP combination (accumulating risk) or fork and own the extension. Because it sits on phpspec's codegen API — a historically volatile surface — fork maintenance is non-trivial despite the small codebase; expect breakage on every phpspec major. Treat "unmaintained" as a standing cost line, not a footnote.
Support. No vendor, no active issue triage, no SLA. Internal support = one engineer who understands phpspec's generator pipeline plus a runbook entry. Onboarding cost is low if that person exists; otherwise the tool becomes tribal knowledge and quietly rots.
Scaling. Negligible operational scaling concerns — dev-only, runs at codegen time on a single developer machine or CI step. No throughput, memory, or concurrency implications at runtime. The scaling limit is organizational: more repos adopting it multiplies the maintenance surface without multiplying value, so scope it deliberately rather than letting it spread by default.
Failure modes.
static/nullable hints, which then propagate into PHPStan/Psalm baselines as false cleanliness.Ramp-up. Low for developers already fluent in phpspec (config snippet + regenerate). Medium for the team as a whole if it requires explaining why type-hinted stubs matter for downstream static analysis. The real ramp-up cost is on the maintainer, who must learn phpspec's extension/generator internals to keep a stale package alive — budget days, not hours, and only if the codegen-velocity benefit is demonstrated in the spike.
Bottom line for a TPM: small, stale, niche dev-tooling package with a clean but fragile integration. Leverage is real only inside a phpspec-first team targeting pre-PHP-8 semantics; everywhere else the rational move is to note it as prior art, skip adoption, and revisit only if codegen quality becomes a measured bottleneck.
How can I help you explore Laravel packages today?