You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/MarkingStore/MethodMarkingStore.php
+33-21Lines changed: 33 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -37,21 +37,21 @@ final class MethodMarkingStore implements MarkingStoreInterface
37
37
privatearray$setters = [];
38
38
39
39
/**
40
-
* @param string $property Used to determine methods or property to call
41
-
* The `getMarking` method will use `$subject->getProperty()` or `$subject->property`
42
-
* The `setMarking` method will use `$subject->setProperty(string|array $places, array $context = [])` or `$subject->property = string|array $places`
40
+
* @param string $property Used to determine the accessor methods or the property to call
41
+
* `getMarking()` will use `$subject->getProperty()` or `$subject->$property`
42
+
* `setMarking()` will use `$subject->setProperty(string|array|\BackedEnum $places, array $context = [])` or `$subject->$property = string|array|\BackedEnum $places`
$unInitializedPropertyMessage = \sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property);
57
57
if ($e->getMessage() !== $unInitializedPropertyMessage) {
@@ -64,6 +64,10 @@ public function getMarking(object $subject): Marking
64
64
}
65
65
66
66
if ($this->singleState) {
67
+
if ($markinginstanceof \BackedEnum) {
68
+
$marking = $marking->value;
69
+
}
70
+
67
71
$marking = [(string) $marking => 1];
68
72
} elseif (!\is_array($marking)) {
69
73
thrownewLogicException(\sprintf('The marking stored in "%s::$%s" is not an array and the Workflow\'s Marking store is instantiated with $singleState=false.', get_debug_type($subject), $this->property));
@@ -80,15 +84,15 @@ public function setMarking(object $subject, Marking $marking, array $context = [
thrownewLogicException(\sprintf('Cannot store marking: class "%s" should have either a public method named "%s()" or a public property named "$%s"; none found.', get_debug_type($subject), $method, $property));
121
+
try {
122
+
if (($r = new \ReflectionProperty($subject, $property))->isPublic()) {
123
+
$type = $r->getType();
124
+
125
+
return MarkingStoreMethod::PROPERTY;
126
+
}
127
+
} catch (\ReflectionException) {
128
+
}
129
+
130
+
thrownewLogicException(\sprintf('Cannot store marking: class "%s" should have either a public method named "%s()" or a public property named "$%s"; none found.', get_debug_type($subject), $method, $property));
0 commit comments