[TYPO3-core] Double backslash for namespace
klein.t3 at mfc-linz.at
Tue Jun 17 11:18:52 CEST 2014
Citing the docs:
The simplest way to specify a string is to enclose it in single quotes (the character ').
To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash, double it (\\). ...
TYPO3 CMS Active Contributors Team Member
> -----Original Message-----
> From: typo3-team-core-bounces at lists.typo3.org [mailto:typo3-team-core-
> bounces at lists.typo3.org] On Behalf Of Xavier Perseguers
> Sent: Tuesday, June 17, 2014 11:13 AM
> To: typo3-team-core at lists.typo3.org
> Subject: Re: [TYPO3-core] Double backslash for namespace
> Hi Bernhard,
> > I would like to ask if it is really necessary (according to the CGL)
> > to have double backslash in namespaces. Whenever the single quote
> > string style is used it is not necessary regarding PHP syntax.
> > So:
> > $someObject = GeneralUtility::makeInstance('TYPO3\CMS\SomeObject');
> > Would be fully valid. Double backslashes are not required. I guess
> > they were introduced because the "\" operator is known to be the
> > escape operator. But in case it is followed by any non-escape
> > character it won't do anything. Only if combined with special meaning
> > characters like "\n", "\r", "\x" they will get interpreted - and this
> > also only in double quoted strings.
> > So if we stick to single-quoted strings as usual in TYPO3 world it
> > would be ok to have only one backslash.
> Yes you can abuse the PHP syntax so you may instead write only one
> backslash but in Core we want to stick to strict rules so this character should
> be escaped as well.
> Xavier Perseguers
> TYPO3 CMS Team Member
> TYPO3 .... inspiring people to share!
> Get involved: http://typo3.org
> Before posting to this list, please have a look to the posting rules on the
> following websites:
> TYPO3-team-core mailing list
> TYPO3-team-core at lists.typo3.org
More information about the TYPO3-team-core