googleworkspace / php-samples

PHP samples for Google Workspace APIs
Apache License 2.0
287 stars 348 forks source link

Whats with the formatting of PHP samples?? #143

Open uuf6429 opened 1 year ago

uuf6429 commented 1 year ago

Let's take a look at this one: https://github.com/googleworkspace/php-samples/blob/main/sheets/snippets/src/SpreadsheetBatchUpdate.php

A blind person could have formatted that code better.

On top of that, there are several other problems:

  1. sometimes the samples have a PHP closing tag (?>)... which is totally pointless and increases the risk of bugs with trailing space
  2. dependencies are loaded in the end of the samples... it is common practice to have require "<the autoloader>"; at the beginning
  3. Exceptions are handled badly, by printing the exception message only - totally missing the stacktrace, which is sometimes even more important than just the message. Additionally, I don't know why it needs to handle exceptions in the first place - unhandled exceptions are always printed out.
  4. The samples are using a mixture of old non-namespaced classes, and newer ones...please decide and keep it consistent.

But the formatting is the biggest problem.. I'm already having a hard time jumping between browser tabs trying to figure out things from references, guides, stackoverflow and so on. Having to go through unreadable code on top feels unnecessary.