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

[Question] Encapsed variable + Single quote preference #59

Closed
popojargo opened this issue Feb 5, 2017 · 5 comments
Closed

[Question] Encapsed variable + Single quote preference #59

popojargo opened this issue Feb 5, 2017 · 5 comments

Comments

@popojargo
Copy link
Contributor

I would like to make sure that single quotes are preferred but allow the use of double quotes for encapsed variables. Is there a way to allow such a configuration?

@tchule
Copy link
Contributor

tchule commented Feb 6, 2017

I havn't tested it for a while, but you should be able to specify the level of error of the "preferQuotes" test.
It should be "warning"by default, you can set it to "info".

<test name="preferQuotes">
		<property name="type" value="single"  level="info" />
</test>

@popojargo
Copy link
Contributor Author

I know that we can change the level but is there a way to create an exception for double quotes?
The point is, I'm using single quotes by preference because it's more efficient than double quotes.
Therefore, when you have values that need to be printed in a string, it's as much efficient to use double quotes or concatenation.

@tchule
Copy link
Contributor

tchule commented Feb 7, 2017

I'm sorry, I'm not sure I understand what you want to do.

You prefer to use single quotes in the code, ok. So PHPCheckstyle should say nothing when it encounters single quotes. When it encounters double quotes, it should raise an error/warning/info.
That's what the "preferQuotes" check should do.

Can you provide an example of code with the expected result ?

Thanks,

@jbrooksuk
Copy link
Contributor

I'm using single quotes by preference because it's more efficient than double quotes.

https://nikic.github.io/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html

@popojargo
Copy link
Contributor Author

I think that I will only change the level to info. Thank you for your time guys

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

3 participants