Commit 43262d9d authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

CS.

parent d4dd2622
......@@ -32,7 +32,7 @@ use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
*/
class GenerateCommand extends ContainerAwareCommand
{
protected function configure()
protected function configure(): void
{
$this
->setName('irstea:plantuml:generate')
......@@ -41,11 +41,9 @@ class GenerateCommand extends ContainerAwareCommand
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @SuppressWarnings(UnusedFormalParameter)
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$name = $input->getArgument('graph');
$serviceId = "irstea_plant_uml.graph.$name";
......
......@@ -53,7 +53,7 @@ class ListCommand extends Command
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setName(self::CMD_NAME)
......
......@@ -78,14 +78,6 @@ class RenderCommand extends Command
/**
* RenderCommand constructor.
*
* @param ContainerInterface $container
* @param array $graphNames
* @param string $defaultFormat
* @param string $defaultOutput
* @param string $javaBinary
* @param string $plantUmlJar
* @param string $dotBinary
*/
public function __construct(ContainerInterface $container, array $graphNames, string $defaultFormat, string $defaultOutput, string $javaBinary, string $plantUmlJar, string $dotBinary)
{
......@@ -115,7 +107,7 @@ class RenderCommand extends Command
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): void
{
$graphs = $input->getArgument('graph') ?: $this->graphNames;
$format = $input->getOption('format') ?: $this->defaultFormat;
......@@ -124,7 +116,7 @@ class RenderCommand extends Command
$io = new SymfonyStyle($input, $output);
foreach ($graphs as $name) {
$target = $outputDir . DIRECTORY_SEPARATOR . $name . '.' . $format;
$target = $outputDir . \DIRECTORY_SEPARATOR . $name . '.' . $format;
$io->section("Graphe: $name");
......@@ -135,10 +127,8 @@ class RenderCommand extends Command
}
/**
* @param Graph $graph
* @param $target
* @param $format
* @param SymfonyStyle $io
*/
private function renderGraph(Graph $graph, $target, $format, SymfonyStyle $io): void
{
......@@ -177,8 +167,6 @@ class RenderCommand extends Command
/**
* @param $target
* @param $format
*
* @return array
*/
private function startProcess($target, $format): array
{
......@@ -191,7 +179,7 @@ class RenderCommand extends Command
);
$fs = new Filesystem();
$fs->mkdir(dirname($target));
$fs->mkdir(\dirname($target));
$desc = [
// stdin
......@@ -208,14 +196,9 @@ class RenderCommand extends Command
return [$proc, $pipes];
}
/**
* @param string $nameOrPath
*
* @return string
*/
private function findExecutable(string $nameOrPath): string
{
if (\file_exists($nameOrPath) && \is_executable($nameOrPath)) {
if (file_exists($nameOrPath) && is_executable($nameOrPath)) {
return $nameOrPath;
}
$exec = new ExecutableFinder();
......
......@@ -61,8 +61,6 @@ class ClassFilterBuilder
}
/**
* @param array $config
*
* @return Reference
*/
public function build(array $config)
......@@ -73,7 +71,7 @@ class ClassFilterBuilder
}
$hash = sha1(serialize($filters));
if (!key_exists($hash, $this->filters)) {
if (!array_key_exists($hash, $this->filters)) {
return $this->filters[$hash] = $this->doBuild("irstea.plant_uml.filters.$hash", $filters);
}
......@@ -90,14 +88,14 @@ class ClassFilterBuilder
if ($data === null || $data === []) {
return null;
}
if (is_array($data)) {
if (\is_array($data)) {
$res = [];
$isList = true;
foreach ($data as $k => $v) {
$normalized = $this->normalize($v);
if (!empty($normalized)) {
$res[$k] = $normalized;
if (!is_int($k)) {
if (!\is_int($k)) {
$isList = false;
}
}
......@@ -118,8 +116,7 @@ class ClassFilterBuilder
}
/**
* @param type $id
* @param array $config
* @param type $id
*
* @return Reference
*/
......@@ -138,7 +135,7 @@ class ClassFilterBuilder
return null;
}
if (count($filters) === 1) {
if (\count($filters) === 1) {
return $filters[0];
}
......@@ -148,12 +145,10 @@ class ClassFilterBuilder
}
/**
* @param array $filters
* @param string $id
* @param array $config
* @param bool $notFound
*/
protected function buildSubFilter(array &$filters, $id, array $config, $notFound)
protected function buildSubFilter(array &$filters, $id, array $config, $notFound): void
{
foreach (self::$filterClasses as $key => $class) {
if (!isset($config[$key])) {
......
......@@ -66,10 +66,7 @@ class GraphDefinitionBuilder
private $definition;
/**
* @param ContainerBuilder $container
* @param string $baseId
* @param array $config
* @param ClassFilterBuilder $filterBuilder
* @param string $baseId
*/
public function __construct(ContainerBuilder $container, $baseId, array $config, ClassFilterBuilder $filterBuilder)
{
......@@ -82,9 +79,6 @@ class GraphDefinitionBuilder
$this->entityManager = new Reference("doctrine.orm.${emId}_entity_manager");
}
/**
* @return Definition
*/
public function build(): Definition
{
if (!$this->definition) {
......@@ -94,9 +88,6 @@ class GraphDefinitionBuilder
return $this->definition;
}
/**
* @return Definition
*/
protected function doBuild(): Definition
{
[$source, $sourceFilter] = $this->buildSources();
......@@ -131,9 +122,6 @@ class GraphDefinitionBuilder
return [$finder, null];
}
/**
* @return Reference
*/
protected function buildFinder(): Reference
{
$config = $this->config['sources'];
......@@ -148,9 +136,6 @@ class GraphDefinitionBuilder
throw new \InvalidArgumentException("Invalid source type: {$config['type']}");
}
/**
* @return Reference
*/
protected function buildFilteredDecorator(): Reference
{
$decorator = $this->buildDecorator();
......@@ -166,9 +151,6 @@ class GraphDefinitionBuilder
return $this->setDefinitionDecorator('decorator', 'irstea.plant_uml.decorator.filtered.template', $decorator, $filter);
}
/**
* @return Reference
*/
protected function buildDecorator(): Reference
{
$config = $this->config['decoration']['decorators'];
......@@ -195,8 +177,6 @@ class GraphDefinitionBuilder
/**
* @param string $type
*
* @return Reference
*/
protected function buildTypedDecorator($type): Reference
{
......@@ -211,9 +191,6 @@ class GraphDefinitionBuilder
return new Reference("irstea.plant_uml.decorator.$type");
}
/**
* @return Reference
*/
protected function buildNamespace(): Reference
{
$type = $this->config['layout']['namespaces'];
......@@ -236,8 +213,6 @@ class GraphDefinitionBuilder
* @param string $localId
* @param string|Definition $classOrDef
* @param array ...$arguments
*
* @return Reference
*/
protected function setDefinition($localId, $classOrDef, ...$arguments): Reference
{
......@@ -256,8 +231,6 @@ class GraphDefinitionBuilder
* @param string $localId
* @param string $templateId
* @param array ...$arguments
*
* @return Reference
*/
protected function setDefinitionDecorator($localId, $templateId, ...$arguments): Reference
{
......@@ -269,8 +242,6 @@ class GraphDefinitionBuilder
/**
* @param string $localId
*
* @return string
*/
protected function globalId($localId): string
{
......
......@@ -58,7 +58,7 @@ class Configuration implements ConfigurationInterface
->end()
->scalarNode('plamtuml_jar')
->info('Archive du logiciel PlantUML')
->defaultValue(dirname(__DIR__, 2) . '/bin/plantuml.jar')
->defaultValue(\dirname(__DIR__, 2) . '/bin/plantuml.jar')
->end()
->scalarNode('dot')
->info("Commande 'dot' du package 'graphviz'")
......
......@@ -32,7 +32,7 @@ use Symfony\Component\DependencyInjection\Loader;
*/
class IrsteaPlantUmlExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
......
......@@ -44,7 +44,7 @@ class AssociationDecorator extends AbstractDoctrineDecorator
);
}
protected function decorateItem(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor, $association)
protected function decorateItem(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor, $association): void
{
if (!$association['isOwningSide']) {
return;
......@@ -102,7 +102,7 @@ class AssociationDecorator extends AbstractDoctrineDecorator
);
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['decorators'][] = 'associations';
}
......
......@@ -28,10 +28,10 @@ use Irstea\PlantUmlBundle\Model\NodeInterface;
*/
class EntityDecorator extends AbstractDoctrineDecorator
{
public function decorate(\ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor)
public function decorate(\ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor): void
{
$this->withMetadata(
function ($metadata) use ($node) {
function ($metadata) use ($node): void {
if ($metadata->isMappedSuperclass) {
$node->addStereotype('mappedSuperClass');
} elseif ($metadata->isEmbeddedClass) {
......@@ -44,7 +44,7 @@ class EntityDecorator extends AbstractDoctrineDecorator
);
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['decorators'][] = 'entity';
}
......
......@@ -46,7 +46,7 @@ class EntityFinder implements FinderInterface
return new ArrayIterator($classes);
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['type'] = 'entities';
}
......
......@@ -43,7 +43,7 @@ class FieldDecorator extends AbstractDoctrineDecorator
);
}
protected function decorateItem(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor, $field)
protected function decorateItem(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor, $field): void
{
$isIdentifier = $this->withMetadata(
function (ClassMetadata $metadata) use ($field) {
......@@ -63,7 +63,7 @@ class FieldDecorator extends AbstractDoctrineDecorator
);
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['decorators'][] = 'fields';
}
......
......@@ -66,7 +66,7 @@ class ClassFinder implements FinderInterface
try {
irstea_plantmul_include($path);
} catch (Exception $ex) {
printf("%s: %s (%s)\n", $path, get_class($ex), $ex->getMessage());
printf("%s: %s (%s)\n", $path, \get_class($ex), $ex->getMessage());
}
}
......@@ -92,10 +92,7 @@ class ClassFinder implements FinderInterface
return new ArrayIterator($this->classes);
}
/**
* @param array $conf
*/
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['type'] = 'classes';
$conf['directories'] = $this->directories;
......
......@@ -49,7 +49,7 @@ class FilteringFinder implements FinderInterface
return new CallbackFilterIterator($this->inner->getIterator(), [$this->filter, 'accept']);
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$this->inner->toConfig($conf);
$this->filter->toConfig($conf);
......
......@@ -25,8 +25,6 @@ use ReflectionClass;
interface ClassFilterInterface extends ToConfigInterface
{
/**
* @param ReflectionClass $class
*
* @return bool
*/
public function accept(ReflectionClass $class);
......
......@@ -60,8 +60,6 @@ class ClassVisitor implements ClassVisitorInterface
}
/**
* @param ClassFilterInterface $filter
*
* @return self
*/
public function setClassFilter(ClassFilterInterface $filter)
......@@ -72,8 +70,6 @@ class ClassVisitor implements ClassVisitorInterface
}
/**
* @param DecoratorInterface $decorator
*
* @return self
*/
public function setDecorator(DecoratorInterface $decorator)
......@@ -87,7 +83,7 @@ class ClassVisitor implements ClassVisitorInterface
{
if ($classOrName instanceof \ReflectionClass) {
$class = $classOrName;
} elseif (is_string($classOrName)) {
} elseif (\is_string($classOrName)) {
$class = new \ReflectionClass($classOrName);
} else {
throw new \InvalidArgumentException('Invalid argument, expected ReflectionClass or string');
......@@ -112,9 +108,6 @@ class ClassVisitor implements ClassVisitorInterface
}
/**
* @param NamespaceInterface $namespace
* @param ReflectionClass $class
*
* @return NodeInterface
*/
protected function createNode(NamespaceInterface $namespace, ReflectionClass $class)
......@@ -137,10 +130,7 @@ class ClassVisitor implements ClassVisitorInterface
return $this->rootNamespace->writeTo($writer);
}
/**
* @param array $conf
*/
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['layout'] = [];
$conf['decoration'] = [];
......
......@@ -30,12 +30,7 @@ use Irstea\PlantUmlBundle\Model\NodeInterface;
*/
abstract class AbstractRelationDecorator implements DecoratorInterface
{
/**
* @param NodeInterface $source
* @param array $classNames
* @param ClassVisitorInterface $visitor
*/
protected function visitRelations(NodeInterface $source, array $classNames, ClassVisitorInterface $visitor)
protected function visitRelations(NodeInterface $source, array $classNames, ClassVisitorInterface $visitor): void
{
foreach ($classNames as $className) {
$target = $visitor->visitClass($className);
......@@ -46,9 +41,6 @@ abstract class AbstractRelationDecorator implements DecoratorInterface
}
/**
* @param NodeInterface $source
* @param NodeInterface $target
*
* @return ArrowInterface
*/
abstract protected function buildRelation(NodeInterface $source, NodeInterface $target);
......
......@@ -33,7 +33,7 @@ use ReflectionProperty;
*/
class AttributeDecorator implements DecoratorInterface
{
public function decorate(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor)
public function decorate(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor): void
{
foreach ($class->getProperties() as $property) {
/* @var $property ReflectionProperty */
......@@ -55,7 +55,7 @@ class AttributeDecorator implements DecoratorInterface
}
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$conf['decorators'][] = 'attributes';
}
......
......@@ -56,7 +56,7 @@ class CompositeDecorator implements DecoratorInterface
return $this;
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
foreach ($this->decorators as $decorator) {
$decorator->toConfig($conf);
......
......@@ -41,10 +41,6 @@ class FilteringDecorator implements DecoratorInterface
*/
private $filter;
/**
* @param DecoratorInterface $next
* @param ClassFilterInterface $filter
*/
public function __construct(DecoratorInterface $next, ClassFilterInterface $filter)
{
$this->next = $next;
......@@ -60,7 +56,7 @@ class FilteringDecorator implements DecoratorInterface
return $this;
}
public function toConfig(array &$conf)
public function toConfig(array &$conf): void
{
$this->filter->toConfig($conf);
$this->next->toConfig($conf);
......
......@@ -31,10 +31,6 @@ use ReflectionClass;
trait InheritableItemDecoratorTrait
{
/**
* @param \ReflectionClass $class
* @param NodeInterface $node
* @param ClassVisitorInterface $visitor
*
* @return self
*/
public function decorate(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment