[php-src] PR #21941: Add experimental list<T> type declarations
| From: | tony1877 | Date: | Sun, 03 May 2026 14:31:44 +0000 |
| Subject: | [php-src] PR #21941: Add experimental list<T> type declarations | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35998@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21941
Author: tony1877
This adds an experimental list<T> type declaration prototype.
Implemented:
- parser support for list<T>
- runtime validation for parameters, return types, and properties
- list-shape validation using zend_array_is_list()
- element type validation
- nullable ?list<T>
- Reflection string rendering as list<T>
- return covariance with array
- parameter contravariance with array
- explicit rejection of list<T> inside union types for now
Tests run:
- sapi/cli/php run-tests.php Zend/tests/type_declarations/list_type_*.phpt
- 14 passed, 0 failed
- sapi/cli/php run-tests.php Zend/tests/type_declarations
- 503 passed, 7 skipped, 0 failed
- sapi/cli/php run-tests.php ext/reflection
- 505 passed, 13 skipped, 0 failed
- sapi/cli/php run-tests.php Zend/tests/type_declarations/typed_properties_*.phpt
- 119 passed, 1 skipped, 0 failed
- sapi/cli/php run-tests.php Zend/tests/type_declarations/variance
Zend/tests/type_declarations/union_types/variance
Zend/tests/type_declarations/intersection_types/variance
- 78 passed, 0 failed
Notes:
- This is a prototype and intentionally keeps union support out of scope because the existing union
type machinery assumes complex list payloads are union/intersection/class-name shaped.