CLAUDE.md: fix multifactory list example (Article → Article())#330
Merged
Conversation
In the "Definition with list" example, `article: Article` (without parentheses) is parsed as a reference to an existing service of type Article rather than an inline definition, so compilation fails with "Service of type Article not found". Inline services in a locator list must be written as statements, i.e. with parentheses: `article: Article()`.
There was a problem hiding this comment.
Pull request overview
Fixes a broken CLAUDE.md documentation example where a multifactory “Definition with list” used article: Article, which is parsed as a reference to an existing service of type Article rather than an inline definition—causing compilation to fail when no such service is registered.
Changes:
- Update the multifactory list example to use
article: Article()so it’s treated as an inline/anonymous service definition. - Keep the “Or with references” example unchanged (it correctly demonstrates named services +
@servicereferences).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
CLAUDE.md, the "Definition with list" example for a multifactory is broken:article: Article(a bare string) is parsed as a reference to an existing service of typeArticle(Reference::fromType()inLocatorDefinition), not as an inline definition. Since no such service is registered, compilation fails with:Only statements (values with parentheses) are turned into anonymous services inside a locator list.
Fix
Add the parentheses so it is an inline definition:
Verified by compiling the example against the current sources — with
Article()the container builds andcreateArticle()returns a newArticle,getDb()returns the sharedPDO.The second example in the same section (with
@articlereferences) is correct and left unchanged.Found during a documentation audit of nette/documentation; the same fix was applied there.