Improve class name checking in GeneratorCommand #38965
Closed
+37
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Support for class names with subdirectories
GeneratorCommand
checks if the given name is a reserved word.However, a name with a subdirectory will pass this check.
Changed to check for simple class names without the subdirectory part.
Checking for valid class names as PHP
This change will check for invalid class names such as
2021MyClass
String+Helper
The regular expression used can be found here.
https://www.php.net/manual/en/language.oop5.basic.php
Add reserved words
Add missing reserved words and reserved words to be added in PHP 8.1.
int
float
bool
string
true
false
null
void
iterable
object
match
enum
readonly
https://www.php.net/manual/en/reserved.other-reserved-words.php
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L136
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L166
https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L157
Screenshot
I'm new to contributing to OSS, so please let me know if I'm missing anything.