sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

Improve PHP files generated from proto

Open roxblnfk opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

There are a lot of Psalm issues related with usage of PHP files generated from proto (messages). For example:

$details = $info->hasDetails()
    // psalm: PossiblyNullArgument: Argument 1 of EncodedValues::fromPayloads cannot be null, possibly null value provided
    ? EncodedValues::fromPayloads($info->getDetails(), $converter)
    : EncodedValues::empty();

Describe the solution you'd like

That case will be fixed if we add additional annotations in generated files fike this:

/**
 * ...
 * @psalm-mutation-free
 */
public function getDetails() { ... }

/**
 * @psalm-assert-if-true !null $this->getDetails()
 * @psalm-mutation-free
 */
public function hasDetails() { ... }

roxblnfk avatar Jul 04 '23 14:07 roxblnfk