Skip to content

Commit

Permalink
fix: fix to Avoid interdependencies Smeghead\PhpClassDiagram\Php and …
Browse files Browse the repository at this point in the history
…Smeghead\PhpClassDiagram\Php\Finders.
  • Loading branch information
smeghead committed Sep 7, 2023
1 parent 70ab03d commit 3aef891
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## v1.2.1 (2023-09-07)

### Bug fix

* fix to Avoid interdependencies Smeghead\PhpClassDiagram\Php and Smeghead\PhpClassDiagram\Php\Finders.

## v1.2.0 (2023-09-05)

### Features
Expand Down
Binary file modified dogfood-package.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions src/Php/Finders/FindUsePhpTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\NodeFinder;
use Smeghead\PhpClassDiagram\Php\PhpType;

final class FindUsePhpTypes
{
Expand All @@ -23,7 +20,7 @@ public function __construct(ClassLike $class)
}

/**
* @return PhpType[] use class types.
* @return FullyQualified[] use class types.
*/
public function collectTypes(): array
{
Expand All @@ -39,10 +36,6 @@ public function collectTypes(): array
}));
}
// @phpstan-ignore-next-line
return array_map(function(FullyQualified $x): PhpType {
$parts = $x->parts;
$name = array_pop($parts);
return new PhpType($parts, '', $name);
}, $useClasses);
return $useClasses;
}
}
2 changes: 1 addition & 1 deletion src/Php/PhpClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,6 @@ public function getDescription(): string
public function getUsingTypes(): array
{
$finder = new FindUsePhpTypes($this->syntax);
return $finder->collectTypes();
return array_map(fn(FullyQualified $x) => new PhpType(array_slice($x->parts, 0, count($x->parts) - 1), '', end($x->parts)), $finder->collectTypes());
}
}
1 change: 0 additions & 1 deletion test/FindUsePhpTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ public function testMainUseProduct(): void
$this->assertSame(['hoge', 'fuga', 'product'], $types[0]->getNamespace());
$this->assertSame('Product', $types[0]->getName());
}

}

0 comments on commit 3aef891

Please sign in to comment.