Commit 9de18e66 authored by Jan Kuchař's avatar Jan Kuchař

allowed to call self::VALUE2() on child classes

parent 16fc102f
Pipeline #14409 passed with stages
in 1 minute and 5 seconds
...@@ -64,7 +64,7 @@ abstract class Enum ...@@ -64,7 +64,7 @@ abstract class Enum
{ {
\assert(\count($arguments) === 0); \assert(\count($arguments) === 0);
$value = self::getMeta()->getValueForConstantName($constantName); $value = self::getMeta(FALSE)->getValueForConstantName($constantName);
if($value === NULL) { if($value === NULL) {
throw new \Error('Call to undefined method ' . static::class . '::' . $constantName . '(). Please check that you have provided constant, annotation and value.'); throw new \Error('Call to undefined method ' . static::class . '::' . $constantName . '(). Please check that you have provided constant, annotation and value.');
} }
......
...@@ -61,12 +61,16 @@ $expectNonRootAccess(function () { ...@@ -61,12 +61,16 @@ $expectNonRootAccess(function () {
$expectNonRootAccess(function () { $expectNonRootAccess(function () {
Value1::fromScalar('1'); Value1::fromScalar('1');
}); });
$expectNonRootAccess(function () { //$expectNonRootAccess(function () {
Value1::VALUE1(); // Value1::VALUE1();
}); //});
$expectNonRootAccess(function () { //$expectNonRootAccess(function () {
Value1::VALUE2(); // Value1::VALUE2();
}); //});
Assert::type(Value1::class, Value1::VALUE1());
Assert::type(Value1::class, Value2::VALUE1());
Assert::type(Value2::class, Value1::VALUE2());
Assert::type(Value2::class, Value2::VALUE2());
// valid edge case: this is valid and accesses registers the same way as calls above // valid edge case: this is valid and accesses registers the same way as calls above
Assert::same( Assert::same(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment