-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
In the new controller system each action is a class.
Since PHP has some reserved words you cannot use everything for a class name.
I see that if I want to have an action called new this is handled nicely. The class name should be NewAction and the Action is appended when searching for the class to handle my action.
But I found that the list of reserved words is not complete:
Magento\Framework\App\Router\ActionList contains a few reserved words:
$reservedWords = array('new', 'switch', 'return', 'print', 'list')
But I will not be able to have in my own code an url like this for example {module}/{controller}/public since public is also a reserved word. I mean I will be able to do it but not with the default routing system.
I think a full list of reserved words is needed even if some of them may never be used.
Here is what I got so far:
$reservedWords = array(
'abstract', 'and', 'array',
'as', 'break', 'callable', 'case',
'catch', 'class', 'clone', 'const',
'continue', 'declare', 'default', 'die',
'do', 'echo', 'else', 'elseif',
'empty', 'enddeclare', 'endfor', 'endforeach',
'endif', 'endswitch', 'endwhile', 'eval',
'exit', 'extends', 'final', 'for',
'foreach', 'function', 'global', 'goto',
'if', 'implements', 'include',
'instanceof', 'insteadof', 'interface', 'isset',
'list', 'namespace', 'new', 'or',
'print', 'private', 'protected', 'public',
'require', 'return', 'static',
'switch', 'throw', 'trait', 'try',
'unset', 'use', 'var', 'while',
'xor'
)