Skip to content

Commit 2f8743d

Browse files
committed
added ClassType::getTraitResolutions & PhpFile::getNamespaces()
1 parent 6341ebb commit 2f8743d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/PhpGenerator/ClassType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,15 @@ public function getTraits(): array
290290
}
291291

292292

293+
/**
294+
* @internal
295+
*/
296+
public function getTraitResolutions(): array
297+
{
298+
return $this->traits;
299+
}
300+
301+
293302
/**
294303
* @return static
295304
*/

src/PhpGenerator/PhpFile.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ public function addNamespace(string $name): PhpNamespace
6363
}
6464

6565

66+
/**
67+
* @return PhpNamespace[]
68+
*/
69+
public function getNamespaces(): array
70+
{
71+
return $this->namespaces;
72+
}
73+
74+
6675
public function __toString(): string
6776
{
6877
foreach ($this->namespaces as $namespace) {

tests/PhpGenerator/ClassType.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Assert::false($class->isFinal());
2020
Assert::false($class->isAbstract());
2121
Assert::same([], $class->getExtends());
2222
Assert::same([], $class->getTraits());
23+
Assert::same([], $class->getTraitResolutions());
2324

2425
$class
2526
->setAbstract(true)
@@ -38,6 +39,7 @@ Assert::true($class->isFinal());
3839
Assert::true($class->isAbstract());
3940
Assert::same('ParentClass', $class->getExtends());
4041
Assert::same(['ObjectTrait', 'AnotherTrait'], $class->getTraits());
42+
Assert::same(['ObjectTrait' => [], 'AnotherTrait' => ['sayHello as protected']], $class->getTraitResolutions());
4143
Assert::count(2, $class->getConstants());
4244
Assert::type(Nette\PhpGenerator\Constant::class, $class->getConstants()['ROLE']);
4345

0 commit comments

Comments
 (0)