Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# ReflectionCommon
[![Build Status](https://travis-ci.org/phpDocumentor/ReflectionCommon.svg?branch=master)](https://travis-ci.org/phpDocumentor/ReflectionCommon)
6 changes: 5 additions & 1 deletion src/Fqsen.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ final class Fqsen
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.

$fqsen,
$matches
);

if ($result === 0) {
throw new \InvalidArgumentException(
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/FqsenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function validFqsenProvider()
['\My\Space\MY_CONSTANT2', 'MY_CONSTANT2'],
['\My\Space\MyClass', 'MyClass'],
['\My\Space\MyInterface', 'MyInterface'],
['\My\Space\Option«T»', 'Option«T»'],
['\My\Space\MyTrait', 'MyTrait'],
['\My\Space\MyClass::myMethod()', 'myMethod'],
['\My\Space\MyClass::$my_property', 'my_property'],
Expand Down Expand Up @@ -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 ;-)

];
}

Expand Down