Repository navigation
Conversation
Bind the input to a template and return a conditional Arrayy type so that array inputs (maps, lists, array shapes) keep precise key and value types, while Traversable, callable, scalar, null and mixed inputs keep the previous untyped fallback. Annotation-only: no runtime or API change, and the native @return remains the documented fallback. Adds tests/PHPStan/CreateFactoryInference.php (red on de7df89, green now) and runs it in CI next to the legacy two-parameter fixture. Refs #194 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137bBXkFzHNcAuxvYcpRCLG
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough
ChangesFactory Type Inference
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Merge Risk: ⚪ Minimal · up to
|
|
Tick the box to add this pull request to the merge queue (same as
|
|
|
voku
left a comment
There was a problem hiding this comment.
AI-assisted source review on exact head 550352525d44c2b7bb2404374634aa324d1cef42 (not human approval).
I inspected the production diff, the PHPStan fixture and the CI change against #194:
src/Create.phpchanges annotations and the local static@phpstan-varonly. Function parameters, return declaration and construction logic stay unchanged, so accepted runtime inputs and runtime semantics are not narrowed.TCreateDatais bound to the complete input. The conditional@phpstan-returnpreserves array key/value/shape types and retainsint|string,mixed,array<int|string,mixed>for non-array inputs; the plain@returnremains the portable fallback.- The new fixture asserts map, list, shape,
first(),map(),toList(),getIterator(), mixed and non-array inputs, plus a legacy two-template consumer. CI invokes this fixture explicitly in the PHPStan job. - No relationship to the independent generic consistency question in #192 is claimed. PhpStorm/LSP behavior is not established by a PHPStan-only fixture.
No production-code blocker found in the narrow scope. CI on this head is running, not green yet; the former green workflow belongs to the older 0e6c394 head. A separate human review/merge decision remains required.
Independent source review — exact head
|
…run (#800) * learning: record two validated findings from the Arrayy #194 dogfood run - finding.2026-10-18.d93598: prove each declared validation command can execute on the host before the Contract is approved (Infection had no coverage driver; verification blocked at finish). - finding.2026-10-18.d56b74: typed-factory inference via a template on the whole parameter plus a conditional @phpstan-return (voku/Arrayy#195). Findings only: no proposal, classification, note or active guidance is created or changed. Task id ARRAYY-194 is the Loop task arrayy-194 in the root's task-id convention. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137bBXkFzHNcAuxvYcpRCLG * docs(learning): remove unproven version-specific conclusion --------- Co-authored-by: Claude <noreply@anthropic.com>



Refs #194
What
Arrayy\create()(src/Create.php) now binds its input to a template and returns a conditionalArrayytype via@phpstan-param/@phpstan-return(key-of/value-of). Array inputs keep precise key and value types. Traversable, callable, scalar, null and object inputs keep the previous untyped fallback.Annotation-only: no runtime or API change, the native
@returnis unchanged, and there is no new suppression,ignoreErrorsentry or baseline entry. The existing inner@varcast restates the same conditional type.array<string, DateTimeImmutable>Arrayy<int|string, mixed, …>Arrayy<string, DateTimeImmutable, …>;first()isDateTimeImmutable|nulllist<DateTimeImmutable>mixedelementsint<0, max>keys,DateTimeImmutablevaluesarray{id: int, name: string}mixedelements'id'|'name'keys,int|stringvaluesmixedarray<int|string, mixed>dataarray<mixed>data (same type, spelled differently)Tests
New fixture
tests/PHPStan/CreateFactoryInference.php, run in CI next to the legacy two-parameter fixture. It covers map, list and shape inputs,first(),toList(),getIterator(),map()callback parameters, the non-array fallbacks, an unknownmixedinput, and passing the result to a legacyArrayy<int, string>consumer.de7df89: 11 failures, including the legacy two-template consumer, which base rejects.Local runs on PHP 8.3 (PHPStan 2.3.1 from the release phar):
src/: no errors.LegacyTwoParameterArrayy.php: no errors.GenericNegativeUsage.php: still exactly 2argument.typeerrors.phpstan-fixtures.neonovertests/: 521 errors both before and after, with an identical diff (pre-existing, not gated by CI).Not verified
0e6c394e; on current head55035252, Infection is still running (Actions run39158513663).55035252; PHPStan runs in the PHP 8.3 CI job.@phpstan-return, and the plain@returnis unchanged, so IDEs that ignore@phpstan-*tags will see no change.Process note
This was run through agent-loop (task
arrayy-194, Contract revision 1 approved byvoku). The prior local Loop verification was blocked by its Infection command because the sandbox lacked a coverage driver; that local state has not been altered here. A read-only Dream/ Learning triage and candidate close-out evidence are documented in PR comment, but no durable Learning decision or independent human review is recorded. Loop state is untracked and kept out of this PR.Non-goals respected: no runtime/API change, no loosened analysis, no version bump, separate from #192 and #193.
Generated by Claude Code
This change is
Summary by CodeRabbit
create()now provides more precise static type information, preserving array keys, values, and shapes in its result. Non-array inputs retain their existing general type behavior.Arrayyusage.