doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Fix Throwable note to mention that Error can be extended (fixes #1647).

Open AndrolGenhald opened this issue 3 years ago • 2 comments

AndrolGenhald avatar Jun 23 '22 19:06 AndrolGenhald

But see https://github.com/php/doc-en/issues/1647#issuecomment-1165439900 f. I'm really unsure whether userland code should extend Error.

cmb69 avatar Jul 02 '22 11:07 cmb69

It might be a good idea to add a note that says although it is possible to extend Error this is in general a bad idea as those should only refer to programming/engine errors.

Girgias avatar Sep 13 '22 09:09 Girgias

@AndrolGenhald gentle nudge for author to address reviewer comments.

afilina avatar Jan 18 '23 16:01 afilina

How sure are you that userland code shouldn't extend Error? It doesn't seem that common, but some popular projects are doing it: https://grep.app/search?q=extends%20%5CError&words=true&filter[lang][0]=PHP (a lot of that is stubs and polyfills, but about half of them seem to be actual userland extensions of Error).

If Error really shouldn't be extended I'll add a note to the Error documentation as well, as I mentioned here I didn't think the documentation was clear on that. In retrospect, allowing Error to be extended in userland makes sense for polyfills, but it should be more clear that it's not intended for general use.

AndrolGenhald avatar Jan 20 '23 01:01 AndrolGenhald