widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

PHP formatting improvements

Open jeffski opened this issue 3 years ago • 1 comments

This PR addresses a couple issues, 1 bug and 1 improvement related to the PHP code examples.

When generating documentation, the PHP code example is cut off at the start and in my case looks like this (won't work):

php-missing

With this update it will look like (correct):

php-correct

I think the <?php tag at the start is breaking things, but I think any PHP developer is smart enough to know to add the tag in to their script so it isn't needed.

Also you can see that the code now uses modern array syntax [], available since PHP7, released in 2015. I think support for PHP5 which is EOL can be dropped in favour of the [] syntax.

jeffski avatar Dec 31 '20 11:12 jeffski

I think the request body would be better written as:

// Define array of request body.
$request_body_json = <<<JSON
{{=data.bodyParameter.exampleValues.json}}
JSON;
$request_body = json_decode($request_body_json, true);

However when I use <<< the text seems to be truncated. I need a way to escape the <<< so they are displayed when rendered.

In any case, the improvements I have made are better than the current template so they should be merged as a first step.

jeffski avatar Dec 31 '20 11:12 jeffski