postmanlabs / postman-code-generators

Common repository for all code generators shipped with Postman
Apache License 2.0
981 stars 348 forks source link

fix php codegen missing ?> at end of snippet (fixes #640) #724

Closed aarifkhan7 closed 6 months ago

aarifkhan7 commented 7 months ago

Fixes #640 Issue: The code generators for php, generates snippet without ?> end tag.

Code Snippet: `<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => 'https://postman-echo.com/get?test=123', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', ));

$response = curl_exec($curl);

curl_close($curl); echo $response; `

The Code snippet after the fix looks like: `<?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => 'https://postman-echo.com/get?test=123', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', ));

$response = curl_exec($curl);

curl_close($curl); echo $response;

?>`

aman-v-singh commented 6 months ago

Hey @aarifkhan7, It is entirely optional to close PHP with ?>, it is even considered a good practice to not close PHP tags. You can read more about it here.

I am closing the PR, you can open it for further discussions.