Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Jan Kuchař
grifart-enum
Commits
9de18e66
Commit
9de18e66
authored
Jan 10, 2019
by
Jan Kuchař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allowed to call self::VALUE2() on child classes
parent
16fc102f
Pipeline
#14409
passed with stages
in 1 minute and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
src/Enum.php
src/Enum.php
+1
-1
tests/Regression/full-classes-as-values.phpt
tests/Regression/full-classes-as-values.phpt
+10
-6
No files found.
src/Enum.php
View file @
9de18e66
...
...
@@ -64,7 +64,7 @@ abstract class Enum
{
\
assert
(
\
count
(
$arguments
)
===
0
);
$value
=
self
::
getMeta
()
->
getValueForConstantName
(
$constantName
);
$value
=
self
::
getMeta
(
FALSE
)
->
getValueForConstantName
(
$constantName
);
if
(
$value
===
NULL
)
{
throw
new
\
Error
(
'Call to undefined method '
.
static
::
class
.
'::'
.
$constantName
.
'(). Please check that you have provided constant, annotation and value.'
);
}
...
...
tests/Regression/full-classes-as-values.phpt
View file @
9de18e66
...
...
@@ -61,12 +61,16 @@ $expectNonRootAccess(function () {
$expectNonRootAccess
(
function
()
{
Value1
::
fromScalar
(
'1'
);
});
$expectNonRootAccess
(
function
()
{
Value1
::
VALUE1
();
});
$expectNonRootAccess
(
function
()
{
Value1
::
VALUE2
();
});
//$expectNonRootAccess(function () {
// Value1::VALUE1();
//});
//$expectNonRootAccess(function () {
// 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
Assert
::
same
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment