Skip to content

Whats with the formatting of PHP samples?? #143

Open
@uuf6429

Description

@uuf6429

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions