PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Added documentation

Open Beakerboy opened this issue 6 years ago • 4 comments

Since this is an abstract class, it would be beneficial to document the expectations of the child class. Any function that returns an array should document the format of the array.

Beakerboy avatar Feb 27 '19 13:02 Beakerboy

I agree that it would be a good thing™ for this array to be better documented.

In the PHPCS 2.x branch, the array was documented in the File class and, while that documentation may need an update, I think it would be a very good idea to bring it back.

See: https://github.com/squizlabs/PHP_CodeSniffer/blob/2.9/CodeSniffer/File.php#L26-L106

jrfnl avatar Feb 27 '19 13:02 jrfnl

I think it would be a very good idea to bring it back

Agreed. I think it's mostly just the same, but probably with a few more indexes. It probably belongs in the wiki docs as it is easier to format and manage there, but with a link off the the docs from the code.

gsherwood avatar Feb 28 '19 03:02 gsherwood

In reading the code for JS and PHP, I believe this is the expected result of the tokenize function. If other indexes are added to the tokens index, they happen at later stages. If tokens were their own object, it would be more obvious where to document the structure.

Beakerboy avatar Feb 28 '19 10:02 Beakerboy

While the documentation added here is strictly correct, IMO it is misleading as the $tokens array is enhanced with numerous other keys after this initial run and those other keys would now not be documented.

IMO, either the documentation in the File class docblock as was available in PHPCS2.x should be brought back & updated to reflect the current keys, or as @gsherwood suggested, this documentation should be added to the wiki.

I'm marking this as a close candidate as I don't think merging this as-is has added value.

jrfnl avatar Jul 13 '23 18:07 jrfnl