Skip to content

Commit 35c6594

Browse files
committed
Allow fqsen with utf-8 chars
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.
1 parent a046af6 commit 35c6594

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# ReflectionCommon
2+
[![Build Status](https://travis-ci.org/phpDocumentor/ReflectionCommon.svg?branch=master)](https://travis-ci.org/phpDocumentor/ReflectionCommon)

src/Fqsen.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ final class Fqsen
3838
public function __construct($fqsen)
3939
{
4040
$matches = array();
41-
$result = preg_match('/^\\\\([\\w_\\\\]*)(?:[:]{2}\\$?([\\w_]+))?(?:\\(\\))?$/', $fqsen, $matches);
41+
$result = preg_match(
42+
'/^\\\\([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff\\\\]*)?(?:[:]{2}\\$?([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*))?(?:\\(\\))?$/',
43+
$fqsen,
44+
$matches
45+
);
4246

4347
if ($result === 0) {
4448
throw new \InvalidArgumentException(

tests/unit/FqsenTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function validFqsenProvider()
4343
['\My\Space\MY_CONSTANT2', 'MY_CONSTANT2'],
4444
['\My\Space\MyClass', 'MyClass'],
4545
['\My\Space\MyInterface', 'MyInterface'],
46+
['\My\Space\Option«T»', 'Option«T»'],
4647
['\My\Space\MyTrait', 'MyTrait'],
4748
['\My\Space\MyClass::myMethod()', 'myMethod'],
4849
['\My\Space\MyClass::$my_property', 'my_property'],
@@ -72,6 +73,7 @@ public function invalidFqsenProvider()
7273
['\My\*'],
7374
['\My\Space\.()'],
7475
['My\Space'],
76+
['1_function()']
7577
];
7678
}
7779

0 commit comments

Comments
 (0)