2024-05-21 14:56:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2025-08-06 20:43:23 +08:00
|
|
|
use SPC\exception\ValidationException;
|
2024-05-21 14:56:54 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('protobuf')]
|
|
|
|
|
class protobuf extends Extension
|
|
|
|
|
{
|
|
|
|
|
public function validate(): void
|
|
|
|
|
{
|
|
|
|
|
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
2025-08-06 20:43:23 +08:00
|
|
|
throw new ValidationException('The latest protobuf extension requires PHP 8.0 or later');
|
2024-05-21 14:56:54 +08:00
|
|
|
}
|
2025-06-19 15:15:01 +07:00
|
|
|
$grpc = $this->builder->getExt('grpc');
|
2025-03-14 23:39:31 +08:00
|
|
|
// protobuf conflicts with grpc
|
2025-06-19 15:15:01 +07:00
|
|
|
if ($grpc?->isBuildStatic()) {
|
2025-08-06 20:43:23 +08:00
|
|
|
throw new ValidationException('protobuf conflicts with grpc, please remove grpc or protobuf extension');
|
2025-03-14 23:39:31 +08:00
|
|
|
}
|
2024-05-21 14:56:54 +08:00
|
|
|
}
|
|
|
|
|
}
|