PHP: Fixed methods with keyword names + minor improvements#2818
PHP: Fixed methods with keyword names + minor improvements#2818RunDevelopment merged 5 commits intoPrismJS:masterfrom
Conversation
|
@RunDevelopment Hey, perhaps I should've mentioned. Instance methods are called with $variable->foreach(); // this "foreach" is a method
$variable->method(); // this is also a method
foreach ($list as $value) { // this "foreach" is a keyword
}
Test::foreach(); // this is "foreach" static method
Test::method(); // this is "method" static method
# Exceptions
$variable->class(); // this "class" should be interpreted as "keyword"
Test::class; // This "class" should still be a keyword, just as it is now. Please, don't break it. |
|
Wait, so
So |
Yes,
I meant that since PHP 7.4, you can use all keywords as method names, with the exception of |
This resolves #2817.
Apart from the obvious fix, I also made some minor improvements to the code.