Skip to content
Open
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
5 changes: 3 additions & 2 deletions src/core/src/Context/ApplicationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
namespace Hypervel\Context;

use Hyperf\Context\ApplicationContext as HyperfApplicationContext;
use Hypervel\Container\Contracts\Container as ContainerContract;
use Psr\Container\ContainerInterface;
use TypeError;

class ApplicationContext extends HyperfApplicationContext
{
/**
* @return \Hypervel\Container\Contracts\Container
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phpdoc return type does not match the method signature (Container vs ContainerInterface). Update the docblock to reflect the actual return type (Psr\Container\ContainerInterface) or adjust the signature to match the intended project contract.

Suggested change
* @return \Hypervel\Container\Contracts\Container
* @return \Psr\Container\ContainerInterface

Copilot uses AI. Check for mistakes.
* @throws TypeError
*/
public static function getContainer(): ContainerContract
public static function getContainer(): ContainerInterface
{
/* @phpstan-ignore-next-line */
return self::$container;
Expand Down
14 changes: 14 additions & 0 deletions src/core/src/View/Compilers/Concerns/CompilesHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Hypervel\View\Compilers\Concerns;

use Hypervel\Foundation\Vite;

trait CompilesHelpers
{
/**
Expand All @@ -21,4 +23,16 @@ protected function compileMethod(string $method): string
{
return "<?php echo method_field{$method}; ?>";
}

/**
* Compile the "vite" statements into valid PHP.
*/
protected function compileVite(?string $arguments): string
{
$arguments ??= '()';

$class = Vite::class;

return "<?php echo app('{$class}'){$arguments}; ?>";
}
}
4 changes: 4 additions & 0 deletions src/foundation/publish/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@

'url' => env('APP_URL', 'http://localhost'),

'frontend_url' => env('FRONTEND_URL', 'http://localhost:3000'),

'asset_url' => env('ASSET_URL', 'https://example.com'),

/*
|--------------------------------------------------------------------------
| Application Timezone
Expand Down
1 change: 1 addition & 0 deletions src/foundation/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ protected function registerCoreContainerAliases(): void
\Hypervel\Queue\Failed\FailedJobProviderInterface::class => ['queue.failer'],
\Hypervel\Validation\Contracts\Factory::class => ['validator'],
\Hypervel\Validation\DatabasePresenceVerifierInterface::class => ['validation.presence'],
\Hypervel\Foundation\Vite::class => ['vite'],
] as $key => $aliases) {
foreach ($aliases as $alias) {
$this->alias($key, $alias);
Expand Down
6 changes: 4 additions & 2 deletions src/foundation/src/Providers/FoundationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ protected function listenCommandException(): void
protected function isConsoleKernelCall(Throwable $exception): bool
{
foreach ($exception->getTrace() as $trace) {
if (($trace['class'] ?? null) === ConsoleKernel::class
&& ($trace['function'] ?? null) === 'call') {
if (
($trace['class'] ?? null) === ConsoleKernel::class
&& ($trace['function'] ?? null) === 'call'
) {
return true;
}
}
Expand Down
107 changes: 107 additions & 0 deletions src/foundation/src/Testing/Concerns/InteractsWithContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
use Hypervel\Foundation\Contracts\Application as ApplicationContract;
use Hypervel\Foundation\Testing\DatabaseConnectionResolver;
use Hypervel\Foundation\Testing\Dispatcher\HttpDispatcher as TestingHttpDispatcher;
use Hypervel\Foundation\Vite;
use Hypervel\Support\Facades\Facade;
use Hypervel\Support\HtmlString;
use Mockery;
use Mockery\MockInterface;

trait InteractsWithContainer
{
protected ?ApplicationContract $app = null;

protected $originalVite;

/**
* Register an instance of an object in the container.
*
Expand Down Expand Up @@ -79,6 +84,108 @@ protected function forgetMock(string $abstract): static
return $this;
}

/**
* Register an empty handler for Vite in the container.
*
* @return $this
*/
protected function withoutVite(): static
{
if ($this->originalVite == null) {
$this->originalVite = app(Vite::class);
}

Facade::clearResolvedInstance(Vite::class);

$this->swap(Vite::class, new class extends Vite {
public function __invoke(array|string $entrypoints, ?string $buildDirectory = null): HtmlString
{
return new HtmlString('');
}

public function __call($method, $parameters): string
{
return '';
}

public function __toString(): string
{
return '';
}

public function useIntegrityKey(bool|string $key): static
{
return $this;
}

public function useBuildDirectory(string $path): static
{
return $this;
}

public function useHotFile(string $path): static
{
return $this;
}

public function withEntryPoints(array $entryPoints): static
{
return $this;
}

public function useScriptTagAttributes(callable|array $attributes): static
{
return $this;
}

public function useStyleTagAttributes(callable|array $attributes): static
{
return $this;
}

public function usePreloadTagAttributes(callable|array|false $attributes): static
{
return $this;
}

public function preloadedAssets(): array
{
return [];
}

public function reactRefresh(): ?HtmlString
{
return new HtmlString('');
}

public function content(string $asset, ?string $buildDirectory = null): string
{
return '';
}

public function asset(string $asset, ?string $buildDirectory = null): string
{
return '';
}
});

return $this;
}

/**
* Restore Vite in the container.
*
* @return $this
*/
protected function withVite(): static
{
if ($this->originalVite) {
$this->app->instance(Vite::class, $this->originalVite);
}

return $this;
}

protected function flushApplication(): void
{
$this->app = null;
Expand Down
Loading