Skip to content

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.
@jaapio jaapio requested a review from mvriel April 30, 2017 15:24
mvriel
mvriel previously requested changes Jun 4, 2017
$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.

['\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.

2 participants