rocketeers / docs

Rocketeer's documentation
7 stars 25 forks source link

Bad code sample #22

Open mindplay-dk opened 9 years ago

mindplay-dk commented 9 years ago

The first sample on this page isn't valid PHP code. Looks like half an array? Pretty confusing.

Anahkiasen commented 9 years ago

Yes sorry it's the <?php tag that is confusing, I added it for syntax highliting but it's supposed to be part of the hooks.php file. Putting the whole config file would just have been even more confusing

mindplay-dk commented 9 years ago

I usually put //... to indicate that irrelevant lines was taken out of an example - that way you can still show the opening/closing array and php tag :-)

Anahkiasen commented 9 years ago

Would you mind sending a quick PR for this?

mindplay-dk commented 9 years ago

Well, I don't know what the code sample was supposed to look like ;-)

What I mean is, just comment-out the irrelevant parts, so if you have:

return array(
    'foo' => 1,
    'bar' => 2,
    'baz' => 3,
);

But the example deals only with baz, just comment out the rest:

return array(
    // ...
    'baz' => 3,
);

But preserve context (parens, nesting, identation etc.) so that it's still valid PHP, so it illustrates where the relevant parts would appear :-)

Anahkiasen commented 9 years ago

I think maybe just adding the other arrays above it but empty would make it clearer, like:

hooks.php

<?php return [
  'before' => [],
  'after' => [
    // The curent example
  ],
  'custom' => [],
];

What do you think?