protocolbuffers / protocolbuffers/protobuf
PHP Extension - Constructor cannot convert optional to string
Open
@bshaffer is already working on this.
Since Apr 14, 2026.
bug
php
- Dominant language
- C++
- Stars
- 72k
- Forks
- 16.3k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 140
Description
This is a follow up to https://github.com/protocolbuffers/protobuf/issues/20000
When the constructor is called with null values
new TestMessage([
'optional_bool' => null,
'optional_bytes' => null,
'optional_string' => null,
]);
# Cannot convert '' to string
The added typehints prevent the original issue when using a setter
but it seems to still be an issue for constructor since extension bypassed the php setter :
Not sure what the best approach is here for now I have variation of my original fix here: ee05655
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.