{"id":15952366,"url":"https://github.com/jordanrl/never-argument-type","last_synced_at":"2026-01-19T12:33:46.692Z","repository":{"id":73491341,"uuid":"395813233","full_name":"JordanRL/never-argument-type","owner":"JordanRL","description":null,"archived":false,"fork":false,"pushed_at":"2021-08-15T11:16:13.000Z","size":38,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T01:27:38.021Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JordanRL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-13T22:20:20.000Z","updated_at":"2021-08-19T17:07:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"f106483b-f6cc-4a83-97f2-9a0a5700b9a2","html_url":"https://github.com/JordanRL/never-argument-type","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JordanRL/never-argument-type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2Fnever-argument-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2Fnever-argument-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2Fnever-argument-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2Fnever-argument-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JordanRL","download_url":"https://codeload.github.com/JordanRL/never-argument-type/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JordanRL%2Fnever-argument-type/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28567900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T13:08:22.402Z","updated_at":"2026-01-19T12:33:46.671Z","avatar_url":"https://github.com/JordanRL.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP RFC: Never For Parameter Types\n\n\n**THIS DOCUMENT HAS BEEN RETIRED. SEE THE FULL RFC: https://wiki.php.net/rfc/never_for_parameter_types**\n\n\n## Introduction\n\nArguments in PHP are [contravariant](https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)) to preserve Liskov substitution. This means that if class B extends class A, then redefines a function call, the entire type of that argument from class A must be present in the type of the argument in class B:\n\n```php\n\u003c?php\n\nabstract class A {\n\n  abstract public function foo(int $arg);\n\n}\n\nclass B extends A {\n  \n  public function foo(int|float $arg) {\n    return round($arg) + 1;\n  }\n  \n}\n```\n\nThus, the more specific a type is for an argument in a base class, the more broad it can be in an extending class with the requirement that it must also include the type from the base class.\n\nSince `never` is a [bottom type](https://en.wikipedia.org/wiki/Bottom_type) within the PHP engine, all other types contain it. This RFC proposes allowing `never` as a valid argument type for methods on interfaces and abstract functions.\n\n## Use Cases\n\n### Interfaces and Abstracts\n\nWith the `never` type available, interfaces and abstracts would be able to require that implementing classes provide a type without specifying any details about what that type must be. This would allow use cases such as the following:\n\n```php\n\u003c?php\n\ninterface CollectionInterface {\n\n  public function add(never $input): self;\n\n}\n```\n\nImplementers of the `CollectionInterface` could then specify any type they want, but failing to specify a type would result in a Fatal Error. Functions which use collections could then type against the interface, allowing any of the variously typed implementations to be provided.\n\nIn this way, allowing the `never` type for interfaces and abstracts could be a method of providing minimal support for generics while avoiding the challenges that providing generics represents. It would also not prevent or make it more difficult to provide full generics in the future.\n\n### Internal Classes and Interfaces\n\nProviding internal interfaces that require a type but do not specify which type can be very beneficial. In fact, the motivation for exploring this concept originated in researching operator overloads and the interfaces that such a feature would provide.\n\n## Design Considerations\n\n### Using Never vs. A New Type\n\nWhile it could be argued that the meaning of `never` was that code using this type would terminate, a new type offers several issues over using `never`:\n\n- `never` already represents the concept of a bottom type in PHP due to its usage with return types. The engine already has the concept of this type built in, but is not currently exposing it for use with arguments. Having multiple bottom types not only doesn't make sense, but I cannot find a single instance of any programming language having multiple bottom types.\n- `never` correctly indicates that the code which uses it for an argument type can never be called directly.\n- This usage has precedence in other languages; see below.\n\n### Other Languages\n\nThere are several languages which contain a bottom type, some of which use `never` as their bottom type. The behavior described in this RFC is in fact how `never` behaves and can be used [in TypeScript](https://blog.logrocket.com/when-to-use-never-and-unknown-in-typescript-5e4d6c5799ad/), which also uses `never` as its bottom type.\n\nScala also uses the bottom type to denote covariant parameter polymorphism, though the bottom type in Scala is `Nothing`.\n\n## Proposal\n\nAllow the use of `never` as a type for arguments in interfaces and classes. This would have the following semantics:\n\n- `never` cannot be used in an intersection type or union type. Any intersection would reduce to `never`, and any union would reduce `never` out of the union, as `never` is the identity type of unions.\n- Attempting to call code directly that uses the `never` type for an argument would result in a `TypeError`, as no zval will match this type.\n\nThis means that an interface or class could allow implementers and subclasses to declare a type for an argument without restricting that type to anything particular.\n\n## Backward Incompatible Changes\n\nNone\n\n## Proposed PHP Version\n\nThis change is proposed for PHP 8.2\n\n## RFC Impact\n\n### To SAPIs\n\nNone\n\n### To Existing Extensions\n\nNone\n\n### To Opcache\n\nNone\n\n### New Constants\n\nNone\n\n### php.ini Defaults\n\nNone\n\n## Proposed Voting Choices\n\nAllow `never` as a parameter type: yes/no. A 2/3 vote is required to pass. \n\n## Vote\n\n## Patches and Tests\n\nhttps://github.com/php/php-src/pull/7373\n\n## References\n\n- https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)\n- https://en.wikipedia.org/wiki/Bottom_type\n- https://blog.logrocket.com/when-to-use-never-and-unknown-in-typescript-5e4d6c5799ad/\n\n## Changelog\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanrl%2Fnever-argument-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjordanrl%2Fnever-argument-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjordanrl%2Fnever-argument-type/lists"}