Skip to content
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

Merged
merged 1 commit into from
Sep 11, 2017

Conversation

jaapio
Copy link
Member

@jaapio jaapio commented Apr 30, 2017

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.

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.
mvriel
mvriel previously requested changes Jun 4, 2017
@@ -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]*))?(?:\\(\\))?$/',
Copy link
Member

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

Copy link
Member Author

@jaapio jaapio Jun 5, 2017

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()']
Copy link
Member

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?

Copy link
Member Author

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 ;-)

@jaapio jaapio dismissed mvriel’s stale review September 11, 2017 18:02

No response, after feedback on the review. Tried to fix the issues.

@jaapio jaapio merged commit 21bdeb5 into phpDocumentor:master Sep 11, 2017
@jaapio jaapio deleted the feature/utf8-class-methodnames branch September 11, 2017 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants