[PHP-NOTES] note 130671 added to language.types.never

[email protected] ("[email protected]") Sun, 01 Mar 2026 04:10:18 +0000
Newsgroups php.notes
Message-ID <[email protected]>
Never cannot be used in a union type because, being the bottom type, it is already automatically a subtype of every other type. "A|never" is equivalent to "A".

When one type is "obviously" a subtype of another (i.e., it doesn't require loading the class definitions of all the types involved), the former is redundant in union types, and PHP flags the union of both as an error.

Similarly for intersection types, where "A&never" means the same thing as "never". It "obviously" doesn't make sense to mention A there, so PHP won't allow doing so.
----
Server IP: 206.189.2.9
Probable Submitter: 122.57.27.239
----
Manual Page -- https://php.net/manual/en/language.types.never.php
Edit        -- https://main.php.net/note/edit/130671
Del: integrated  -- https://main.php.net/note/delete/130671/integrated
Del: useless     -- https://main.php.net/note/delete/130671/useless
Del: bad code    -- https://main.php.net/note/delete/130671/bad+code
Del: spam        -- https://main.php.net/note/delete/130671/spam
Del: non-english -- https://main.php.net/note/delete/130671/non-english
Del: in docs     -- https://main.php.net/note/delete/130671/in+docs
Del: other reasons-- https://main.php.net/note/delete/130671
Reject      -- https://main.php.net/note/reject/130671
Search      -- https://main.php.net/manage/user-notes.php