Skip to content

Commit a594f97

Browse files
authored
chore(php): fix php 8.5 deprecations 33.x (#25714)
* chore(php): prevent PHP 8.5 null array key deprecation * chore(php): fix chr() deprecation in CodedOutputStream.php
1 parent 054fffd commit a594f97

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

php/src/Google/Protobuf/Internal/CodedOutputStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static function writeVarintToArray($value, &$buffer, $trim = false)
9898
}
9999

100100
while (($low >= 0x80 || $low < 0) || $high != 0) {
101-
$buffer[$current] = chr($low | 0x80);
101+
$buffer[$current] = chr(($low | 0x80) & 0xFF);
102102
$value = ($value >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7));
103103
$carry = ($high & 0x7F) << ((PHP_INT_SIZE << 3) - 7);
104104
$high = ($high >> 7) & ~(0x7F << ((PHP_INT_SIZE << 3) - 7));

php/src/Google/Protobuf/Internal/Descriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getFullName()
5454
public function addField($field)
5555
{
5656
$this->field[$field->getNumber()] = $field;
57-
$this->json_to_field[$field->getJsonName()] = $field;
57+
$this->json_to_field[$field->getJsonName() ?? ''] = $field;
5858
$this->name_to_field[$field->getName()] = $field;
5959
$this->index_to_field[] = $field;
6060
}

php/src/Google/Protobuf/Internal/DescriptorPool.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function addDescriptor($descriptor)
7575
$this->unique_descs[$descriptor->getFullName()] =
7676
$descriptor;
7777
$this->class_to_desc[$descriptor->getClass()] = $descriptor;
78-
$this->class_to_desc[$descriptor->getLegacyClass()] = $descriptor;
79-
$this->class_to_desc[$descriptor->getPreviouslyUnreservedClass()] = $descriptor;
78+
$this->class_to_desc[$descriptor->getLegacyClass() ?? ''] = $descriptor;
79+
$this->class_to_desc[$descriptor->getPreviouslyUnreservedClass() ?? ''] = $descriptor;
8080
foreach ($descriptor->getNestedType() as $nested_type) {
8181
$this->addDescriptor($nested_type);
8282
}
@@ -90,7 +90,7 @@ public function addEnumDescriptor($descriptor)
9090
$this->proto_to_class[$descriptor->getFullName()] =
9191
$descriptor->getClass();
9292
$this->class_to_enum_desc[$descriptor->getClass()] = $descriptor;
93-
$this->class_to_enum_desc[$descriptor->getLegacyClass()] = $descriptor;
93+
$this->class_to_enum_desc[$descriptor->getLegacyClass() ?? ''] = $descriptor;
9494
}
9595

9696
public function getDescriptorByClassName($klass)

0 commit comments

Comments
 (0)