Re: [fw-general] Re: Zend coding style and multiline string concatenation

2011-11-18 Thread Ralph Schindler

On 11/18/11 1:44 AM, janroald wrote:


weierophinney wrote:


We typically recommend the second format, or the usage of
heredocs/nowdocs (latter is PHP 5.3 only, though). However, our CS does
not dictate either way.


heredoc/nowdocs I would discourage unless there is a fantastic reason to 
use them in "library code" for the following reasons:


  * it pushes text up against the left margin (in the least the 
here/nowdoc label)


  * if you're trying to beautify your code, you'd be adding additional 
spaces after a newline (both of which are probably unnecessary)


  * you cannot be explicit about your line ending types, it just so 
happens to include whatever your setting is in your IDE/editor




Many developers find unnecessary concatenation very annoying.
I'm curious why Zend would recommend this practice.
I'm not criticizing, its all just details, I'm just curious if there's any
good reason for it.


Lets take your above example:


Basically, is following allowed?

   1. $sql = "SELECT `id`, `name` FROM `people`
   2. WHERE `name` = 'Susan'
   3. ORDER BY `name` ASC ";


Or should it be always like this?

   1. $sql = "SELECT `id`, `name` FROM `people` "
   2.  . "WHERE `name` = 'Susan' "
   3.  . "ORDER BY `name` ASC ";


These two things are not equivalent. In the context of a database 
connection where whitespace is removed and the SQL is parsed and 
executed they are equivalent.  To a person who wants to push this 
statement through a logger, they former includes newlines and whitespace 
that they might otherwise not want in their SQL statement.


So, while it's pretty in the context of your IDE/editor, and in the 
context of the database it does not care, inside your log file, you'll 
have unsightly whitespace and newlines.


I, personally, take this a step further and only use double quotes if my 
intention is to interpolate values, otherwise I stick with a single 
quote (by seeing a doublequote ("), my brain automatically says to me: 
"there must be a variable or control character being injected into that 
somewhere".


Have a good one!
Ralph Schindler

--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] Re: Zend coding style and multiline string concatenation

2011-11-18 Thread Matthew Weier O'Phinney
-- janroald  wrote
(on Thursday, 17 November 2011, 11:44 PM -0800):
> weierophinney wrote:
> > We typically recommend the second format, or the usage of
> > heredocs/nowdocs (latter is PHP 5.3 only, though). However, our CS does
> > not dictate either way.
> 
> Many developers find unnecessary concatenation very annoying.  I'm
> curious why Zend would recommend this practice.  I'm not criticizing,
> its all just details, I'm just curious if there's any good reason for
> it. 

Because it makes it more evident in diffs that the content of the line
is a string value.

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




[fw-general] Re: Zend coding style and multiline string concatenation

2011-11-18 Thread janroald

weierophinney wrote:
> 
> We typically recommend the second format, or the usage of
> heredocs/nowdocs (latter is PHP 5.3 only, though). However, our CS does
> not dictate either way.
> 

Many developers find unnecessary concatenation very annoying.
I'm curious why Zend would recommend this practice.
I'm not criticizing, its all just details, I'm just curious if there's any
good reason for it. 


--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-coding-style-and-multiline-string-concatenation-tp4080014p4082458.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com