-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Double quote usage #4
Comments
I completely missed that part. Here's an in depth review: https://blog.blackfire.io/php-7-performance-improvements-encapsed-strings-optimization.html Originally posted by @geerteltink at zendframework/zend-coding-standard#18 (comment) |
You need to update Originally posted by @geerteltink at zendframework/zend-coding-standard#18 (comment) |
Thanks for the review @xtreamwayz . It'd be worth keeping an eye on squizlabs/PHP_CodeSniffer#2259 for a more comprehensive sniff. Originally posted by @kynx at zendframework/zend-coding-standard#18 (comment) |
I saw that this morning. Looks like it's just an idea. No PR yet. Originally posted by @geerteltink at zendframework/zend-coding-standard#18 (comment) |
I believe our rule is that double quoted string can not contain vars or other variable interpolation and Originally posted by @Xerkus at zendframework/zend-coding-standard#18 (comment) |
The main reasons I've advocated usage of
Both of these were informed by performance of previous PHP versions with regards to string interpolation. Interpolation was known to be slow, and escaping rules tend to get messy. Concatenation is predictable, but hard to read. However, if PHP 7 solves most of the performance issues, string interpolation would likely be a viable choice again. As such, I've got an open question to Julien Pauli asking what the performance differences are between the two approaches. Originally posted by @weierophinney at zendframework/zend-coding-standard#18 (comment) |
@weierophinney Did you get a reply on your question? Maybe we could run a benchmark and see for ourselves. |
I never did get a reply, unfortunately. I'd love to have some benchmarks. I definitely prefer using |
@weierophinney tbh, the main place I use interpolation is in exception messages and one-off scripts. I raised the issue after an in-house argument over my exception messages. It blew over long ago :) |
Squiz.Strings.DoubleQuoteUsage.ContainsVar prevents strings containing variables. This doesn't match the examples in the documentation and, given that PHP7s interpolation uses less memory than concatenation, probably isn't intended.
This PR adds an exclude for that check and tries to make the docs a little more exact.
Originally posted by @kynx at zendframework/zend-coding-standard#18
The text was updated successfully, but these errors were encountered: