rfc:returntypehint2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:returntypehint2 [2011/12/22 00:17] – [Changelog] fitchwh | rfc:returntypehint2 [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2011-12-13 | * Date: 2011-12-13 | ||
* Author: Will Fitch < | * Author: Will Fitch < | ||
- | * Status: | + | * Status: |
Line 27: | Line 27: | ||
This implementation of return type hinting follows the same approach. | This implementation of return type hinting follows the same approach. | ||
+ | |||
+ | === Returning NULL === | ||
+ | |||
+ | By default, if you specify a return type hint, you **must** return that type. However, a new keyword " | ||
=== Example Implementations === | === Example Implementations === | ||
Line 56: | Line 60: | ||
} | } | ||
| | ||
- | public | + | public |
+ | { | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | // The nullable keyword allows you to return null | ||
+ | protected nullable ArrayObject getArrayObject() | ||
{ | { | ||
return null; | return null; | ||
} | } | ||
| | ||
- | | + | |
{ | { | ||
- | return 'strlen'; | + | return 'str_replace'; |
+ | } | ||
+ | |||
+ | ArrayObject methodsDontNeedModsActually() | ||
+ | { | ||
+ | return new ArrayObject(); | ||
} | } | ||
} | } | ||
Line 154: | Line 169: | ||
=== Tests === | === Tests === | ||
- | A total of 22 tests were added to tests/ | + | A total of 21 tests were added to tests/ |
* Determine that non-namespaced and namespaced class name don't produce a syntax error | * Determine that non-namespaced and namespaced class name don't produce a syntax error | ||
Line 165: | Line 180: | ||
===== Patch ===== | ===== Patch ===== | ||
- | The downloadable | + | The patch for this is now outdated and gone. |
- | + | ||
- | Patch: http:// | + | |
- | + | ||
- | Github: https:// | + | |
Line 176: | Line 187: | ||
===== Changelog ===== | ===== Changelog ===== | ||
- | - Updated to include " | + | - Updated to include " |
+ | - Updated to remove allowing NULL to be returned unconditionally when declaring return types | ||
+ | - Added a new patch which includes a " | ||
+ | - Updated the RFC to take " | ||
rfc/returntypehint2.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1