Vladislav Kaverin

Results 15 comments of Vladislav Kaverin

Will be partially implemented in PHP 8's `match` operator (#303), but it doesn't cover cases with exhaustion over class constants.

Is it possible to add here some kind of annotation to force exhaustion check at compile time instead of runtime `warning` to cover #428?

I strongly disagree about this change. Two independent calls of the constructor MUST return two independent instances, but suggested feature just breaks this rule and affects runtime. In fact, this...

> Could you give an example of breaking cases, please? I missed the fact that `@kphp-pure-function` is currently supported only for built-in functions, so you're right, current behaviour won't change....

Do you mean it's gonna be kind of workaround while there's no real `enum`, like for PHP

But why? The fact that a class instance cannot be `mixed` was a fundamental statement for KPHP for years, why break this rule now?

`to_array_debug` and `json_encode` have no connection between ones. As the name says, `to_array_debug` is for debug purposes only. Check [`JsonEncoder` and `visibility_policy`](https://vkcom.github.io/kphp/kphp-language/howto-by-kphp/json-encode-decode.html#skip-all-private-fields-kphp-json-visibility_policypublic).

The only *correct* way is still `JsonEncoder`. It has a lot of customizations. You can make your own class that [`extends JsonEncoder` and override `visibility_policy`](https://vkcom.github.io/kphp/kphp-language/howto-by-kphp/json-encode-decode.html#encoders-inheritors-of-jsonencoder), so you don't need to...

1) Private constructor doesn't stop you from extending `JsonEncoder`, since you don't need to instantiate it. 2) You don't need to use overridden constants manually, all you need is just...

Maybe it's worth to rename (or alias) the annotation into `type-string` to avoid confusing with by `class`?