[php-src] PR #20635: [RFC] Type Aliases
| From: | withinboredom | Date: | Tue, 02 Dec 2025 22:09:34 +0000 |
| Subject: | [php-src] PR #20635: [RFC] Type Aliases | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34197@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20635
Author: withinboredom
https://wiki.php.net/rfc/typed-aliases
Known issues:
- including types just includes the file then tosses it away -- could be cached
- Path must be literal string: include types 'types.php' works, but these don't:
include types $path; Variable - won't work
include types __DIR__ . '/types.php'; Expression - won't work
- Opcache interaction: Need to verify include types works correctly with opcache. The types file
itself won't be opcached in the traditional sense.
Todos:
- [ ] Caching mechanism for include types: Store compiled type ASTs to avoid re-parsing
- [ ] Test coverage needed:
- [ ] Namespace scoping (curly brace, multiple unscoped, etc.)
- [ ] Nested include types (types file includes another types file?)
- [ ] Circular include detection
- [ ] Complex DNF types
- [ ] Interaction with class/function/const imports of same name
- [ ] Validate implementation matches RFC scoping: Verify FC(imports_type) is reset at namespace
boundaries like other imports
- [ ] What happens with include types inside a function? (Should error?)
- [ ] Self-referential aliases: use type Foo|int as Foo; (Should error)
- [ ] Alias referencing undefined alias