diff --git a/composer.json b/composer.json index bf3d6f2..ca9f12e 100644 --- a/composer.json +++ b/composer.json @@ -27,16 +27,16 @@ }, "require": { "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "dotkernel/dot-cache": "^4.0", + "ramsey/uuid": "^4.5.0", + "ramsey/uuid-doctrine": "^2.1.0", + "roave/psr-container-doctrine": "^5.2.2 || ^6.0.0", "dotkernel/dot-errorhandler": "^4.4.0", "laminas/laminas-component-installer": "^3.5.0", "laminas/laminas-config-aggregator": "^1.17.0", "mezzio/mezzio": "^3.24.0", "mezzio/mezzio-fastroute": "^3.13.0", - "mezzio/mezzio-twigrenderer": "^2.17.0", - "dotkernel/dot-cache": "^4.0", - "ramsey/uuid": "^4.5.0", - "ramsey/uuid-doctrine": "^2.1.0", - "roave/psr-container-doctrine": "^5.2.2" + "mezzio/mezzio-twigrenderer": "^2.17.0" }, "require-dev": { "filp/whoops": "^2.17.0", @@ -47,8 +47,7 @@ "phpunit/phpunit": "^10.5.45", "roave/security-advisories": "dev-master", "symfony/var-dumper": "^7.2.3", - "vincentlanglet/twig-cs-fixer": "^3.5.1", - "phpstan/phpstan-doctrine": "^2.0.3" + "vincentlanglet/twig-cs-fixer": "^3.5.1" }, "autoload": { "psr-4": { diff --git a/config/autoload/local.php b/config/autoload/local.php index 14cdc54..a58f3f8 100644 --- a/config/autoload/local.php +++ b/config/autoload/local.php @@ -26,7 +26,7 @@ ]; return [ - 'databases' => $databases, + 'databases' => $databases, 'doctrine' => [ 'connection' => [ 'orm_default' => [ diff --git a/src/App/src/ConfigProvider.php b/src/App/src/ConfigProvider.php index 7d0fdaf..212099d 100644 --- a/src/App/src/ConfigProvider.php +++ b/src/App/src/ConfigProvider.php @@ -6,24 +6,78 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\EntityListenerResolver as EntityListenerResolverInterface; +use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Dot\Cache\Adapter\ArrayAdapter; use Dot\Cache\Adapter\FilesystemAdapter; use Light\App\Factory\GetIndexViewHandlerFactory; use Light\App\Handler\GetIndexViewHandler; use Mezzio\Application; -use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType; -use Ramsey\Uuid\Doctrine\UuidBinaryType; use Ramsey\Uuid\Doctrine\UuidType; use Roave\PsrContainerDoctrine\EntityManagerFactory; +use Symfony\Component\Cache\Adapter\AdapterInterface; use function getcwd; +/** + * @phpstan-type ConfigType array{ + * dependencies: DependenciesType, + * doctrine: DoctrineConfigType, + * resultCacheLifetime: int, + * } + * @phpstan-type DoctrineConfigType array{ + * cache: array{ + * array: array{ + * class: class-string, + * }, + * filesystem: array{ + * class: class-string, + * directory: non-empty-string, + * namespace: non-empty-string, + * }, + * }, + * configuration: array{ + * orm_default: array{ + * entity_listener_resolver: class-string, + * result_cache: non-empty-string, + * metadata_cache: non-empty-string, + * query_cache: non-empty-string, + * hydration_cache: non-empty-string, + * typed_field_mapper: non-empty-string|null, + * second_level_cache: array{ + * enabled: bool, + * default_lifetime: int, + * default_lock_lifetime: int, + * file_lock_region_directory: string, + * regions: string[], + * }, + * }, + * }, + * driver: array{ + * orm_default: array{ + * class: class-string, + * }, + * }, + * migrations: array{ + * migrations_paths: array, + * all_or_nothing: bool, + * check_database_platform: bool, + * }, + * types: array, + * } + * @phpstan-type DependenciesType array{ + * factories: array, + * aliases: array, + * } + */ + class ConfigProvider { /** @return array{ * dependencies: array, + * doctrine: array, * templates: array, * } */ @@ -37,10 +91,7 @@ public function __invoke(): array } /** - * @return array{ - * delegators: array>, - * factories: array, - * } + * @return DependenciesType */ public function getDependencies(): array { @@ -83,6 +134,9 @@ public function getTemplates(): array ]; } + /** + * @return DoctrineConfigType + */ private function getDoctrineConfig(): array { return [ @@ -98,12 +152,13 @@ private function getDoctrineConfig(): array ], 'configuration' => [ 'orm_default' => [ - 'result_cache' => 'filesystem', - 'metadata_cache' => 'filesystem', - 'query_cache' => 'filesystem', - 'hydration_cache' => 'array', - 'typed_field_mapper' => null, - 'second_level_cache' => [ + 'entity_listener_resolver' => EntityListenerResolverInterface::class, + 'result_cache' => 'filesystem', + 'metadata_cache' => 'filesystem', + 'query_cache' => 'filesystem', + 'hydration_cache' => 'array', + 'typed_field_mapper' => null, + 'second_level_cache' => [ 'enabled' => true, 'default_lifetime' => 3600, 'default_lock_lifetime' => 60,