Skip to content

Commit

Permalink
Some cleanup (formatting/beautifying)
Browse files Browse the repository at this point in the history
  • Loading branch information
muratpurc committed Sep 27, 2011
1 parent badd378 commit d9b69fb
Show file tree
Hide file tree
Showing 5 changed files with 625 additions and 625 deletions.
12 changes: 6 additions & 6 deletions autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
/**
* Example autoload implementation which uses the generated class map configuration
*
* This file contains the class definition and the registration of the autoloader
* together for the sake of simplicity. This is up to you to separate the logic to
* This file contains the class definition and the registration of the autoloader
* together for the sake of simplicity. This is up to you to separate the logic to
* your requirements/wishes.
*
* Usage:
* <pre>
* // include this file, e. g. at the beginning of your scripts or in a bootstrap
* // include this file, e. g. at the beginning of your scripts or in a bootstrap
* // implementation
* require_once('/path/to/autoloader.php');
* // ... then use your classes ...
* </pre>
*
* @category Development
* @package mpAutoloaderClassMap
* @author Murat Purc <[email protected]>
* @package mpAutoloaderClassMap
* @author Murat Purc <[email protected]>
* @copyright Copyright (c) 2009-2011 Murat Purc (http://www.purc.de)
* @license http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2
* @version $Id$
Expand All @@ -37,7 +37,7 @@ class myAutoloader
/**
* Autoloader implementation
* @param string $name The required class name
* @throws Exception if autoloader couldn't set class map configuration in initial call
* @throws Exception if autoloader couldn't set class map configuration in initial call
*/
public static function autoload($name)
{
Expand Down
164 changes: 82 additions & 82 deletions example.php
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
<?php
/**
* Example usage for autoloader class map file generator.
*
* Parses full PEAR directory and creates a class map file!
*
* Usage:
* ------
* 1. Modifiy settings to youre requriements
* 2. call this cript from command line as follows:
* $ php example.php
* 3. Check created class map file
*
* @category Development
* @package mpAutoloaderClassMap
* @author Murat Purc <[email protected]>
* @copyright Copyright (c) 2009-2011 Murat Purc (http://www.purc.de)
* @license http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2
* @version $Id$
*/


################################################################################
##### Initialization/Settings

// create a page context class, better than spamming global scope
$context = new stdClass();

// current path
$context->currentPath = str_replace('\\', '/', realpath(dirname(__FILE__) . '/')) . '/';

// the destination file where the class map configuration should be written in
$context->destinationFile = $context->currentPath . '/classmap.configuration.php';

// list of paths from where all class/interface names should be found
// NOTE: Path depends on used environment and should be adapted
$context->pathsToParse = array(
'/path/to/my/project'
);

// list to collect class maps
$context->classMapList = array();

// class file finder options
$context->options = array(
// exclude following folder names
'excludeDirs' => array('temp', 'session', 'docs', 'tests'),
// no specific file exclusion
'excludeFiles' => array(),
// parse all files with '.php' extension
'extensionsToParse' => '.php',
// disbale debugging
'enableDebug' => false,
);


################################################################################
##### Process

// include required classes
include_once($context->currentPath . 'lib/mpClassTypeFinder.php');
include_once($context->currentPath . 'lib/mpClassMapFileCreator.php');

// collect all found class/interface names with their paths
$context->classTypeFinder = new mpClassTypeFinder($context->options);
foreach ($context->pathsToParse as $pos => $dir) {
$classMap = $context->classTypeFinder->findInDir(new SplFileInfo($dir), true);
if ($classMap) {
$context->classMapList = array_merge($context->classMapList, $classMap);
}
}

// uncomment following line to get some debug messages
#echo $context->classTypeFinder->getFormattedDebugMessages();


// write the class map configuration
$context->classMapCreator = new mpClassMapFileCreator();
$context->classMapCreator->create($context->classMapList, $context->destinationFile);


// cleanup
<?php
/**
* Example usage for autoloader class map file generator.
*
* Parses full PEAR directory and creates a class map file!
*
* Usage:
* ------
* 1. Modifiy settings to youre requriements
* 2. call this cript from command line as follows:
* $ php example.php
* 3. Check created class map file
*
* @category Development
* @package mpAutoloaderClassMap
* @author Murat Purc <[email protected]>
* @copyright Copyright (c) 2009-2011 Murat Purc (http://www.purc.de)
* @license http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2
* @version $Id$
*/


################################################################################
##### Initialization/Settings

// create a page context class, better than spamming global scope
$context = new stdClass();

// current path
$context->currentPath = str_replace('\\', '/', realpath(dirname(__FILE__) . '/')) . '/';

// the destination file where the class map configuration should be written in
$context->destinationFile = $context->currentPath . '/classmap.configuration.php';

// list of paths from where all class/interface names should be found
// NOTE: Path depends on used environment and should be adapted
$context->pathsToParse = array(
'/path/to/my/project'
);

// list to collect class maps
$context->classMapList = array();

// class file finder options
$context->options = array(
// exclude following folder names
'excludeDirs' => array('temp', 'session', 'docs', 'tests'),
// no specific file exclusion
'excludeFiles' => array(),
// parse all files with '.php' extension
'extensionsToParse' => '.php',
// disbale debugging
'enableDebug' => false,
);


################################################################################
##### Process

// include required classes
include_once($context->currentPath . 'lib/mpClassTypeFinder.php');
include_once($context->currentPath . 'lib/mpClassMapFileCreator.php');

// collect all found class/interface names with their paths
$context->classTypeFinder = new mpClassTypeFinder($context->options);
foreach ($context->pathsToParse as $pos => $dir) {
$classMap = $context->classTypeFinder->findInDir(new SplFileInfo($dir), true);
if ($classMap) {
$context->classMapList = array_merge($context->classMapList, $classMap);
}
}

// uncomment following line to get some debug messages
#echo $context->classTypeFinder->getFormattedDebugMessages();


// write the class map configuration
$context->classMapCreator = new mpClassMapFileCreator();
$context->classMapCreator->create($context->classMapList, $context->destinationFile);


// cleanup
unset($context);
Loading

0 comments on commit d9b69fb

Please sign in to comment.