Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/Container/ArgonContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,9 @@ public function __construct(
$strictMode
);

if ($serviceResolver instanceof ServiceResolverInterface && $serviceResolver !== $this->serviceResolver) {
if (method_exists($serviceResolver, 'setStrictMode')) {
$serviceResolver->setStrictMode($strictMode);
}
}

$argumentResolver->setServiceResolver($this->serviceResolver);

if (method_exists($this->interceptors, 'setResolver')) {
$this->interceptors->setResolver($this->serviceResolver);
}
$this->interceptors->setResolver($this->serviceResolver);

$this->invoker = $invoker ?? new CallableInvoker(
$this->serviceResolver,
Expand Down
3 changes: 2 additions & 1 deletion src/Container/Compiler/CompilationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function __construct(
public readonly PhpFile $file,
public readonly PhpNamespace $namespace,
public readonly ClassType $class,
public readonly bool $strictMode
public readonly bool $strictMode,
public readonly bool $noReflection
) {
}
}
5 changes: 3 additions & 2 deletions src/Container/Compiler/CompilationContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public function create(
ArgonContainer $container,
string $namespace,
string $className,
bool $strictMode = false
bool $strictMode = false,
bool $noReflection = false
): CompilationContext {
$file = new PhpFile();
$file->setStrictTypes();
Expand All @@ -28,6 +29,6 @@ public function create(
$class = $namespaceGen->addClass($className);
$class->setExtends(ArgonContainer::class);

return new CompilationContext($container, $file, $namespaceGen, $class, $strictMode);
return new CompilationContext($container, $file, $namespaceGen, $class, $strictMode, $noReflection);
}
}
21 changes: 16 additions & 5 deletions src/Container/Compiler/ContainerCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ public function compile(
string $filePath,
string $className,
string $namespace = 'App\\Compiled',
?bool $strictMode = null
bool $strictMode = false,
?bool $noReflection = null
): void {
$strictMode ??= method_exists($this->container, 'isStrictMode')
? $this->container->isStrictMode()
: false;
if (!$strictMode) {
$strictMode = $this->container->isStrictMode();
}

if ($noReflection === null) {
$noReflection = $strictMode;
}

$context = $this->contextFactory->create($this->container, $namespace, $className, $strictMode);
$context = $this->contextFactory->create(
$this->container,
$namespace,
$className,
$strictMode,
$noReflection
);

$this->coreGenerator->generate($context);
$this->serviceDefinitionGenerator->generate($context);
Expand Down
Loading