Skip to content

Commit 02d8bd0

Browse files
committed
chore: add plugin types
1 parent a513b84 commit 02d8bd0

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Thesis\Protobuf\Compiler;
6+
7+
/**
8+
* @api
9+
*/
10+
enum CodeGeneratorFeature: int
11+
{
12+
case None = 0;
13+
case Proto3Optional = 1;
14+
case SupportEditions = 2;
15+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Thesis\Protobuf\Compiler;
6+
7+
use Thesis\Protobuf\Reflection;
8+
9+
/**
10+
* @api
11+
* @see https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/plugin.proto
12+
*/
13+
final readonly class CodeGeneratorRequest
14+
{
15+
/**
16+
* @param list<string> $filesToGenerate
17+
* @param list<FileDescriptorProto> $protoFiles
18+
* @param list<FileDescriptorProto> $sourceFileDescriptors
19+
*/
20+
public function __construct(
21+
#[Reflection\Field(1, new Reflection\ListT(Reflection\StringT::T))]
22+
public array $filesToGenerate = [],
23+
#[Reflection\Field(2, Reflection\StringT::T)]
24+
public ?string $parameter = null,
25+
#[Reflection\Field(15, new Reflection\ListT(
26+
new Reflection\ObjectT(FileDescriptorProto::class),
27+
))]
28+
public array $protoFiles = [],
29+
#[Reflection\Field(17, new Reflection\ListT(
30+
new Reflection\ObjectT(FileDescriptorProto::class),
31+
))]
32+
public array $sourceFileDescriptors = [],
33+
#[Reflection\Field(3, new Reflection\ObjectT(CompilerVersion::class))]
34+
public ?CompilerVersion $compilerVersion = null,
35+
) {}
36+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Thesis\Protobuf\Compiler;
6+
7+
use Thesis\Protobuf\Reflection;
8+
9+
/**
10+
* @api
11+
* @see https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/compiler/plugin.proto
12+
*/
13+
final readonly class CodeGeneratorResponse
14+
{
15+
/**
16+
* @param list<GeneratedFile> $files
17+
*/
18+
public function __construct(
19+
#[Reflection\Field(1, Reflection\StringT::T)]
20+
public ?string $error = null,
21+
#[Reflection\Field(2, Reflection\Uint64T::T)]
22+
public ?int $supportFeatures = null,
23+
#[Reflection\Field(3, Reflection\Int32T::T)]
24+
public ?int $minimumEdition = null,
25+
#[Reflection\Field(4, Reflection\Int32T::T)]
26+
public ?int $maximumEdition = null,
27+
#[Reflection\Field(15, new Reflection\ListT(
28+
new Reflection\ObjectT(GeneratedFile::class),
29+
))]
30+
public array $files = [],
31+
) {}
32+
}

src/Compiler/CompilerVersion.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Thesis\Protobuf\Compiler;
6+
7+
use Thesis\Protobuf\Reflection;
8+
9+
/**
10+
* @api
11+
*/
12+
final readonly class CompilerVersion
13+
{
14+
public function __construct(
15+
#[Reflection\Field(1, Reflection\Int32T::T)]
16+
public ?int $major = null,
17+
#[Reflection\Field(2, Reflection\Int32T::T)]
18+
public ?int $minor = null,
19+
#[Reflection\Field(3, Reflection\Int32T::T)]
20+
public ?int $patch = null,
21+
#[Reflection\Field(4, Reflection\StringT::T)]
22+
public ?string $suffix = null,
23+
) {}
24+
}

src/Compiler/FileDescriptorSet.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/**
1010
* @api
11+
* @see https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto
1112
*/
1213
final readonly class FileDescriptorSet
1314
{

src/Compiler/GeneratedFile.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Thesis\Protobuf\Compiler;
6+
7+
use Thesis\Protobuf\Reflection;
8+
9+
/**
10+
* @api
11+
*/
12+
final readonly class GeneratedFile
13+
{
14+
public function __construct(
15+
#[Reflection\Field(1, Reflection\StringT::T)]
16+
public ?string $name = null,
17+
#[Reflection\Field(2, Reflection\StringT::T)]
18+
public ?string $insertionPoint = null,
19+
#[Reflection\Field(15, Reflection\StringT::T)]
20+
public ?string $content = null,
21+
#[Reflection\Field(16, new Reflection\ObjectT(GeneratedCodeInfo::class))]
22+
public ?GeneratedCodeInfo $generatedCodeInfo = null,
23+
) {}
24+
}

0 commit comments

Comments
 (0)