Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fixing deprecated preg_replace usage in classmap_generator.php #7135

Merged
merged 2 commits into from
Jan 18, 2015

Conversation

Lansoweb
Copy link
Contributor

With php >= 5.5, the /e parameter in preg_replace is deprecated and gives the warning:

Creating class file map for library in '<path>'...
PHP Deprecated:  preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in <path>/zf2/bin/classmap_generator.php on line 231

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in <path>/zf2/bin/classmap_generator.php on line 231
Wrote classmap file to '<path>/autoload_classmap.php'

As suggested, this PR changes the preg_replace to preg_replace_callback.

@Ocramius Ocramius added the bug label Jan 18, 2015
@Ocramius Ocramius added this to the 2.3.5 milestone Jan 18, 2015
@@ -228,7 +231,11 @@
$maxWidth = max($maxWidth, strlen($match[1]));
}

$content = preg_replace('(\n\s+([^=]+)=>)e', "'\n \\1' . str_repeat(' ', " . $maxWidth . " - strlen('\\1')) . '=>'", $content);
$content = preg_replace_callback('(\n\s+([^=]+)=>)', function ($matches)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

psr-2 coding standard, the brace { should be in same line after function ($matches), so it should be :

$content = preg_replace_callback('(\n\s+([^=]+)=>)', function ($matches) {

@Lansoweb
Copy link
Contributor Author

Thanks @samsonasik! Fixed.

@Ocramius Ocramius self-assigned this Jan 18, 2015
Ocramius added a commit that referenced this pull request Jan 18, 2015
…ssmap-generator' into develop

Close #7135
Forward port #7135
@Ocramius Ocramius merged commit 542c11f into zendframework:master Jan 18, 2015
Ocramius added a commit that referenced this pull request Jan 18, 2015
@Ocramius
Copy link
Member

Merged, thanks @Lansoweb!

master: 4513cc4
develop: 99e0bc0

@Lansoweb
Copy link
Contributor Author

@Ocramius My pleasure. Can close bug #7134 too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants