@@ -13,9 +13,9 @@ class Trigger {
13
13
/** @var array<string> */
14
14
protected array $ keyMatches ;
15
15
/** @var array<string> */
16
- protected array $ with ;
16
+ protected array $ select ;
17
17
/** @var array<string> */
18
- protected array $ without ;
18
+ protected array $ selectAllExcept ;
19
19
/** @var array<Callback> */
20
20
protected array $ callbacks ;
21
21
protected ?bool $ hasFired ;
@@ -27,8 +27,8 @@ public function __construct(Input $input) {
27
27
28
28
$ this ->matches = [];
29
29
$ this ->keyMatches = [];
30
- $ this ->with = [];
31
- $ this ->without = [];
30
+ $ this ->select = [];
31
+ $ this ->selectAllExcept = [];
32
32
$ this ->callbacks = [];
33
33
$ this ->hasFired = null ;
34
34
}
@@ -49,28 +49,40 @@ public function when(string|array...$matches):self {
49
49
return $ this ;
50
50
}
51
51
52
- public function with (string ...$ keys ):self {
52
+ public function select (string ...$ keys ):self {
53
53
foreach ($ keys as $ key ) {
54
- $ this ->with []= $ key ;
54
+ $ this ->select []= $ key ;
55
55
}
56
56
57
57
return $ this ;
58
58
}
59
+ /** @deprecated Use select() instead to avoid ambiguity with immutable `with` functions */
60
+ public function with (string ...$ keys ):self {
61
+ return $ this ->select (...$ keys );
62
+ }
59
63
60
- public function without (string ...$ keys ):self {
64
+ public function selectAllExcept (string ...$ keys ):self {
61
65
foreach ($ keys as $ key ) {
62
- $ this ->without []= $ key ;
66
+ $ this ->selectAllExcept []= $ key ;
63
67
}
64
68
65
69
return $ this ;
66
70
}
71
+ /** @deprecated Use selectAllExcept() instead to avoid ambiguity with immutable `with` functions */
72
+ public function without (string ...$ keys ):self {
73
+ return $ this ->selectAllExcept (...$ keys );
74
+ }
67
75
68
- public function withAll ():self {
69
- $ this ->with = [];
70
- $ this ->without = [];
76
+ public function selectAll ():self {
77
+ $ this ->select = [];
78
+ $ this ->selectAllExcept = [];
71
79
72
80
return $ this ;
73
81
}
82
+ /** @deprecated Use selectAll() instead to avoid ambiguity with immutable `with` functions */
83
+ public function withAll ():self {
84
+ return $ this ->selectAll ();
85
+ }
74
86
75
87
public function setTrigger (string $ key , string $ value ):self {
76
88
if (!isset ($ this ->matches [$ key ])) {
@@ -142,8 +154,8 @@ public function fire():bool {
142
154
protected function callCallbacks ():void {
143
155
$ fields = $ this ->inputDataFactory ->create (
144
156
$ this ->input ,
145
- $ this ->with ,
146
- $ this ->without
157
+ $ this ->select ,
158
+ $ this ->selectAllExcept
147
159
);
148
160
149
161
foreach ($ this ->callbacks as $ callback ) {
0 commit comments