Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad code sample #22

Open
mindplay-dk opened this issue Aug 8, 2015 · 5 comments
Open

Bad code sample #22

mindplay-dk opened this issue Aug 8, 2015 · 5 comments

Comments

@mindplay-dk
Copy link

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

@Anahkiasen
Copy link
Member

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
Copy link
Author

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
Copy link
Member

Would you mind sending a quick PR for this?

@mindplay-dk
Copy link
Author

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
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants