> On Wed, Apr 22, 2020 at 11:10 PM Barney Laurance <bar...@redmagic.org.uk> wrote ...
I don't seem to have this message, and can't find it in any archives; was it sent off-list by mistake? On Thu, 23 Apr 2020 at 10:26, Guilliam Xavier <guilliam.xav...@gmail.com> wrote: > Indeed, < > https://www.php.net/manual/en/language.pseudo-types.php#language.types.mixed > > > currently says that, in the PHP documentation, "`mixed` indicates that > a parameter may accept multiple (but not necessarily all) types", and > gives two examples: > <https://www.php.net/manual/en/function.gettype.php> is accurate, but > <https://www.php.net/manual/en/function.str-replace.php> IMO should > just use `string|array` rather than `mixed` (that's already the case > in < > https://github.com/php/php-src/blob/master/ext/standard/basic_functions.stub.php#L649-L655 > >). > Don't forget how recent support for union types in PHP itself is; while the manual could have come up with a richer notation, the invention of "mixed" is itself simply a convenience to fit the DocBook template. A change to that convention would need to be discussed with the editors of the manual (including nuances like "string|bool" vs "string|false", and edge cases where null is a rare error return), so calling any use of mixed right now "wrong" is overstating the case. It turns out DocBook itself didn't actually have a notation for union types until Richard Quadling asked for it for future use in the PHP manual; it's been accepted but would require tooling updates to actually make use of. See https://news-web.php.net/php.doc/969386777 and https://github.com/docbook/docbook/issues/91 All of which is to say, I wouldn't use the conventions used in the manual as any kind of guide to type system design. The best we can say is that there's existing usage of "mixed" in the PHP manual and in docblocks understood by many tools, so to avoid confusion, the new pseudo-type should either behave roughly in line with that usage, or have a new name Regards, -- Rowan Tommins [IMSoP]