Greetings to you all, I will like to submit an RFC on introducing type alias to php.
Even though Generics won't or never be introduced to PHP, personally i will like php to add the type alias feature. Type aliases provide a mechanism to create more descriptive and readable type hints in PHP code. This enhancement will improve code readability and maintainability and also to promote type reusability. Motivation: The motivation behind introducing type aliases is to: 1. Enhance code readability by allowing developers to use meaningful type hint names. 2. Improve code maintainability by reducing the likelihood of type hint updates throughout the codebase. 3. Encourage the adoption of best practices for type hinting. Proposal: Syntax: Type aliases will be declared using the `type` or `typealias` keyword, followed by the alias name, an equal sign (`=`), and the type it is aliased to. Sample: ``` type MyType = string; // or typealias MyType = string; // Advance type MyType = string|null; // or type MyType = [string, null]; ``` Usage: Type aliases can be used in parameter and return type hints as follows: ``` function greetings(MyType $message): string { // Implementation } greetings(1); // TypeError ``` Since this is just a basic feature, Type aliases Inheritance (compound type) may not be added, since we are not digging deeper into generics :). References: https://docs.python.org/3/glossary.html#term-type-alias https://doc.rust-lang.org/beta/reference/items/type-aliases.html https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes-func.html#type-aliases So, What do you think?