Repository navigation
fix(php): make generated docs examples parse - #2054
Merged
Merged
Conversation
Examples for operations without auth setters never terminated the client chain, so the next statement was a parse error. This hit every example in sdk-for-manager, whose spec declares no per-operation security. Object array examples given as JSON strings were also pasted in verbatim as JSON, and string values were not escaped. The test lints every generated PHP example so either class of break fails generation tests instead of shipping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generated phpunit.xml sets cacheDirectory to .phpunit.cache, but the generated .gitignore did not ignore it, so running the tests left it untracked and regeneration dropped any hand-added ignore rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟢 Tier S · Ready to merge
The PHP generator now emits parseable documentation examples for operations with and without security setters, and converts JSON array examples into escaped PHP array literals. Generation tests lint example code blocks across client, server, and console platforms, and generated PHP SDKs now ignore PHPUnit's cache directory. Latest changes: The newest commit adds
📂 Walkthrough · 4
Reviewed the commits since |
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.
What
Generated PHP docs examples that failed to parse:
;on the last auth setter. Operations with no security schemes got->setEndpoint(...)with no terminator, so the$service = new Service($client);line after it was a parse error. This hit every example in appwrite-labs/sdk-for-manager, because that spec declares no per-operation security (Hansi caught it on appwrite-labs/sdk-for-manager#47). The template now puts the terminator onsetEndpoint()when there are no setters. It also drops theif [(x)]|length > 0/for node in [(x)]wrapper, which was always true and only ever looped once.PHP::getParamExample()pasted string array examples verbatim, so[{"$id":"one",...}]landed in PHP source. It now JSON-decodes them throughjsonToAssoc(), matching what theTYPE_OBJECTbranch already did..phpunit.cache/in the generated.gitignore. The generatedphpunit.xmlsetscacheDirectory=".phpunit.cache", but the cache was never ignored.jsonToAssoc()hardening. Lists now render without'0' =>keys, and quotes and backslashes in strings and keys are escaped.Test
GenerationTest::testPhpExamplesParserunsphp -lon the code block of every generated PHP example, for client, server and console. Before the fix it failed on 25 examples, and after on 0.Verified
GenerationTestpasses excepttestAmbiguousConditionalResponsesFailGenerationandtestUnsupportedTypedConditionsFailRatherThanStringify. Those two error identically on unmodifiedmainon my machine: they run in separate processes, and my local php.ini has a brokenyaml.soentry whose startup warning breaks them. CI is the authority for those two.--dry-runand djlint pass on the changed files.Not verified
PHP85Test) locally: CI runs it. Example output changes only underdocs/examples, so SDK runtime behaviour shouldn't move.🤖 Generated with Claude Code