Skip to content

Commit 2b56326

Browse files
committed
Prevent compile errors with "Name already in use" issue
1 parent 9ff8ed9 commit 2b56326

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Compiler/Compiler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function compile(
4242
$fqcn = (string) ($class = ($context->getClass() ?? new ClassReferenceMetadata($className, $namespace)));
4343

4444
if ($context->getFilePath() !== null && file_exists($context->getFilePath())) {
45-
include $context->getFilePath();
45+
include_once $context->getFilePath();
4646
}
4747

4848
$tree = $this->strategy->buildTree(
@@ -54,9 +54,9 @@ public function compile(
5454
$prettyPrinter = new PrettyPrinter\Standard();
5555
if ($context->getFilePath() !== null && is_writable(dirname($context->getFilePath()))) {
5656
file_put_contents($context->getFilePath(), $prettyPrinter->prettyPrintFile($tree));
57-
include $context->getFilePath();
57+
include_once $context->getFilePath();
5858
} else {
59-
include 'data://text/plain;base64,' . base64_encode($prettyPrinter->prettyPrintFile($tree));
59+
include_once 'data://text/plain;base64,' . base64_encode($prettyPrinter->prettyPrintFile($tree));
6060
}
6161

6262
return new $fqcn();

0 commit comments

Comments
 (0)