spiral / framework

High-Performance PHP Framework
https://spiral.dev
MIT License
1.82k stars 89 forks source link

'array' as alias for ArrayStorage in default installation for cache config do not work #1161

Open shanginn opened 1 month ago

shanginn commented 1 month ago

Description

On the fresh spiral framework install in the config/cache.php local driver for cache is defined as

'local' => [
    // Alias for ArrayStorage type
    'type' => 'array',
],

But the alias itself is missing or not working properly, because when running default tests the error is thrown:

[Spiral\Core\Exception\Container\NotFoundException]
Can't resolve `Spiral\Scheduler\JobsLocatorInterface`: undefined class or binding `array`.
Container trace list:
- action: 'resolve from binding'
  alias: 'Spiral\Scheduler\JobsLocatorInterface'
  scope: 'root'
  context: Parameter #0 [ <required> Spiral\Scheduler\JobsLocatorInterface $locator ]
  binding: Alias to `Spiral\Scheduler\JobsLocator`
  - action: 'resolve from binding'
    alias: 'Spiral\Scheduler\JobsLocator'
    scope: 'root'
    context: Parameter #0 [ <required> Spiral\Scheduler\JobsLocatorInterface $locator ]
    binding: Deferred factory 'Spiral\Scheduler\Bootloader\SchedulerBootloader'->initJobsLocator()
    - action: 'resolve from binding'
      alias: 'Spiral\Scheduler\Mutex\JobMutexInterface'
      scope: 'root'
      context: Parameter #1 [ <required> Spiral\Scheduler\Mutex\JobMutexInterface $mutex ]
      binding: Deferred factory 'Spiral\Scheduler\Bootloader\SchedulerBootloader'->initEventMutex()
      - action: 'autowire'
        alias: 'array'
        context: null
in vendor/spiral/framework/src/Core/src/Internal/Factory.php:359

The fix that worked for me is just to replace it with the class itself:

'local' => [
    'type' => ArrayStorage::class,
],

How To Reproduce

Repo with the problem present. Just run phpunit and you will get the error

Install log and phpunit run with error

Additional Info

Q A
Framework Version 3.14.5
PHP version 8.3.10
Operating system MacOS