Currently we have symbol tables separate from each other based on kind. For instance, constants, functions, and classes/interfaces/traits all have their own tables. This allows us to use the same name for a constant, function, and a class all simultaneously:
const Symbol = 'symbol'; function symbol() {} class Symbol {} // no errors
This behavior is sometimes useful but prohibits other, more useful features such as the ability to use a function name as a callback without using strings:
// this looks for constant strlen, not function strlen: array_map(strlen, ['hello', 'world']); // must use the string: array_map('strlen', ['hello', 'world']);
This makes it difficult to rename functions because it is more difficult to determine if a string is meant to be the function name or not compared to a symbolic usage. This RFC proposes to unify the constant, function, and class/interface/trait symbol tables into one.
This RFC proposes to unify the constant, function, and class/interface/trait symbol tables into one.
TODO
Any projects currently using the same name for different kinds of symbols will now get a redefinition error.
This RFC targets PHP 8.0 or PHP 9.0 because of the backwards compatibility breaks.
TODO
Depending on the exact implementation it may be possible for opcache to work without any changes.
Constants are currently case sensitive while functions and classes are case insensitive. Should we unify the case sensitivity at the same time?
This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC.
This RFC requires two-thirds of the votes to be in favor of logically unifying the symbol tables.
At this stage there is no patch.
Links to external references, discussions or RFCs