From 3c7f7e18ed584afd4aaaec4b47a8274caaa6225a Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Fri, 30 May 2025 09:08:56 +0200 Subject: [PATCH 1/3] add more type tags --- src/Attributes/Binary.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/Fixed32.php | 30 ++++++++++++++++++++++++++++++ src/Attributes/Fixed64.php | 30 ++++++++++++++++++++++++++++++ src/Attributes/Float32.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/Float64.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/Int32.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/Int64.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/SFixed32.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/SFixed64.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/SInt32.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/SInt64.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/UInt32.php | 31 +++++++++++++++++++++++++++++++ src/Attributes/UInt64.php | 30 ++++++++++++++++++++++++++++++ 13 files changed, 400 insertions(+) create mode 100644 src/Attributes/Binary.php create mode 100644 src/Attributes/Fixed32.php create mode 100644 src/Attributes/Fixed64.php create mode 100644 src/Attributes/Float32.php create mode 100644 src/Attributes/Float64.php create mode 100644 src/Attributes/Int32.php create mode 100644 src/Attributes/Int64.php create mode 100644 src/Attributes/SFixed32.php create mode 100644 src/Attributes/SFixed64.php create mode 100644 src/Attributes/SInt32.php create mode 100644 src/Attributes/SInt64.php create mode 100644 src/Attributes/UInt32.php create mode 100644 src/Attributes/UInt64.php diff --git a/src/Attributes/Binary.php b/src/Attributes/Binary.php new file mode 100644 index 0000000..81b5cf4 --- /dev/null +++ b/src/Attributes/Binary.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'string'; + } + + public function validate(mixed $value): bool + { + return true; + } +} diff --git a/src/Attributes/Fixed32.php b/src/Attributes/Fixed32.php new file mode 100644 index 0000000..18069e7 --- /dev/null +++ b/src/Attributes/Fixed32.php @@ -0,0 +1,30 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'string' || $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/Fixed64.php b/src/Attributes/Fixed64.php new file mode 100644 index 0000000..1676916 --- /dev/null +++ b/src/Attributes/Fixed64.php @@ -0,0 +1,30 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'string' || $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/Float32.php b/src/Attributes/Float32.php new file mode 100644 index 0000000..99ac5e0 --- /dev/null +++ b/src/Attributes/Float32.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'float'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/Float64.php b/src/Attributes/Float64.php new file mode 100644 index 0000000..e2e4900 --- /dev/null +++ b/src/Attributes/Float64.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'float' || $type === 'string'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/Int32.php b/src/Attributes/Int32.php new file mode 100644 index 0000000..b4eed93 --- /dev/null +++ b/src/Attributes/Int32.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/Int64.php b/src/Attributes/Int64.php new file mode 100644 index 0000000..ea9de7d --- /dev/null +++ b/src/Attributes/Int64.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'string' || $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/SFixed32.php b/src/Attributes/SFixed32.php new file mode 100644 index 0000000..07c0e15 --- /dev/null +++ b/src/Attributes/SFixed32.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/SFixed64.php b/src/Attributes/SFixed64.php new file mode 100644 index 0000000..5569584 --- /dev/null +++ b/src/Attributes/SFixed64.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/SInt32.php b/src/Attributes/SInt32.php new file mode 100644 index 0000000..29dc70b --- /dev/null +++ b/src/Attributes/SInt32.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/SInt64.php b/src/Attributes/SInt64.php new file mode 100644 index 0000000..f7040a6 --- /dev/null +++ b/src/Attributes/SInt64.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/UInt32.php b/src/Attributes/UInt32.php new file mode 100644 index 0000000..905f6e3 --- /dev/null +++ b/src/Attributes/UInt32.php @@ -0,0 +1,31 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function scopes(): array + { + return $this->scopes; + } + + public function acceptsType(string $type): bool + { + return $type === 'int' || $type === 'string'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } +} diff --git a/src/Attributes/UInt64.php b/src/Attributes/UInt64.php new file mode 100644 index 0000000..badc40c --- /dev/null +++ b/src/Attributes/UInt64.php @@ -0,0 +1,30 @@ + $scopes + */ + public function __construct(protected readonly array $scopes = [null]) {} + + public function acceptsType(string $type): bool + { + return $type === 'string' || $type === 'int'; + } + + public function validate(mixed $value): bool + { + return is_numeric($value); + } + + public function scopes(): array + { + return $this->scopes; + } +} From 513a8e2b76006ac19544ef658e08966f4912c319 Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Fri, 30 May 2025 09:18:09 +0200 Subject: [PATCH 2/3] sfixed64 can also be string --- src/Attributes/SFixed64.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Attributes/SFixed64.php b/src/Attributes/SFixed64.php index 5569584..d4774bb 100644 --- a/src/Attributes/SFixed64.php +++ b/src/Attributes/SFixed64.php @@ -21,7 +21,7 @@ public function scopes(): array public function acceptsType(string $type): bool { - return $type === 'int'; + return $type === 'int' || $type === 'string'; } public function validate(mixed $value): bool From b3ab15ae3d4c4c9b99b352308c4c7d013ac862e8 Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Fri, 30 May 2025 09:28:06 +0200 Subject: [PATCH 3/3] sint64 can also be a string --- src/Attributes/SInt64.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Attributes/SInt64.php b/src/Attributes/SInt64.php index f7040a6..fc76abd 100644 --- a/src/Attributes/SInt64.php +++ b/src/Attributes/SInt64.php @@ -21,7 +21,7 @@ public function scopes(): array public function acceptsType(string $type): bool { - return $type === 'int'; + return $type === 'int' || $type === 'string'; } public function validate(mixed $value): bool