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

Style guide? #104

Open
radmen opened this issue Aug 7, 2017 · 13 comments
Open

Style guide? #104

radmen opened this issue Aug 7, 2017 · 13 comments
Assignees

Comments

@radmen
Copy link
Contributor

radmen commented Aug 7, 2017

We should use a consistent coding style. I think that we should stick to PSR-2 style guides.

It can be validated using composer run-script phpcs

$ composer run-script phpcs
> ./vendor/bin/phpcs --standard=PSR2 src

FILE: zubr/src/array_column.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 10 | WARNING | Line exceeds 120 characters; contains 292 characters
 11 | WARNING | Line exceeds 120 characters; contains 187 characters
----------------------------------------------------------------------

The second thing is the format of PHPDocs. I've used simplified doc blocks however, I see that @ddziaduch literally copied docs blocks from PHP source (or IDE stub :)). Which format should we use?

@radmen
Copy link
Contributor Author

radmen commented Aug 7, 2017

Ah, and one more thing - should we use camel case or snake case for function parameters?

@ddziaduch
Copy link
Contributor

@radmen yeap I have copied PHPDocs from PhpStorm stubs

@radmen
Copy link
Contributor Author

radmen commented Aug 7, 2017

For me it's fine - I can do the same for other functions. It would be good to use the same format.

Should we use PhpStorm stubs?

@nkkollaw
Copy link
Owner

nkkollaw commented Aug 7, 2017

Ah, and one more thing - should we use camel case or snake case for function parameters?

I vote always snake case for parameters, as it seems to be more common.

@nkkollaw
Copy link
Owner

nkkollaw commented Aug 7, 2017

We should use a consistent coding style. I think that we should stick to PSR-2 style guides.

I will add more stuff to CONTRIBUTING.md, including a style guide and more detailed instructions.

@ddziaduch
Copy link
Contributor

What about new PSR coding standard? It is not "official" yet but it will be soon

@ddziaduch
Copy link
Contributor

@nkkollaw
Copy link
Owner

nkkollaw commented Aug 7, 2017

Very nice. I vote yes.

Also, of course we would need to change some code, but even if the spec changed we would still be consistent in that we're using the same standard.

Do you know how final the code is? Will there be pretty much no changes before the official release?

@radmen
Copy link
Contributor Author

radmen commented Aug 7, 2017

@ddziaduch looks nice. Is this supported by phpcs? We could automate code style validation.

@ddziaduch
Copy link
Contributor

@nkkollaw @radmen don't know :<

@nkkollaw
Copy link
Owner

nkkollaw commented Aug 8, 2017

I looked today somewhat briefly, they don't seem to even mention it.

What are the new specs called, do you know? Perhaps PSR-9? That would ease searching...

@nkkollaw nkkollaw self-assigned this Aug 8, 2017
@ddziaduch
Copy link
Contributor

It does not have number yet. Seems that it is still a draft http://www.php-fig.org/psr/

@nkkollaw
Copy link
Owner

nkkollaw commented Aug 9, 2017

Damn.

The only solution would be to configure phpcs manually, so that we used its configuration for PSR-2 and configured everything else found in the draft manually.

I don't know.

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

No branches or pull requests

3 participants