|
24 | 24 | * This file can be removed once a fix is implemented in the protobuf library |
25 | 25 | * @see https://github.com/protocolbuffers/protobuf/issues/11649 |
26 | 26 | */ |
27 | | -namespace GPBMetadata\Google\Protobuf; |
| 27 | +namespace GPBMetadata\Google\Protobuf { |
28 | 28 |
|
29 | | -class DescriptorFix |
30 | | -{ |
31 | | - public static $is_initialized = false; |
| 29 | + class DescriptorFix |
| 30 | + { |
| 31 | + public static $is_initialized = false; |
32 | 32 |
|
33 | | - public static function initOnce() { |
34 | | - $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); |
| 33 | + public static function initOnce() { |
| 34 | + $pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool(); |
35 | 35 |
|
36 | | - if (static::$is_initialized == true) { |
37 | | - return; |
38 | | - } |
| 36 | + if (static::$is_initialized == true) { |
| 37 | + return; |
| 38 | + } |
39 | 39 |
|
40 | | - if ($pool instanceof \Google\Protobuf\Internal\DescriptorPool) { |
41 | | - // add a no-op reference for "google.protobuf.DescriptorProto" |
42 | | - $pool->addMessage('google.protobuf.DescriptorProto', \Google\Protobuf\Internal\Message::class)->finalizeToPool(); |
| 40 | + if ($pool instanceof \Google\Protobuf\Internal\DescriptorPool) { |
| 41 | + // add a no-op reference for "google.protobuf.DescriptorProto" |
| 42 | + $pool->addMessage('google.protobuf.DescriptorProto', \Google\Protobuf\DescriptorProto::class)->finalizeToPool(); |
| 43 | + } |
| 44 | + static::$is_initialized = true; |
43 | 45 | } |
44 | | - static::$is_initialized = true; |
45 | 46 | } |
| 47 | + |
| 48 | + DescriptorFix::initOnce(); |
46 | 49 | } |
47 | 50 |
|
48 | | -DescriptorFix::initOnce(); |
| 51 | +namespace Google\Protobuf { |
| 52 | + |
| 53 | + class DescriptorProto |
| 54 | + { |
| 55 | + public function __construct() |
| 56 | + { |
| 57 | + throw new \LogicException('Proto2 classes are not supported'); |
| 58 | + } |
| 59 | + } |
| 60 | +} |
49 | 61 |
|
0 commit comments