Skip to content

Commit 8f09d35

Browse files
committed
PresenterComponentReflection::parseAnnotation() recognizes TRUE / FALSE / NULL
1 parent bf72864 commit 8f09d35

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Application/UI/PresenterComponentReflection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,12 @@ public static function parseAnnotation(\Reflector $ref, $name)
199199
if (!preg_match_all("#[\\s*]@$name(?:\(\\s*([^)]*)\\s*\))?#", $ref->getDocComment(), $m)) {
200200
return FALSE;
201201
}
202+
static $tokens = ['true' => TRUE, 'false' => FALSE, 'null' => NULL];
202203
$res = [];
203204
foreach ($m[1] as $s) {
204-
$arr = $s === '' ? [TRUE] : preg_split('#\s*,\s*#', $s, -1, PREG_SPLIT_NO_EMPTY);
205-
$res = array_merge($res, $arr);
205+
foreach (preg_split('#\s*,\s*#', $s, -1, PREG_SPLIT_NO_EMPTY) ?: ['true'] as $item) {
206+
$res[] = array_key_exists($tmp = strtolower($item), $tokens) ? $tokens[$tmp] : $item;
207+
}
206208
}
207209
return $res;
208210
}

tests/UI/PresenterComponentReflection.parseAnnotation.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ $rc = new ReflectionClass('TestClass');
3030

3131
Assert::same(['value ="Johno\'s addendum"', 'mode=True', TRUE, TRUE], Reflection::parseAnnotation($rc, 'title'));
3232
Assert::same(['item 1'], Reflection::parseAnnotation($rc, 'components'));
33-
Assert::same(['true', 'FALSE', 'null'], Reflection::parseAnnotation($rc, 'persistent'));
33+
Assert::same([TRUE, FALSE, NULL], Reflection::parseAnnotation($rc, 'persistent'));
3434
Assert::same([TRUE], Reflection::parseAnnotation($rc, 'renderable'));
3535
Assert::false(Reflection::parseAnnotation($rc, 'missing'));

0 commit comments

Comments
 (0)