-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow fqsen with utf-8 chars #10
Allow fqsen with utf-8 chars #10
Conversation
Be more specific when checking the first character of the element names. And allow utf-8 chars in element names according to the php spec. Fixes phpDocumentor#7.
@@ -38,7 +38,11 @@ | |||
public function __construct($fqsen) | |||
{ | |||
$matches = array(); | |||
$result = preg_match('/^\\\\([\\w_\\\\]*)(?:[:]{2}\\$?([\\w_]+))?(?:\\(\\))?$/', $fqsen, $matches); | |||
$result = preg_match( | |||
'/^\\\\([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff\\\\]*)?(?:[:]{2}\\$?([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*))?(?:\\(\\))?$/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add the 'u' suffix to the regex and if I remember correctly you can use the \p{L}
matcher. Take a peek in the ReflectionDocBlock library how UTF-8 is handled there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it with /^\\\\([\p{L}_][\p{LS}_0-9\\\\]*)?(?:[:]{2}\\$?([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*))?(?:\\(\\))?$/u
this is different from what you did in ReflectionDocBlock since not all characters that match \s
are allowed here. \p
seems to be to limited. And it doesn't make I clearer to me. even more complicated since you will have to understand what the {}
do after \p
. If you don't mind I would like to keep it as is.
I failed in finding the right sentence to make all tests pass.
@@ -72,6 +73,7 @@ public function invalidFqsenProvider() | |||
['\My\*'], | |||
['\My\Space\.()'], | |||
['My\Space'], | |||
['1_function()'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vaguely remember that PHP identifiers are not allowed to start with a digit; has that changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why it is in the invalidFqsenProvider ;-)
No response, after feedback on the review. Tried to fix the issues.
Be more specific when checking the first character of the element names.
And allow utf-8 chars in element names according to the php spec.
Fixes #7.