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

Coding standard does not specify negation formatting #48

Open
mhujer opened this issue Aug 22, 2018 · 3 comments
Open

Coding standard does not specify negation formatting #48

mhujer opened this issue Aug 22, 2018 · 3 comments

Comments

@mhujer
Copy link
Contributor

mhujer commented Aug 22, 2018

Currently the negation formatting is not explicitly specified in the standard.

It can be written either:

  • with no spaces if (!is_array($foo))
  • with space after if (! is_array($foo))
  • with spaces around if ( ! is_array($foo))

In the Scalar types chapter there is a code example which includes negation formatted without spaces around:

<?php

if (!is_int($foo)) {
	return (int) $foo;
}

So it would be nice to have it explicitly stated in the coding standard. Maybe eventually also checked automatically (but PHP_CodeSniffer currently offers only SpaceAfterNotSniff).

@VasekPurchart
Copy link
Member

Thanks for the suggestion, I will add it in next major version (to not break versioning) in the format stated in the code example.

@mhujer
Copy link
Contributor Author

mhujer commented Dec 21, 2018

It is now possible to check this with PHPCS>=3.4 squizlabs/PHP_CodeSniffer#2233

@VasekPurchart
Copy link
Member

Yes, I noticed, already have it in my notes :)

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