Skip to content

Commit

Permalink
entity: fixed constant expansion with no name prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Feb 19, 2017
1 parent 0dd82ca commit 5ac3ab7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Entity/Reflection/ModifierParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private function processKeyword($value, ReflectionClass $reflectionClass)
return null;
} elseif (is_numeric($value)) {
return $value * 1;
} elseif (preg_match('#^[a-z0-9_\\\\]+::[a-z0-9_]+(\\*)?$#i', $value)) {
} elseif (preg_match('#^[a-z0-9_\\\\]+::[a-z0-9_]*(\\*)?$#i', $value)) {
list($className, $const) = explode('::', $value, 2);
if ($className === 'self' || $className === 'static') {
$reflection = $reflectionClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ $dic = require_once __DIR__ . '/../../../../bootstrap.php';
* @property int $test7 {enum static::TYPES_THREE}
* @property int $test8 {enum \NextrasTests\Orm\Entity\Reflection\EnumTestEntity::TYPE_*}
* @property string $test9 {enum Enum::A, Enum::B}
* @property string $test10 {enum Enum::*}
*/
class EnumTestEntity extends Entity
{
Expand Down Expand Up @@ -59,6 +60,7 @@ class MetadataParserParseEnumTest extends TestCase
Assert::same([3], $metadata->getProperty('test7')->enum);
Assert::same([1, 2], $metadata->getProperty('test8')->enum);
Assert::same(['a', 'b'], $metadata->getProperty('test9')->enum);
Assert::same(['a', 'b'], $metadata->getProperty('test10')->enum);
}
}

Expand Down
5 changes: 5 additions & 0 deletions tests/cases/unit/Entity/Reflection/ModifierParserTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class ModifierParserTest extends TestCase
$parser->parse('modifier self::FOO*, static::BAR*', $reflection)
);

Assert::equal(
['modifier', [1, 2, 'X', 'Y']],
$parser->parse('modifier self::*', $reflection)
);

Assert::throws(function () use ($parser, $reflection) {
$parser->parse('modifier ConstantsExpansion::FOOD*', $reflection);
}, InvalidModifierDefinitionException::class, 'No constant matches NextrasTests\Orm\Entity\Reflection\ConstantsExpansion::FOOD* pattern.');
Expand Down

0 comments on commit 5ac3ab7

Please sign in to comment.