Add PHP as a supported output language#103
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 10 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
This is likely a transient issue. You can re-trigger a run from the dashboard. |
added 3 commits
July 22, 2026 13:01
Follows the exact same pattern as python/javascript/typescript:
- New prompt partial (prompts/partials/_language_php.md): uses the
curl and json_encode/json_decode core extensions (ext-curl,
ext-json) - both part of core PHP, so no Composer dependency is
needed at all, no project/dependency file of any kind. Same
auth-hardcoding/refresh guidance as the other languages.
- base_engineer.py: added "php" to _OUTPUT_LANGUAGE_EXTENSIONS (.php)
and _get_language_name() ("PHP"). _get_run_command() uses the full
path rather than a bare relative "php api_client.php" - applying the
same fix greptile-apps caught on the Go/Java/C# PRs proactively here
from the start, since php <relative-path> has the identical shape
(the agent's cwd is scripts_dir.parent.parent, not scripts_dir where
the script is actually saved).
- cli.py: added PHP to the interactive `output_language` config picker.
- Updated the three docstrings/comments that listed the language set
(config.py, engineer.py, prompts/__init__.py) and README.md's output
language line.
- Tests: mirrored the existing per-language test pattern in
test_base_engineer.py (extension, run command, prompt content) and
test_prompts.py (partial loading) for PHP.
Checked the partial for the literal-brace str.format_map() bug caught
in the Java PR - no literal `{`/`}` anywhere in the new file.
Full test suite passes (49/49, run 3x). ruff check is clean on every
file this touches (8 pre-existing lint errors elsewhere on main, none
in the touched lines).
Two real bugs caught by greptile-apps and cubic-dev-ai independently
on the PR, both verified before fixing:
1. _get_run_command()'s "php \"{path}\"" only looked safe - manual
double-quoting does NOT stop $() or backtick command substitution
inside a double-quoted shell string, confirmed live. If scripts_dir
(derived from output_dir, not something this function controls)
ever contained shell metacharacters, the resulting {run_command}
could execute something other than what was intended when the
agent runs it. Replaced with shlex.quote(), the stdlib function
built exactly for this - confirmed live it correctly single-quotes
the whole path when metacharacters are present, and correctly
escapes literal single quotes too (manual double-quoting handles
neither case). Added a dedicated test with a deliberately hostile
path (embedded $(rm -rf ~)) asserting the command round-trips
through shlex.split() back to the literal path, not something a
shell would expand.
2. The partial said ext-curl was "part of core PHP" alongside ext-json,
but that's only true for ext-json - ext-curl is bundled-but-optional
and not guaranteed enabled on every PHP install (some minimal/
stripped installs omit it). Fixed the wording and added the same
check-and-install guidance the C PR already gives for libcurl's
equivalent gap, rather than silently assuming curl_init() exists.
Full test suite passes (50/50, run 2x) except the same pre-existing
flaky test noted on the other language PRs. ruff check clean on the
touched lines.
Same root cause cubic flagged on the C# and Ruby PRs: a relative --output-dir leaves scripts_dir relative to the original cwd, but once the agent's cwd moves to scripts_dir.parent.parent (see analyze_and_generate), embedding that same relative string re-interprets it from the new location and points at a doubly-nested, nonexistent path. Resolve scripts_dir before interpolating it, proactively applying the same fix here before it gets flagged.
kalil0321
force-pushed
the
add-php-output-language
branch
from
July 22, 2026 11:05
26a9ca9 to
72f2d90
Compare
Owner
|
@greptile review |
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.
Follows the exact same pattern as python/javascript/typescript:
output_languageconfig picker.Checked the partial for the literal-brace str.format_map() bug caught in the Java PR - no literal
{/}anywhere in the new file.Full test suite passes (49/49, run 3x). ruff check is clean on every file this touches (8 pre-existing lint errors elsewhere on main, none in the touched lines).
Summary by cubic
Add PHP as a supported output language for generating a standalone API client using cURL and
ext-json. Adds a shell-safe, absolute-path run command and updates the CLI, prompts, docs, and tests.New Features
output_language: "php"with.phpextension and name "PHP"; run viaphpwith an absolute path.prompts/partials/_language_php.mdusing cURL and JSON; includes cookie jar handling, per-endpoint functions, example usage, and auth hardcoding with auto-refresh guidance.phpto the interactive settings picker incli.py; updateREADME.md, docstrings, andCHANGELOG.md; tests for extension mapping, prompt content, and partial loading.Bug Fixes
shlex.quote()and resolves the script path to an absolute path to prevent command substitution and cwd mismatches; adds hostile-path and relative-path tests to verify correct tokenization and resolution.ext-curlis optional and may be missing; adds check/install guidance whencurl_initis unavailable.Written for commit 72f2d90. Summary will update on new commits.
Greptile Summary
This PR adds PHP as a supported output language. The main changes are:
Confidence Score: 4/5
The remaining relative-path mismatch should be fixed before merging.
src/reverse_api/base_engineer.py
Important Files Changed
Reviews (2): Last reviewed commit: "Resolve scripts_dir to an absolute path ..." | Re-trigger Greptile