Skip to content

Commit 9c1b400

Browse files
nikophilclaude
andcommitted
docs: clarify ref(type, name) syntax as an escape hatch
Add a note explaining that the <ref(type, name)> syntax is a fallback mechanism for edge cases, and that automatic resolution should be preferred. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6ee606c commit 9c1b400

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ jobs:
250250
251251
- name: Test
252252
run: |
253-
vendor/bin/phpunit -c phpunit-10.xml.dist tests/Unit
253+
vendor/bin/phpunit tests/Unit
254254
255255
test-with-paratest:
256256
name: Test with paratest

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,9 @@ the category named "tech" in the registry.
28902890
| title | category |
28912891
| My Post | <ref(category, tech)> |
28922892
2893+
The ``<ref(type, name)>`` syntax is an escape hatch for edge cases where automatic type resolution fails.
2894+
Prefer using automatic resolution (just the object name) whenever possible, as it is cleaner and more readable.
2895+
28932896
.. note::
28942897

28952898
Objects can be referenced by their name until the next database reset occurs. How long they persist depends on your

src/Test/Behat/src/AbstractFoundryContext.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ public function createObjectWithProperties(TableNode $table, string $factoryShor
4747
$parametersList = $table->getColumnsHash();
4848

4949
if (1 !== \count($parametersList)) {
50-
throw new \InvalidArgumentException(\sprintf(
51-
'Expected exactly one line of properties to create one object, got %d lines. Use "there are %s with" to create multiple objects.',
52-
\count($parametersList),
53-
$factoryShortName,
54-
));
50+
throw new \InvalidArgumentException(\sprintf('Expected exactly one line of properties to create one object, got %d lines. Use "there are %s with" to create multiple objects.', \count($parametersList), $factoryShortName));
5551
}
5652

5753
$factory->create($parametersList[0]);
@@ -81,10 +77,7 @@ public function assertObjectHasProperties(FoundryTableNode $table, string $facto
8177
$parametersList = $table->getColumnsHash();
8278

8379
if (1 !== \count($parametersList)) {
84-
throw new \InvalidArgumentException(\sprintf(
85-
'Expected exactly one line of properties for assertion, got %d lines.',
86-
\count($parametersList),
87-
));
80+
throw new \InvalidArgumentException(\sprintf('Expected exactly one line of properties for assertion, got %d lines.', \count($parametersList)));
8881
}
8982

9083
$object = $this->objectRegistry->getByFactoryShortName($factoryShortName, $objectName);

0 commit comments

Comments
 (0)