40
40
*/
41
41
class Context implements \ArrayAccess
42
42
{
43
- private array $ keys = array () ;
44
- private array $ values = array () ;
45
- private array $ frozen = array () ;
46
- private array $ raw = array () ;
43
+ private array $ keys = [] ;
44
+ private array $ values = [] ;
45
+ private array $ frozen = [] ;
46
+ private array $ raw = [] ;
47
47
48
48
private $ shared ;
49
49
private $ protected ;
@@ -56,10 +56,10 @@ class Context implements \ArrayAccess
56
56
*
57
57
* @param array $values (default: array())
58
58
*/
59
- public function __construct (array $ values = array () )
59
+ public function __construct (array $ values = [] )
60
60
{
61
- $ this ->shared = new \SplObjectStorage ;
62
- $ this ->protected = new \SplObjectStorage ;
61
+ $ this ->shared = new \SplObjectStorage () ;
62
+ $ this ->protected = new \SplObjectStorage () ;
63
63
64
64
foreach ($ values as $ key => $ value ) {
65
65
$ this ->offsetSet ($ key , $ value );
@@ -71,7 +71,7 @@ public function __construct(array $values = array())
71
71
*
72
72
* @param string $name The unique name for the fact
73
73
*
74
- * @return boolean
74
+ * @return bool
75
75
*/
76
76
public function offsetExists ($ name ): bool
77
77
{
@@ -83,9 +83,9 @@ public function offsetExists($name): bool
83
83
*
84
84
* @param string $name The unique name for the fact
85
85
*
86
- * @return mixed The resolved value of the fact
87
- *
88
86
* @throws \InvalidArgumentException if the name is not defined
87
+ *
88
+ * @return mixed The resolved value of the fact
89
89
*/
90
90
#[\ReturnTypeWillChange]
91
91
public function offsetGet ($ name )
@@ -104,7 +104,7 @@ public function offsetGet($name)
104
104
// If this is a shared value, resolve, freeze, and return the result
105
105
if ($ this ->shared ->contains ($ value )) {
106
106
$ this ->frozen [$ name ] = true ;
107
- $ this ->raw [$ name ] = $ value ;
107
+ $ this ->raw [$ name ] = $ value ;
108
108
109
109
return $ this ->values [$ name ] = $ value ($ this );
110
110
}
@@ -130,12 +130,12 @@ public function offsetSet($name, $value): void
130
130
throw new \RuntimeException (sprintf ('Cannot override frozen fact "%s". ' , $ name ));
131
131
}
132
132
133
- $ this ->keys [$ name ] = true ;
133
+ $ this ->keys [$ name ] = true ;
134
134
$ this ->values [$ name ] = $ value ;
135
135
}
136
136
137
137
/**
138
- * Unset a fact
138
+ * Unset a fact.
139
139
*
140
140
* @param string $name The unique name for the fact
141
141
*/
@@ -159,9 +159,9 @@ public function offsetUnset($name): void
159
159
*
160
160
* @param callable $callable A fact callable to share
161
161
*
162
- * @return callable The passed callable
163
- *
164
162
* @throws \InvalidArgumentException if the callable is not a Closure or invokable object
163
+ *
164
+ * @return callable The passed callable
165
165
*/
166
166
public function share ($ callable )
167
167
{
@@ -182,9 +182,9 @@ public function share($callable)
182
182
*
183
183
* @param callable $callable A callable to protect from being evaluated
184
184
*
185
- * @return callable The passed callable
186
- *
187
185
* @throws \InvalidArgumentException if the callable is not a Closure or invokable object
186
+ *
187
+ * @return callable The passed callable
188
188
*/
189
189
public function protect ($ callable )
190
190
{
@@ -202,9 +202,9 @@ public function protect($callable)
202
202
*
203
203
* @param string $name The unique name for the fact
204
204
*
205
- * @return mixed The value of the fact or the closure defining the fact
206
- *
207
205
* @throws \InvalidArgumentException if the name is not defined
206
+ *
207
+ * @return mixed The value of the fact or the closure defining the fact
208
208
*/
209
209
public function raw ($ name )
210
210
{
@@ -234,7 +234,7 @@ public function keys()
234
234
*
235
235
* @param mixed $callable
236
236
*
237
- * @return boolean
237
+ * @return bool
238
238
*/
239
239
protected function isCallable ($ callable )
240
240
{
0 commit comments