rfc:internal_function_return_types

PHP RFC: Support 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.

See: https://github.com/php/php-src/pull/1050/files#diff-3ea93da7d1026a9f53948a5d14b1f7bdR247

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

  1. the version(s) it was merged to
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature

References

Rejected Features

None

rfc/internal_function_return_types.txt · Last modified: 2017/09/22 13:28 (external edit)