Skip to content

Commit b887f5f

Browse files
committed
Code chapter 2
Signed-off-by: Howriq <[email protected]>
1 parent fe04d0f commit b887f5f

File tree

7 files changed

+99
-44
lines changed

7 files changed

+99
-44
lines changed

README.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

data/cache/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

mkdocs.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

phpcs.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
<file>test</file>
2020

2121
<!-- Include all rules from the Laminas Coding Standard -->
22-
<rule ref="LaminasCodingStandard" />
22+
<rule ref="LaminasCodingStandard" >
23+
<exclude-pattern>src/Migrations/*</exclude-pattern>
24+
</rule>
2325
</ruleset>

src/App/src/ConfigProvider.php

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,76 @@
66

77
use Doctrine\ORM\EntityManager;
88
use Doctrine\ORM\EntityManagerInterface;
9-
use Doctrine\ORM\Mapping\EntityListenerResolver;
9+
use Doctrine\ORM\Mapping\EntityListenerResolver as EntityListenerResolverInterface;
10+
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
1011
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
1112
use Dot\Cache\Adapter\ArrayAdapter;
1213
use Dot\Cache\Adapter\FilesystemAdapter;
1314
use Light\App\Factory\EntityListenerResolverFactory;
1415
use Light\App\Factory\GetIndexViewHandlerFactory;
1516
use Light\App\Handler\GetIndexViewHandler;
17+
use Light\App\Resolver\EntityListenerResolver;
1618
use Light\App\Types\UuidType;
1719
use Mezzio\Application;
1820
use Roave\PsrContainerDoctrine\EntityManagerFactory;
1921

22+
use Symfony\Component\Cache\Adapter\AdapterInterface;
2023
use function getcwd;
2124

25+
/**
26+
* @phpstan-type ConfigType array{
27+
* dependencies: DependenciesType,
28+
* doctrine: DoctrineConfigType,
29+
* }
30+
* @phpstan-type DoctrineConfigType array{
31+
* cache: array{
32+
* array: array{
33+
* class: class-string<AdapterInterface>,
34+
* },
35+
* filesystem: array{
36+
* class: class-string<AdapterInterface>,
37+
* directory: non-empty-string,
38+
* namespace: non-empty-string,
39+
* },
40+
* },
41+
* configuration: array{
42+
* orm_default: array{
43+
* entity_listener_resolver: class-string<EntityListenerResolverInterface>,
44+
* result_cache: non-empty-string,
45+
* metadata_cache: non-empty-string,
46+
* query_cache: non-empty-string,
47+
* hydration_cache: non-empty-string,
48+
* typed_field_mapper: non-empty-string|null,
49+
* second_level_cache: array{
50+
* enabled: bool,
51+
* default_lifetime: int,
52+
* default_lock_lifetime: int,
53+
* file_lock_region_directory: string,
54+
* regions: string[],
55+
* },
56+
* },
57+
* },
58+
* driver: array{
59+
* orm_default: array{
60+
* class: class-string<MappingDriver>,
61+
* },
62+
* },
63+
* migrations: array{
64+
* migrations_paths: array<non-empty-string, non-empty-string>,
65+
* all_or_nothing: bool,
66+
* check_database_platform: bool,
67+
* },
68+
* types: array<non-empty-string, class-string>,
69+
* }
70+
* @phpstan-type DependenciesType array{
71+
* factories: array<class-string|non-empty-string, class-string|non-empty-string>,
72+
* aliases: array<class-string|non-empty-string, class-string|non-empty-string>,
73+
* }
74+
**/
2275
class ConfigProvider
2376
{
2477
/**
25-
@return array{
26-
* dependencies: array<mixed>,
27-
* templates: array<mixed>,
28-
* }
78+
* @return ConfigType
2979
*/
3080
public function __invoke(): array
3181
{
@@ -37,10 +87,7 @@ public function __invoke(): array
3787
}
3888

3989
/**
40-
* @return array{
41-
* delegators: array<class-string, array<class-string>>,
42-
* factories: array<class-string, class-string>,
43-
* }
90+
* @return DependenciesType
4491
*/
4592
public function getDependencies(): array
4693
{
@@ -84,6 +131,9 @@ public function getTemplates(): array
84131
];
85132
}
86133

134+
/**
135+
* @return DoctrineConfigType
136+
*/
87137
private function getDoctrineConfig(): array
88138
{
89139
return [

src/Book/src/ConfigProvider.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,34 @@
55
namespace Light\Book;
66

77
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
8+
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
89

10+
/**
11+
* @phpstan-type ConfigType array{
12+
* dependencies: DependenciesType,
13+
* doctrine: DoctrineConfigType,
14+
* }
15+
* @phpstan-type DoctrineConfigType array{
16+
* driver: array{
17+
* orm_default: array{
18+
* drivers: array<non-empty-string, non-empty-string>,
19+
* },
20+
* BookEntities: array{
21+
* class: class-string<MappingDriver>,
22+
* cache: non-empty-string,
23+
* paths: non-empty-string[],
24+
* },
25+
* },
26+
* }
27+
* @phpstan-type DependenciesType array{
28+
* factories: array<class-string, class-string>,
29+
* }
30+
*/
931
class ConfigProvider
1032
{
33+
/**
34+
* @return ConfigType
35+
*/
1136
public function __invoke(): array
1237
{
1338
return [
@@ -16,6 +41,9 @@ public function __invoke(): array
1641
];
1742
}
1843

44+
/**
45+
* @return DependenciesType
46+
*/
1947
private function getDependencies(): array
2048
{
2149
return [
@@ -24,6 +52,9 @@ private function getDependencies(): array
2452
];
2553
}
2654

55+
/**
56+
* @return DoctrineConfigType
57+
*/
2758
private function getDoctrineConfig(): array
2859
{
2960
return [

src/Book/src/Entity/Book.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ public function setAuthor(string $author): void
5050
$this->author = $author;
5151
}
5252

53+
/**
54+
* @return array{
55+
* title:string|null,
56+
* author:string|null
57+
* }
58+
*/
5359
public function getArrayCopy(): array
5460
{
5561
return [

0 commit comments

Comments
 (0)