Skip to content

Commit 0bc4748

Browse files
committed
Implement second-level metadata (prototypes)
1 parent 16641bc commit 0bc4748

File tree

114 files changed

+1574
-3174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1574
-3174
lines changed

bench/src/Serializers/TypeLangAttributesBench.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use PhpBench\Attributes\Warmup;
1111
use TypeLang\Mapper\Bench\Stub\ExampleRequestDTO;
1212
use TypeLang\Mapper\Mapper;
13-
use TypeLang\Mapper\Mapping\Driver\AttributeDriver;
14-
use TypeLang\Mapper\Mapping\Driver\Psr16CachedDriver;
15-
use TypeLang\Mapper\Mapping\Driver\ReflectionDriver;
13+
use TypeLang\Mapper\Mapping\Provider\AttributeDriver;
14+
use TypeLang\Mapper\Mapping\Provider\Psr16CachedDriver;
15+
use TypeLang\Mapper\Mapping\Provider\ReflectionDriver;
1616
use TypeLang\Mapper\Platform\StandardPlatform;
1717

1818
#[Revs(30), Warmup(3), Iterations(5), BeforeMethods('prepare')]
@@ -31,7 +31,7 @@ public function prepare(): void
3131

3232
$this->cached = new Mapper(
3333
platform: new StandardPlatform(
34-
driver: new Psr16CachedDriver(
34+
meta: new Psr16CachedDriver(
3535
cache: $this->psr16,
3636
delegate: $driver,
3737
),
@@ -40,7 +40,7 @@ public function prepare(): void
4040

4141
$this->raw = new Mapper(
4242
platform: new StandardPlatform(
43-
driver: $driver,
43+
meta: $driver,
4444
),
4545
);
4646
}

bench/src/Serializers/TypeLangDocBlockBench.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use PhpBench\Attributes\Warmup;
1111
use TypeLang\Mapper\Bench\Stub\ExampleRequestDTO;
1212
use TypeLang\Mapper\Mapper;
13-
use TypeLang\Mapper\Mapping\Driver\DocBlockDriver;
14-
use TypeLang\Mapper\Mapping\Driver\Psr16CachedDriver;
15-
use TypeLang\Mapper\Mapping\Driver\ReflectionDriver;
13+
use TypeLang\Mapper\Mapping\Provider\DocBlockDriver;
14+
use TypeLang\Mapper\Mapping\Provider\Psr16CachedDriver;
15+
use TypeLang\Mapper\Mapping\Provider\ReflectionDriver;
1616
use TypeLang\Mapper\Platform\StandardPlatform;
1717

1818
#[Revs(30), Warmup(3), Iterations(5), BeforeMethods('prepare')]
@@ -31,7 +31,7 @@ public function prepare(): void
3131

3232
$this->cached = new Mapper(
3333
platform: new StandardPlatform(
34-
driver: new Psr16CachedDriver(
34+
meta: new Psr16CachedDriver(
3535
cache: $this->psr16,
3636
delegate: $driver,
3737
),
@@ -40,7 +40,7 @@ public function prepare(): void
4040

4141
$this->raw = new Mapper(
4242
platform: new StandardPlatform(
43-
driver: $driver,
43+
meta: $driver,
4444
),
4545
);
4646
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"require": {
1212
"php": "^8.1",
13+
"psr/clock": "^1.0",
1314
"psr/log": "^1.0|^2.0|^3.0",
1415
"psr/simple-cache": "^1.0|^2.0|^3.0",
1516
"type-lang/parser": "^1.4",

example/04.mapping/01.reflection-mapping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818

1919
// Create standard platform with reflection driver
2020
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
21-
driver: new \TypeLang\Mapper\Mapping\Driver\ReflectionDriver(),
21+
meta: new \TypeLang\Mapper\Mapping\Reader\ReflectionReader(),
2222
);
2323

2424
$mapper = new Mapper($platform);

example/04.mapping/02.attribute-mapping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function __construct(
2121
// Which means that we only read those fields that are marked with
2222
// the "MapProperty" attribute.
2323
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
24-
driver: new \TypeLang\Mapper\Mapping\Driver\AttributeDriver(),
24+
meta: new \TypeLang\Mapper\Mapping\Reader\AttributeReader(),
2525
);
2626

2727
$mapper = new Mapper($platform);

example/04.mapping/03.driver-inheritance-mapping.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function __construct(
2222
// Which means that we read all public fields, as well as those marked
2323
// with the MapProperty attribute with overwriting.
2424
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
25-
driver: new \TypeLang\Mapper\Mapping\Driver\AttributeDriver(
26-
delegate: new \TypeLang\Mapper\Mapping\Driver\ReflectionDriver(),
25+
meta: new \TypeLang\Mapper\Mapping\Reader\AttributeReader(
26+
delegate: new \TypeLang\Mapper\Mapping\Reader\ReflectionReader(),
2727
),
2828
);
2929

example/04.mapping/04.phpdoc-mapping.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
require __DIR__ . '/../../vendor/autoload.php';
88

9+
die('TODO: Not implemented yet');
10+
911
class ExampleDTO
1012
{
1113
public function __construct(
@@ -17,9 +19,9 @@ public function __construct(
1719
}
1820

1921
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
20-
driver: new \TypeLang\Mapper\Mapping\Driver\DocBlockDriver(
21-
delegate: new \TypeLang\Mapper\Mapping\Driver\AttributeDriver(
22-
delegate: new \TypeLang\Mapper\Mapping\Driver\ReflectionDriver(),
22+
meta: new \TypeLang\Mapper\Mapping\Provider\DocBlockDriver(
23+
delegate: new \TypeLang\Mapper\Mapping\Provider\AttributeDriver(
24+
delegate: new \TypeLang\Mapper\Mapping\Provider\ReflectionDriver(),
2325
),
2426
),
2527
);

example/04.mapping/05.phpdoc-custom-tags-mapping.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
require __DIR__ . '/../../vendor/autoload.php';
88

9+
die('TODO: Not implemented yet');
10+
911
class ExampleDTO
1012
{
1113
public function __construct(
@@ -18,11 +20,11 @@ public function __construct(
1820
}
1921

2022
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
21-
driver: new \TypeLang\Mapper\Mapping\Driver\DocBlockDriver(
23+
meta: new \TypeLang\Mapper\Mapping\Provider\DocBlockDriver(
2224
paramTagName: 'custom-param', // Override "@param" tag by the "@custom-param"
2325
varTagName: 'custom-var', // Override "@var" tag by the "@custom-var"
24-
delegate: new \TypeLang\Mapper\Mapping\Driver\AttributeDriver(
25-
delegate: new \TypeLang\Mapper\Mapping\Driver\ReflectionDriver(),
26+
delegate: new \TypeLang\Mapper\Mapping\Provider\AttributeDriver(
27+
delegate: new \TypeLang\Mapper\Mapping\Provider\ReflectionDriver(),
2628
),
2729
),
2830
);

example/04.mapping/06.cache.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
require __DIR__ . '/../../vendor/autoload.php';
88

9+
die('TODO: Not implemented yet');
10+
911
class ExampleDTO
1012
{
1113
/**
@@ -24,10 +26,10 @@ public function __construct(
2426
);
2527

2628
$platform = new \TypeLang\Mapper\Platform\StandardPlatform(
27-
driver: new \TypeLang\Mapper\Mapping\Driver\Psr16CachedDriver(
29+
meta: new \TypeLang\Mapper\Mapping\Provider\Psr16CachedDriver(
2830
cache: $cache,
29-
delegate: new \TypeLang\Mapper\Mapping\Driver\DocBlockDriver(
30-
delegate: new \TypeLang\Mapper\Mapping\Driver\AttributeDriver(),
31+
delegate: new \TypeLang\Mapper\Mapping\Provider\DocBlockDriver(
32+
delegate: new \TypeLang\Mapper\Mapping\Provider\AttributeDriver(),
3133
),
3234
),
3335
);

src/Exception/Definition/DefinitionException.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
/**
1212
* Occurs when the type was incorrectly defined.
1313
*/
14-
abstract class DefinitionException extends \InvalidArgumentException implements MapperExceptionInterface
14+
abstract class DefinitionException extends \InvalidArgumentException implements
15+
MapperExceptionInterface
1516
{
1617
public readonly Template $template;
1718

@@ -36,4 +37,16 @@ public function getType(): TypeStatement
3637
{
3738
return $this->type;
3839
}
40+
41+
/**
42+
* @api
43+
*
44+
* @param non-empty-string $file
45+
* @param int<1, max> $line
46+
*/
47+
public function setSource(string $file, int $line): void
48+
{
49+
$this->file = $file;
50+
$this->line = $line;
51+
}
3952
}

0 commit comments

Comments
 (0)