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
31 changes: 18 additions & 13 deletions src/Cli/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Ahc\Cli\Output\ProgressBar;
use Ahc\Cli\Output\Writer;
use BlitzPHP\Exceptions\CLIException;
use BlitzPHP\Utilities\String\Text;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -169,7 +170,7 @@ abstract class Command
/**
* Options recus apres executions
*/
private array $_options = [];
protected array $_options = [];

/**
* @param Console $app Application Console
Expand Down Expand Up @@ -224,7 +225,11 @@ final public function setArguments(array $arguments = []): self
*/
final public function argument(string $name, mixed $default = null): mixed
{
return $this->_arguments[$name] ?? $default;
if (isset($this->_arguments[$name])) {
return $this->_arguments[$name];
}

return $this->_arguments[Text::camel($name)] ?? $default;
}

/**
Expand All @@ -240,7 +245,11 @@ final public function getArg(string $name, mixed $default = null)
*/
final public function option(string $name, mixed $default = null): mixed
{
return $this->_options[$name] ?? $default;
if (isset($this->_options[$name])) {
return $this->_options[$name];
}

return $this->_options[Text::camel($name)] ?? $default;
}

/**
Expand All @@ -258,7 +267,11 @@ final public function param(string $name, mixed $default = null): mixed
{
$params = array_merge($this->_arguments, $this->_options);

return $params[$name] ?? $default;
if (isset($params[$name])) {
return $params[$name];
}

return $params[Text::camel($name)] ?? $default;
}

/**
Expand Down Expand Up @@ -639,16 +652,8 @@ public function __isset(string $key): bool
*
* @return void
*/
protected function initProps()
private function initProps()
{
if (! is_cli()) {
if (! file_exists($ou = TEMP_PATH . 'blitz-cli.txt')) {
file_put_contents($ou, '', LOCK_EX);
}

$this->app->io(new Interactor($ou, $ou));
}

$this->io = $this->app->io();
$this->writer = $this->io->writer();
$this->reader = $this->io->reader();
Expand Down
4 changes: 3 additions & 1 deletion src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ public function reset(array|string|null $keys = null): void
* Rend disponible un groupe de configuration qui n'existe pas (pas de fichier de configuration)
* Ceci est notament utilse pour definir des configurations à la volée
*/
public function ghost(array|string $key, ?Schema $schema = null): static
public function ghost(array|string $key, array|Schema|null $structure = null): static
{
$schema = is_array($structure) ? Expect::mixed($structure) : $structure;

$this->load($key, null, $schema, true);

return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Container/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public static function toolbar(?stdClass $config = null, bool $shared = true): T
public static function translator(?string $locale = null, bool $shared = true): Translate
{
if (null === $locale || $locale === '' || $locale === '0') {
$locale = static::request()->getLocale();
$locale = is_cli() ? static::config()->get('app.language') : static::request()->getLocale();
}

if (true === $shared && isset(static::$instances[Translate::class])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Debug/Toolbar/Collectors/RoutesCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class RoutesCollector extends BaseCollector

public function __construct()
{
$rawRoutes = single_service('routes');
$this->router = single_service('router', $rawRoutes, null);
$rawRoutes = service('routes');
$this->router = service('router', $rawRoutes, null);
$this->definedRouteCollector = new DefinedRouteCollector($rawRoutes);
$this->isAutoRoute = $rawRoutes->shouldAutoRoute();
}
Expand Down