add_method_body
Append new PHP code statements to an existing method while correctly handling nested constructs like arrow functions and computed properties. Specify file, method, and code; optionally provide TypeScript types for variables.
Instructions
Append code to an existing method. Use this when you need to ADD MORE code to a method that already has statements.
For new methods: Use create_method with the body parameter instead - it creates the method with code in one call.
Nested code is handled correctly. The parser tracks brace/bracket/paren depth and only splits on semicolons at the top level. Arrow functions with block bodies, computed properties, and other nested constructs work as single statements.
Pass 'types' to specify TypeScript types for variables declared in the code.
IMPORTANT: This APPENDS to existing method statements. To REPLACE a method's code entirely:
Create a NEW method with create_method (with body parameter)
Update the file's 'data' array to include new method UUID (remove old one)
Update any element click handlers to reference the new method UUID
Delete the old method with delete_method
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | UUID of the file containing the method | |
| method | Yes | UUID of the method to add code to | |
| code | Yes | PHP code for the method body (just the statements, no function declaration). Example: "return $a + $b;" | |
| types | No | Map of variable names to their base TypeScript types (e.g., { "result": "Todo" }). The assembler infers full types from code structure. |