kphp
kphp copied to clipboard
Do not remove empty default values for string and array respectively
Before this PR empty values are eliminated for string and arrays, so
class User {
public string $name = '';
public string $password = '';
}
and
class User {
public string $name;
public string $password;
}
are treated as same.
While it is true technically, this lead to unwanted consequences. Value absence marks such fields as required during JSON deserialization. Removed default value changes class semantics and has strong implication of string having default value of ''.
Suggested changes are about storing fact user provided value was optimized and eliminated. But the fact it was there is used by later steps to correctly process values.