Skip to content

Instantly share code, notes, and snippets.

@astehlik
Created July 27, 2015 13:20
Show Gist options
  • Save astehlik/3986cbae9d2a87055981 to your computer and use it in GitHub Desktop.
Save astehlik/3986cbae9d2a87055981 to your computer and use it in GitHub Desktop.
Regex for replacing unterscored class names with namespaces
# Moves Tx_Mynamespace_Subname_Classname classes to the Tx\Mynamespace\Subname namespace.
<\?php([\s\S]*class) Tx_Mynamespace_(.+?)_
<?php\nnamespace Tx\\\\Mynamespace\\\\$2;$1
# Moves Tx_Mynamespace_Classname classes to the Tx\Mynamespace namespace.
<\?php([\s\S]*class) Tx_Mynamespace_(.+?)
<?php\nnamespace Tx\\\\Mynamespace;$1 $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment