Skip to content

Commit 03b8b34

Browse files
flokixdevdg
authored andcommitted
ComponentReflection::parseAnnotations: fixed regexp quoting
1 parent 61491fd commit 03b8b34

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Application/UI/ComponentReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public static function convertType(& $val, $type, $isClass = FALSE)
195195
*/
196196
public static function parseAnnotation(\Reflector $ref, $name)
197197
{
198-
if (!preg_match_all("#[\\s*]@$name(?:\(\\s*([^)]*)\\s*\))?#", $ref->getDocComment(), $m)) {
198+
if (!preg_match_all('#[\\s*]@' . preg_quote($name, '#') . '(?:\(\\s*([^)]*)\\s*\))?#', $ref->getDocComment(), $m)) {
199199
return FALSE;
200200
}
201201
static $tokens = ['true' => TRUE, 'false' => FALSE, 'null' => NULL];

tests/UI/ComponentReflection.parseAnnotation.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ require __DIR__ . '/../bootstrap.php';
2222
* @author
2323
*@renderable
2424
* @secured(role = "admin", level = 2)
25+
* @Secured\User(loggedIn)
2526
*/
2627
class TestClass {}
2728

@@ -32,4 +33,5 @@ Assert::same(['value ="Johno\'s addendum"', 'mode=True', TRUE, TRUE], Reflection
3233
Assert::same(['item 1'], Reflection::parseAnnotation($rc, 'components'));
3334
Assert::same([TRUE, FALSE, NULL], Reflection::parseAnnotation($rc, 'persistent'));
3435
Assert::same([TRUE], Reflection::parseAnnotation($rc, 'renderable'));
36+
Assert::same(['loggedIn'], Reflection::parseAnnotation($rc, 'Secured\User'));
3537
Assert::false(Reflection::parseAnnotation($rc, 'missing'));

0 commit comments

Comments
 (0)