Skip to content

Commit 3aef891

Browse files
committed
fix: fix to Avoid interdependencies Smeghead\PhpClassDiagram\Php and Smeghead\PhpClassDiagram\Php\Finders.
1 parent 70ab03d commit 3aef891

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## v1.2.1 (2023-09-07)
4+
5+
### Bug fix
6+
7+
* fix to Avoid interdependencies Smeghead\PhpClassDiagram\Php and Smeghead\PhpClassDiagram\Php\Finders.
8+
39
## v1.2.0 (2023-09-05)
410

511
### Features

dogfood-package.png

-343 Bytes
Loading

src/Php/Finders/FindUsePhpTypes.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Name\FullyQualified;
9-
use PhpParser\Node\Param;
10-
use PhpParser\Node\Stmt\Class_;
119
use PhpParser\Node\Stmt\ClassLike;
1210
use PhpParser\Node\Stmt\ClassMethod;
1311
use PhpParser\NodeFinder;
14-
use Smeghead\PhpClassDiagram\Php\PhpType;
1512

1613
final class FindUsePhpTypes
1714
{
@@ -23,7 +20,7 @@ public function __construct(ClassLike $class)
2320
}
2421

2522
/**
26-
* @return PhpType[] use class types.
23+
* @return FullyQualified[] use class types.
2724
*/
2825
public function collectTypes(): array
2926
{
@@ -39,10 +36,6 @@ public function collectTypes(): array
3936
}));
4037
}
4138
// @phpstan-ignore-next-line
42-
return array_map(function(FullyQualified $x): PhpType {
43-
$parts = $x->parts;
44-
$name = array_pop($parts);
45-
return new PhpType($parts, '', $name);
46-
}, $useClasses);
39+
return $useClasses;
4740
}
4841
}

src/Php/PhpClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,6 @@ public function getDescription(): string
229229
public function getUsingTypes(): array
230230
{
231231
$finder = new FindUsePhpTypes($this->syntax);
232-
return $finder->collectTypes();
232+
return array_map(fn(FullyQualified $x) => new PhpType(array_slice($x->parts, 0, count($x->parts) - 1), '', end($x->parts)), $finder->collectTypes());
233233
}
234234
}

test/FindUsePhpTypesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ public function testMainUseProduct(): void
2626
$this->assertSame(['hoge', 'fuga', 'product'], $types[0]->getNamespace());
2727
$this->assertSame('Product', $types[0]->getName());
2828
}
29-
3029
}

0 commit comments

Comments
 (0)