Skip to content

Commit faf0f06

Browse files
koriymclaude
andcommitted
docs: improve assert() message to clarify its purpose
Added descriptive message to assert(class_exists($className)) to explain: - This is an internal logic error, not invalid user input - $className comes from ReflectionParameter type info, so it should always exist - assert() is the appropriate tool for checking "impossible" conditions - Can be disabled in production for performance, unlike explicit exceptions This addresses code review concerns about assert() usage while maintaining the correct semantic distinction between internal logic errors (assert) and user input validation (exceptions). 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f859c39 commit faf0f06

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/InputQuery.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ private function resolveObjectType(ReflectionParameter $param, array $query, arr
265265

266266
// Check if the parameter name exists as a direct nested array in query
267267
if (array_key_exists($paramName, $query) && is_array($query[$paramName])) {
268-
assert(class_exists($className));
268+
// This should never fail as $className comes from ReflectionParameter type info
269+
assert(class_exists($className), "Internal logic error: Class '$className' from reflection should exist");
269270

270271
/** @var Query $nestedQuery */
271272
$nestedQuery = $query[$paramName];

0 commit comments

Comments
 (0)