It looks like the PHP APIs are incomplete. It is definitely a bug that `hasOptionalKeyword()` would return this error.
That said, we are guiding users away from `hasOptionalKeyword()`. Note that it is deprecated in C++: https://github.com/protocolbuffers/protobuf/blob/06e232dcd85ab52dc5e45aa1ea8bcd03f9a9a245/src/google/protobuf/descriptor.h#L976-L981 Instead you should be using something more like `has_presence()` in C++. This function is more future-proof because it tests a semantic property of the field (whether it has presence), rather than a syntactic detail: https://github.com/protocolbuffers/protobuf/blob/06e232dcd85ab52dc5e45aa1ea8bcd03f9a9a245/src/google/protobuf/descriptor.h#L808-L815 So I think the real resolution here is to add `hasPresence()` to PHP. Feel free to file a GitHub issue for that. On Friday, May 19, 2023 at 12:13:04 AM UTC-7 [email protected] wrote: > Hi, > > I am trying to use the FieldDescriptor class in my PHP project, and try to > determine which fields of the protobuf message are optional. I'm using the > hasOptionalKeyword function on the Google\Protobuf\FieldDescriptor class > but i'm running into the following error: > > Attempted to call an undefined method named "hasOptionalKeyword" of class > "Google\Protobuf\Internal\FieldDescriptor". > > It seems the hasOptionalKeyword function calls the internal descriptor > with the same hasOptionalKeyword function, but that function is not > implemented in the internal class. > > I'm using package google/protobuf version 3.23 > > Anything I am missing? > > Regards, > > Job > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/1ffe9ca7-243b-4078-bb72-7c70c858f849n%40googlegroups.com.
