-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
75 lines (65 loc) · 1.71 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
declare(strict_types=1);
/**
* @project Castor Context
* @link https://github.com/castor-labs/context
* @project castor/context
* @author Matias Navarro-Carter [email protected]
* @license BSD-3-Clause
* @copyright 2022 Castor Labs Ltd
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Castor\Context;
use Castor\Context;
/**
* Returns a new context that holds the passed key value pair.
*
* @psalm-pure
*/
function withValue(Context $context, mixed $key, mixed $value): Context
{
return new KVPair($context, $key, $value);
}
/**
* Returns the default fallback context.
*
* This is a context that always returns null.
*
* You can think about it as an "empty" context.
*
* @psalm-pure
*/
function nil(): Context
{
return new Value();
}
/**
* Returns a new context that holds the passed key value pair.
*
* @psalm-pure
*
* @deprecated Use Castor\Context\withValue() instead
*/
function with_value(Context $ctx, mixed $key, mixed $value): Context
{
trigger_error('Castor\Context\with_value() is deprecated and it will be removed in a future version. Please use Castor\Context\withValue() instead', E_USER_DEPRECATED);
return withValue($ctx, $key, $value);
}
/**
* Returns the default fallback context.
*
* This is a context that always returns null.
*
* You can think about it as an "empty" context.
*
* @psalm-pure
*
* @deprecated Use Castor\Context\nil() instead
*/
function fallback(): Context
{
trigger_error('Castor\Context\fallback() is deprecated and it will be removed in a future version. Please use Castor\Context\nil() instead', E_USER_DEPRECATED);
return nil();
}