Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ff08574

Browse files
committed
Factory::fromClassReflection() rejects $withBodies for interfaces
1 parent 7e61e81 commit ff08574

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

‎src/PhpGenerator/Factory.php

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /