Konafets / TYPO3SniffPool

This repository contains custom sniffs which are compatible with the PHP_CodeSniffer. Understand this package as a sniff pool which contains all needed custom sniffs for the various TYPO3 projects.
21 stars 10 forks source link

ValidVariableNameSniff.php raises Deprecation Error in PHP 5.5 #15

Closed garbast closed 10 years ago

garbast commented 10 years ago

In Sniffs/NamingConventions/ValidVariableNameSniff.php there is a preg_replace with switch /e as callback. In PHP 5.5 this is deprecated and should get replaced with preg_replace_callback. The following change fixes this.

Replace $pattern = '/([A-Z]{1,}(?=[A-Z]?|[0-9]))/e'; $replace = "ucfirst(strtolower('\1'))"; $variableNameLowerCamelCased = preg_replace($pattern, $replace, $variableName);

With $pattern = '/([A-Z]{1,}(?=[A-Z]?|[0-9]))/'; $variableNameLowerCamelCased = preg_replace_callback($pattern, function($m) { return ucfirst(strtolower($m[1])); }, $variableName);

Konafets commented 10 years ago

Fixed in develop branch