Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (33 sloc) 1.188 kb
<?php
/**
* createAutoloadTestClasses.php
*
* A script for creating a hierarchy of classes for use with testing
* autoloading. Each directory has classes from a to p; additional classes are
* generated 2 levels deep, giving a total of 16^3 classes to use in
* autoloading tests.
*/
function createClasses($depth, $namespace)
{
foreach (range('a', 'p') as $letter) {
// Create content for namespaced class
$content = "<?php\nnamespace $namespace;\nclass $letter { }";
// Write content to disk
$dir = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
file_put_contents(
$dir . DIRECTORY_SEPARATOR . $letter . '.php',
$content
);
// If we still have depth, recurse and create more classes using the
// current letter as a sub-namespace.
if ($depth > 0) {
$childDir = $dir . DIRECTORY_SEPARATOR . $letter;
mkdir($childDir);
createClasses($depth - 1, $namespace . '\\' . $letter);
}
}
}
// Use 'test' as the top-level namespace, and set a depth of "2" (will provide
// 3 levels of classes).
mkdir('test');
createClasses(2, 'test');
Jump to Line
Something went wrong with that request. Please try again.