[TYPO3-core] declare(encoding='UTF-8'); in extension config files

Oliver Hader oliver.hader at typo3.org
Fri Mar 1 11:06:00 CET 2013


Hi everybody,

thanks for your feedback on this issue. Since several people mentioned
their concerns on using the declare(encoding=...) statements and the
TYPO3 Flow/Neos Team had troubles with that in the past, it's not
encouraged to use it at all - especially not in ext_tables.php and
ext_localconf.php files.

* an accordant remark is going to be added to the CGL sections
* the accordant patches to strip those lines from ext_*.php files is
  going to be abandonned as discussed with the initial authors during
  the review day in IRC

Thanks & Cheers,
Olly


Am 25.02.13 11:01, schrieb Christian Weiske:
> Hello all,
> 
> 
> 
> Since PHP 5.3.0, developers may declare the character set of a PHP file
> using a declare line at the beginning of a file[1]:
> 
>> declare(encoding='ISO-8859-1');
> or
>> declare(encoding='UTF-8');
> 
> This can be used by editors to display the file's characters correctly,
> and is used by PHP's zend multi byte feature (--enable-zend-multibyte)
> to automatically convert the strings in the file.
> 
> A declare(encoding) statement is only valid at the beginning of a file,
> and may be used only once - otherwise a fatal error is issued:
>> PHP Fatal error:  Encoding declaration pragma must be the very first
>> statement in the script
> 
> Knowing that behavior is important when merging several PHP files
> together. TYPO3 does this when creating temporary files that contain the
> contents of ext_tables.php and ext_localconf.php of all active
> extensions.
> 
> When creating those files, TYPO3 needs to remove those declare encoding
> lines, because otherwise the temporary files are invalid and lead to
> fatal PHP errors.
> 
> 
> We've created a patch for this, http://forge.typo3.org/issues/40069
> 
> Helmut Hummel is in favor[2] of simply declaring the declare()
> statements as "not allowed" in ext_localconf.php/ext_tables.php files,
> thus making the issue a non-issue by ignoring it.
> 
> I think that TYPO3 should handle this case: Using declare statements is
> allowed in PHP, and useful for both editing tools and and PHP output.
> 
> What do you think?
> 
> 
> [1] http://php.net/manual/en/control-structures.declare.php
> [2] http://forge.typo3.org/issues/40069#note-16
> 


-- 
Oliver Hader
TYPO3 CMS Core Team Leader

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org


More information about the TYPO3-team-core mailing list