Skip to content

CLAUDE.md: fix multifactory list example (Article → Article())#330

Merged
dg merged 1 commit into
masterfrom
fix/multifactory-list-example
Jul 5, 2026
Merged

CLAUDE.md: fix multifactory list example (Article → Article())#330
dg merged 1 commit into
masterfrom
fix/multifactory-list-example

Conversation

@dg

@dg dg commented Jul 5, 2026

Copy link
Copy Markdown
Member

Problem

In CLAUDE.md, the "Definition with list" example for a multifactory is broken:

services:
	- MultiFactory(
		article: Article        # ← does not compile
		db: PDO(%dsn%, %user%, %password%)
	)

article: Article (a bare string) is parsed as a reference to an existing service of type Article (Reference::fromType() in LocatorDefinition), not as an inline definition. Since no such service is registered, compilation fails with:

Nette\DI\ServiceCreationException: Service of type MultiFactory: Service of type Article not found.

Only statements (values with parentheses) are turned into anonymous services inside a locator list.

Fix

Add the parentheses so it is an inline definition:

		article: Article()

Verified by compiling the example against the current sources — with Article() the container builds and createArticle() returns a new Article, getDb() returns the shared PDO.

The second example in the same section (with @article references) is correct and left unchanged.

Found during a documentation audit of nette/documentation; the same fix was applied there.

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()`.
Copilot AI review requested due to automatic review settings July 5, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + @service references).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dg dg merged commit 37c8b6c into master Jul 5, 2026
13 of 19 checks passed
@dg dg deleted the fix/multifactory-list-example branch July 5, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants