This is an old revision of the document!
PHP RFC: Support Internal function Return Types
- Version: 0.1
- Date: 2015-02-04
- Author: Reeze Xia, reeze@php.net
- Status: Under Discussion
- First Published at: http://wiki.php.net/rfc/internal_function_return_types
Introduction
Since PHP 7 now have return types in user-land, but internal functions didn't support it. This RFC propose support internal function return types to make it consist.
Proposal
Support declare internal function/method return types, this could help make internal functions API testable, this could also makes extension-implemented frameworks/libraries control their return types.
Backward Incompatible Changes
No BC break;
Proposed PHP Version(s)
PHP 7
RFC Impact
To SAPIs
No
To Existing Extensions
No
To Opcache
No
New Constants
New Macro to support declare return types of functions/methods:
- ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO()
- ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX()
php.ini Defaults
None
Open Issues
1. Should we raise E_CORE_ERROR when error detected, should we just ignore it with a warning? 2. Return Types RFC internally support Nullable Types, but user land not, this RFC also support that,
Should support it?
Unaffected PHP Functionality
User-land return types not affected
Future Scope
None
Proposed Voting Choices
This is not a BC break RFC, 50%+1 majority (see voting)
Patches and Tests
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged to
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
References
Rejected Features
None