Skip to content

Commit

Permalink
Merge pull request #45 from smeghead/improve-test-codes
Browse files Browse the repository at this point in the history
Improve test codes
  • Loading branch information
smeghead authored Apr 2, 2023
2 parents aef32d9 + 383b8bc commit 05bf22a
Show file tree
Hide file tree
Showing 26 changed files with 320 additions and 685 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ A CLI tool that parses the PHP source directory and outputs PlantUML class diagr

![Testing](https://github.com/smeghead/php-class-diagram/actions/workflows/php.yml/badge.svg?event=push) [![Latest Stable Version](http://poser.pugx.org/smeghead/php-class-diagram/v)](https://packagist.org/packages/smeghead/php-class-diagram) [![Total Downloads](http://poser.pugx.org/smeghead/php-class-diagram/downloads)](https://packagist.org/packages/smeghead/php-class-diagram) [![Latest Unstable Version](http://poser.pugx.org/smeghead/php-class-diagram/v/unstable)](https://packagist.org/packages/smeghead/php-class-diagram) [![License](http://poser.pugx.org/smeghead/php-class-diagram/license)](https://packagist.org/packages/smeghead/php-class-diagram) [![PHP Version Require](http://poser.pugx.org/smeghead/php-class-diagram/require/php)](https://packagist.org/packages/smeghead/php-class-diagram)

# Features
## Features

* ♻️ Generating class diagrams from source code helps improve continuous design.
* 🔖 Generates expressive class diagrams with an emphasis on namespaces and relationships.
* 🔧 A simple CLI tool that is easy to handle.
* 💡 It is also possible to output a package relationship diagram that visualizes the dependency on the external namespace.

## Dogfooding

### php-class-diagram class diagram

![dogfood class diagram image.](dogfood.png)
Expand Down
12 changes: 6 additions & 6 deletions src/Php/PhpAccessModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

class PhpAccessModifier
{
protected bool $public = false;
protected bool $protected = false;
protected bool $private = false;
protected bool $abstract = false;
protected bool $final = false;
protected bool $static = false;
private bool $public = false;
private bool $protected = false;
private bool $private = false;
private bool $abstract = false;
private bool $final = false;
private bool $static = false;

public function __construct(ClassConst|Property|ClassMethod $stmt)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Php/PhpClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
class PhpClass
{
/** @var string[] directory parts */
protected array $dirs;
protected ClassLike $syntax;
protected array $full;
private array $dirs;
private ClassLike $syntax;
private array $full;

public function __construct(string $filename, Stmt $syntax, array $full)
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public function getProperties(): array
/**
* @return Property[] プロパティ一覧
*/
protected function getPropertiesFromSyntax(): array
private function getPropertiesFromSyntax(): array
{
return $this->syntax->getProperties();
}
Expand Down Expand Up @@ -149,7 +149,7 @@ private function getUsesRec($stmts, $uses = [])
* * 自身のクラス名が目的のクラスかどうか ... (不要かもしれない。暗黙の参照と統合可能
* * 暗黙の参照として、自身のnamespaceを返却する
*/
protected function findNamespaceByTypeParts(array $type_parts): array
private function findNamespaceByTypeParts(array $type_parts): array
{
$type = str_replace('[]', '', array_pop($type_parts));
$primitives = ['string', 'bool', 'boolean', 'int', 'integer', 'float', 'double', 'array', 'object', 'resource'];
Expand Down Expand Up @@ -183,7 +183,7 @@ public function getMethods(): array
return $methods;
}

protected function getMethodInfo(ClassMethod $method): PhpMethod
private function getMethodInfo(ClassMethod $method): PhpMethod
{
return new PhpMethod($method, $this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Php/PhpEnumCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

class PhpEnumCase
{
protected string $name;
protected PhpDocComment $doc;
private string $name;
private PhpDocComment $doc;

public function __construct(EnumCase $e)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Php/PhpMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

class PhpMethod
{
protected string $name;
protected PhpTypeExpression $type;
private string $name;
private PhpTypeExpression $type;
/** @var PhpMethodParameter[] パラメータ一覧 */
protected array $params;
protected PhpAccessModifier $accessModifier;
private array $params;
private PhpAccessModifier $accessModifier;

public function __construct(ClassMethod $method, PhpClass $class)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Php/PhpProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

class PhpProperty
{
protected string $name;
protected PhpTypeExpression $type;
protected PhpAccessModifier $accessModifier;
private string $name;
private PhpTypeExpression $type;
private PhpAccessModifier $accessModifier;

public function __construct(Property $p, PhpClass $class)
{
Expand Down
Loading

0 comments on commit 05bf22a

Please sign in to comment.