Correct OptionEnum docblocks that describe folded-in values as snake_case - #287
saarnilauri wants to merge 1 commit into
Conversation
…case The values folded in from ModelConfig KEY_* constants are copied verbatim and are camelCase (e.g. 'functionDeclarations'), not snake_case. Only the enum constant name is upper snake case. Four comments stated or implied otherwise, which has misled provider authors comparing option names against ModelMetadata::getSupportedOptions(). Also corrects the INPUT_MODALITIES docblock: ModelConfig does define KEY_INPUT_MODALITIES, and because the fold assigns unconditionally after parent::determineClassEnumerations(), that value takes precedence over the locally declared 'input_modalities'. Documentation only; every changed line is a comment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #287 +/- ##
=========================================
Coverage 86.54% 86.54%
Complexity 1381 1381
=========================================
Files 69 69
Lines 4438 4438
=========================================
Hits 3841 3841
Misses 597 597
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description of the change
OptionEnumfoldsModelConfig::KEY_*constants in viadetermineClassEnumerations(). Four comments in the file state or imply that the resulting values are snake_case. They are camelCase, and always have been:determineClassEnumerations()copies$constantValuein verbatim — there is no case transformation anywhere in the method:The confusion is easy to arrive at honestly, because the enum constant name genuinely is upper snake case (
KEY_FUNCTION_DECLARATIONS→FUNCTION_DECLARATIONS); it is only the value that is camelCase. This PR makes that name/value distinction explicit rather than leaving it implied.Verified against
trunk:This is a documentation-only change. Every changed line is a comment; no constant, signature or expression is touched.
Why it matters
These comments are load-bearing for provider authors, who need the option's string value to compare against
ModelMetadata::getSupportedOptions()or to inspect serialized metadata. Taking the comments at face value produces code that silently never matches.It has already cost real debugging time twice in the Ollama provider:
function_declarations" (Fueled/ai-provider-for-ollama#93). The provider did declare it; a grep for the snake_case string simply could not find it. The real defect turned out to be the opposite of the one reported.option.name === 'function_declarations'branch in its admin JS, guarding against a value that no released version of this package has ever emitted.Changes
src/Providers/Models/Enums/OptionEnum.php, four comments:determineClassEnumerations()docblock — replaces "converted to snake_case values" with a description that separates the constant name from the value, plus a concrete example.INPUT_MODALITIESdocblock — see below.A related inaccuracy, and a possible follow-up
The
INPUT_MODALITIESdocblock claimed:The first half is no longer true.
ModelConfigdoes defineKEY_INPUT_MODALITIES = 'inputModalities'(added deliberately, with its own note explaining it exists for model discovery). Because the fold runs afterparent::determineClassEnumerations()and assigns unconditionally, the ModelConfig value overwrites the locally declared one:So
INPUT_MODALITIES = 'input_modalities'is effectively dead — its value never reaches a caller. I have only corrected the docblock here, so this PR stays documentation-only.Removing the constant looks safe (nothing in
src/ortests/referencesOptionEnum::INPUT_MODALITIES, and'input_modalities'appears nowhere else in the package), anddocs/ARCHITECTURE.md:175mentions it only in prose. But that is a code change with a different review calculus, so I have left it out. Happy to open a separate PR, fold it in here, or drop the idea — whichever you prefer.How to test the change
No behaviour to test. To confirm the values the comments now describe:
Expected:
phpcs --standard=PSR12is clean on the changed file, andphp -lpasses.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Tracing the folded-in values through git history to confirm they were never snake_case, verifying the emitted values at runtime, and drafting these comment corrections. The final wording was reviewed and edited by me.
🤖 Generated with Claude Code