Skip to content

Commit 1d90ffe

Browse files
committed
Factory::fromClassReflection() rejects $withBodies for interfaces
1 parent 206a0eb commit 1d90ffe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/PhpGenerator/Factory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function fromClassReflection(
3131
bool $withBodies = false,
3232
): ClassLike
3333
{
34-
if ($withBodies && ($from->isAnonymous() || $from->isInternal())) {
35-
throw new Nette\NotSupportedException('The $withBodies parameter cannot be used for anonymous or internal classes.');
34+
if ($withBodies && ($from->isAnonymous() || $from->isInternal() || $from->isInterface())) {
35+
throw new Nette\NotSupportedException('The $withBodies parameter cannot be used for anonymous or internal classes or interfaces.');
3636
}
3737

3838
$enumIface = null;

tests/PhpGenerator/ClassType.from.bodies.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require __DIR__ . '/fixtures/bodies.php';
1212
Assert::exception(
1313
fn() => ClassType::from(PDO::class, withBodies: true),
1414
Nette\NotSupportedException::class,
15-
'The $withBodies parameter cannot be used for anonymous or internal classes.',
15+
'The $withBodies parameter cannot be used for anonymous or internal classes or interfaces.',
1616
);
1717

1818

@@ -23,7 +23,7 @@ Assert::exception(
2323
}
2424
}, withBodies: true),
2525
Nette\NotSupportedException::class,
26-
'The $withBodies parameter cannot be used for anonymous or internal classes.',
26+
'The $withBodies parameter cannot be used for anonymous or internal classes or interfaces.',
2727
);
2828

2929

0 commit comments

Comments
 (0)