rfc:use_function
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:use_function [2013/07/22 13:02] – revision 1.0.1 FAQ "why 'use function'?" igorw | rfc:use_function [2013/08/15 13:38] – update status to Voting igorw | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Importing namespaced functions ====== | ====== PHP RFC: Importing namespaced functions ====== | ||
- | * Version: 1.0.1 | + | * Version: 1.1.1 |
* Date: 2013-05-02 | * Date: 2013-05-02 | ||
* Author: Igor Wiedler, igor@wiedler.ch | * Author: Igor Wiedler, igor@wiedler.ch | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 70: | Line 70: | ||
var_dump(baz()); | var_dump(baz()); | ||
var_dump(qux()); | var_dump(qux()); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | All of this applies not only to functions, but also to namespaced constants. For consistency, | ||
+ | |||
+ | <code php> | ||
+ | namespace foo\bar { | ||
+ | const baz = 42; | ||
+ | } | ||
+ | |||
+ | namespace { | ||
+ | use const foo\bar\baz; | ||
+ | var_dump(baz); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Just like classes, it should be possible to alias imported functions and constants: | ||
+ | |||
+ | <code php> | ||
+ | namespace { | ||
+ | use function foo\bar as foo_bar; | ||
+ | use const foo\BAZ as FOO_BAZ; | ||
+ | var_dump(foo_bar()); | ||
+ | var_dump(FOO_BAZ); | ||
} | } | ||
</ | </ | ||
Line 206: | Line 230: | ||
===== Changelog ===== | ===== Changelog ===== | ||
- | 2013-07-22 1.0.1 FAQ "why 'use function'?" | + | * 2013-08-08 1.1.1 Added example of aliasing |
- | 2013-07-19 1.0.0 First version published for discussion | + | * 2013-07-23 1.1.0 Added support for constants with `use const` |
+ | * 2013-07-22 1.0.1 FAQ "why 'use function'?" | ||
+ | |
rfc/use_function.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1