You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #306 Checking on reserved keywords for class name validity. (SerkanYildiz)
This PR was squashed before being merged into the 1.0-dev branch (closes#306).
Discussion
----------
Checking on reserved keywords for class name validity.
Validator should also check if the given class name is a reserved keyword or not.
However we have to come up with a better exception message, since this one does not reflect the error. Any suggestion?
Thanks for your help @weaverryan during #SymfonyConHackDay2018
Fixes#305
Commits
-------
f308470 Move validation logic into Validator.
a419b8f Checking on reserved keywords for class name validity.
if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $piece)) {
33
51
$errorMessage = $errorMessage ?: sprintf('"%s" is not valid as a PHP class name (it must start with a letter or underscore, followed by any number of letters, numbers, or underscores)', $className);
34
52
35
53
thrownewRuntimeCommandException($errorMessage);
36
54
}
55
+
56
+
if (\in_array(strtolower($shortClassName), $reservedKeywords, true)) {
57
+
thrownewRuntimeCommandException(sprintf('"%s" is a reserved keyword and thus cannot be used as class name in PHP.', $shortClassName));
0 commit comments