Have a large file with 130k lines ~2k classes in it each encapsulated in a if(!class_exists()){}.
Objective is 2k individual class files with namespaces (currently none) from this data. Will use a parent namespace (let's call it Parent for now) and then first part of class name will be child namespace so. Example:
<?php
if (!class_exists('ThisClassName'){
class ThisClassName {}
}
if (!class_exists('ThisOtherClass'){
class ThisOtherClass{}
}
if (!class_exists('ThatClassName'){
class ThatClassName {}
}
if (!class_exists('ThatOtherClass'){
class ThatOtherClass{}
}
This will end up in this hierarchy:
src/ (root)
This/
ThisClassName.php
ThisOtherClass.php
That/
ThatClassName.php
ThatOtherClass.php
Example file:
<?php
namespace Parent\First;
class FirstClassName {}
Thoughts on how to start writing this script? Language for the file is PHP, though that's not required for any of the extraction scripting. Also consider any valid PHP could be in there for regex purposes.
P.s. For anyone curious this is NetSuite's PHP Toolkit (2016-2018, hopefully they wise up in 2019 and move to PSR)