diff --git a/README.md b/README.md index a19d3f2..2c44346 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Usage ### the `classes` command generates a class diagram from all classes in the given folder Usage: - classes [--console] [--debug] [--properties] [--methods] folder + classes [--console] [--debug] [--properties] [--methods] [--filter] folder Arguments: folder the folder to scan for classes @@ -41,6 +41,7 @@ Usage --debug debug --properties build with properties --methods build with methods + --filter to include/exclude files/folder ```sh diff --git a/composer.json b/composer.json index b266479..84e30ee 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "pimple/pimple": "@stable", "symfony/console": "@stable", "kriswallsmith/buzz": "@stable", - "andrewsville/php-token-reflection": "@stable" + "andrewsville/php-token-reflection": "dev-develop@dev" }, "require-dev" : { @@ -37,5 +37,13 @@ } }, + "repositories" : [ + { + "type" : "vcs", + "url" : "https://github.com/digitalkaoz/PHP-Token-Reflection" + } + ], + + "bin": ["bin/yuml-php"] } diff --git a/src/YumlPhp/Command/ClassesCommand.php b/src/YumlPhp/Command/ClassesCommand.php index 8142756..2200a13 100644 --- a/src/YumlPhp/Command/ClassesCommand.php +++ b/src/YumlPhp/Command/ClassesCommand.php @@ -31,6 +31,7 @@ protected function configure() $this->getDefinition()->addOption(new InputOption('properties', null, InputOption::VALUE_NONE, 'build with properties')); $this->getDefinition()->addOption(new InputOption('methods', null, InputOption::VALUE_NONE, 'build with methods')); + $this->getDefinition()->addOption(new InputOption('filter', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'glob pattern filter')); $this ->setName('classes') @@ -60,6 +61,7 @@ protected function getBuilderConfig(BuilderInterface $builder, InputInterface $i 'withMethods' => $input->getOption('methods'), 'withProperties' => $input->getOption('properties'), 'style' => $style, + 'filter' => $input->getOption('filter'), 'autoload_path' => $input->getArgument('source') ); } diff --git a/src/YumlPhp/Request/ClassesRequest.php b/src/YumlPhp/Request/ClassesRequest.php index 09fd555..0142331 100644 --- a/src/YumlPhp/Request/ClassesRequest.php +++ b/src/YumlPhp/Request/ClassesRequest.php @@ -14,6 +14,7 @@ use TokenReflection\Broker; use TokenReflection\IReflectionClass; use TokenReflection\IReflectionMethod; +use TokenReflection\IReflectionProperty; /** * The console application that handles the commands @@ -22,7 +23,14 @@ */ abstract class ClassesRequest implements RequestInterface { - private $config = array(), $path; + private $config = array( + 'filter' => array(), + 'withProperties' => false, + 'withMethods' => false, + 'debug' => false + ); + + private $path; /** * @inheritDoc @@ -39,7 +47,7 @@ public function setPath($path) */ public function configure(array $config) { - $this->config = $config; + $this->config = array_merge($this->config, $config); return $this; } @@ -52,7 +60,7 @@ public function configure(array $config) protected function getClasses() { $broker = new Broker(new Broker\Backend\Memory()); - $broker->processDirectory(realpath($this->path)); + $broker->processDirectory(realpath($this->path), $this->config['filter']); $classes = $broker->getClasses(); sort($classes); @@ -120,11 +128,12 @@ protected function buildProperties(IReflectionClass $class, $public = '+', $priv { $props = array(); - if (!isset($this->config['withProperties']) || !$this->config['withProperties'] || $class->isInterface()) { + if (!$this->config['withProperties'] || $class->isInterface()) { return $props; } foreach ($class->getProperties() as $property) { + /** @var IReflectionProperty $property */ if ($property->getDeclaringClass() == $class) { $props[] = ($property->isPublic() ? $public : $private) . $property->getName(); } @@ -148,7 +157,7 @@ protected function buildMethods(IReflectionClass $class, $public = '+', $private { $methods = array(); - if (!isset($this->config['withMethods']) || !$this->config['withMethods']) { + if (!$this->config['withMethods']) { return $methods; }