twilio / twilio-php

A PHP library for communicating with the Twilio REST API and generating TwiML.
MIT License
1.57k stars 562 forks source link

Usage Guide Syntax mismatches (Documentation) #729

Closed d-miles closed 2 years ago

d-miles commented 2 years ago

Issue Summary

Wasn't sure where to report an error in the documentation, and thought this might be a better place than through a support ticket? I was looking for a repository to perhaps send a pull request but couldn't find one.

The Exceptions area of the Usage Guide page has a bunch of instances of invalid PHP syntax being used and/or mismatched Twilio method names. This is perhaps due to them being either generated or copied from documentation for other language's libraries.

  1. In the first/second (Twilio Client), and fourth (TwilioException) examples:

    call = $client->account->calls
                  ->get("CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

    should be $call = ...

  2. The first/second (Twilio Client, and third (CurlClient) examples have the same error:

    echo $e.get_code();

    should be $e->get_code(); -- though I'm not sure if get_code() is the correct method name either. If v4.x/v5.x exception classes are anything like v6.x exception classes, then this should also be getCode() or getMessage().

  3. TwimlException:

    echo $e

    should be $e->getCode(); or $e->getMessage();

  4. TwilioException recommends catching TwilioException and calling $e->getStatusCode(); this method is only available on RestException though.

Hope this helps improve your documentation! 😄

d-miles commented 2 years ago

Ha, as I was going through the rest of the documentation, I've just realized this page I was linked to (from "Handling Exceptions" on the main PHP reference page) seems to be somewhat out of date. While the link is for the 'usage guide,' the header of the page mentions that it is really a usage/migration guide to v5.x.

So, perhaps the only change necessary is either updating this PHP reference page to link elsewhere, or extracting the "Handling Exceptions" portions into their own documentation and applying the fixes I pointed out 😃

childish-sambino commented 2 years ago

Thanks for the call out. The exception handling docs work for both 5.x and 6.x. I've submitted the changes for internal review.

rakatyal commented 2 years ago

The docs have been updated. Please let us know if we can help with anything else.