Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use pdepend\reflection\Autoloader;
- use pdepend\reflection\ReflectionSession;
- use pdepend\reflection\resolvers\PearNamingResolver;
- if ( !isset( $argv[1] ) )
- {
- die( 'Missing dir.' );
- }
- include_once '/home/dotxp/dev/PHP/staticReflection/src/main/php/pdepend/reflection/Autoloader.php';
- spl_autoload_register( array( new Autoloader(), 'autoload' ) );
- $classes = array();
- $intClasses = array();
- $inheritance = array();
- $implemented = array();
- $session = ReflectionSession::createDefaultSession(
- new PearNamingResolver( array( $argv[1] ) )
- );
- $query = $session->createDirectoryQuery();
- foreach ( $query->find( $argv[1] ) as $class )
- {
- if ( strpos( $class->getFileName(), 'tests/' ) !== false )
- {
- continue;
- }
- $fullName = fqn( $class );
- $classes[$fullName] = true;
- $intClasses[$fullName] = true;
- $parent = $class->getParentClass();
- if ( $parent !== false )
- {
- $classes[fqn( $parent )] = true;
- $inheritance[fqn( $class )] = fqn( $parent );
- }
- }
- function fqn( $class )
- {
- return $class->getNamespaceName() . '\\' . $class->getName();
- }
- echo "\n\n";
- echo "digraph ClassDiagram {\n";
- echo " rankdir=BT\n\n";
- classNode( 'External', false );
- foreach ( $classes as $className => $dummy )
- {
- if ( isset( $intClasses[$className] ) )
- {
- classNode( $className, true );
- }
- }
- function classNode( $className, $isInternal )
- {
- echo sprintf(
- " %s [shape=box,color=black,fontcolor=%s,label=\"%s\"]\n",
- stripslashes( $className ),
- ( $isInternal ? 'black' : '"#c0c0c0"' ),
- addslashes( $className )
- );
- }
- echo "\n";
- foreach ( $inheritance as $from => $to )
- {
- echo sprintf(
- " %s -> %s\n",
- stripslashes( $from ),
- ( isset( $intClasses[$to] ) ? stripslashes( $to ) : "External" )
- );
- }
- echo "}\n";
Add Comment
Please, Sign In to add comment