Skip to content

Commit 7239174

Browse files
committed
KRF-244 #fix Fixed spread() method in Promise API
1 parent 441d6b4 commit 7239174

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

Promise.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ public function spread(callable $onFulfilled = null, callable $onRejected = null
135135
{
136136
return $this->then(
137137
function($values) use($onFulfilled) {
138-
call_user_func_array($onFulfilled, (array) $values);
138+
return call_user_func_array($onFulfilled, (array) $values);
139139
},
140140
function($rejections) use($onRejected) {
141-
call_user_func_array($onRejected, (array) $rejections);
141+
return call_user_func_array($onRejected, (array) $rejections);
142142
},
143143
function($reasons) use($onCancel) {
144-
call_user_func_array($onCancel, (array) $reasons);
144+
return call_user_func_array($onCancel, (array) $reasons);
145145
}
146146
);
147147
}

PromiseCancelled.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,10 @@ public function done(callable $onFulfilled = null, callable $onRejected = null,
100100
public function spread(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
101101
{
102102
return $this->then(
103-
function($values) use($onFulfilled) {
104-
call_user_func_array($onFulfilled, (array) $values);
105-
},
106-
function($rejections) use($onRejected) {
107-
call_user_func_array($onRejected, (array) $rejections);
108-
},
103+
null,
104+
null,
109105
function($reasons) use($onCancel) {
110-
call_user_func_array($onCancel, (array) $reasons);
106+
return call_user_func_array($onCancel, (array) $reasons);
111107
}
112108
);
113109
}

PromiseFulfilled.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,7 @@ public function spread(callable $onFulfilled = null, callable $onRejected = null
8989
{
9090
return $this->then(
9191
function($values) use($onFulfilled) {
92-
call_user_func_array($onFulfilled, (array) $values);
93-
},
94-
function($rejections) use($onRejected) {
95-
call_user_func_array($onRejected, (array) $rejections);
96-
},
97-
function($reasons) use($onCancel) {
98-
call_user_func_array($onCancel, (array) $reasons);
92+
return call_user_func_array($onFulfilled, (array) $values);
9993
}
10094
);
10195
}

PromiseRejected.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,9 @@ public function done(callable $onFulfilled = null, callable $onRejected = null,
9595
public function spread(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
9696
{
9797
return $this->then(
98-
function($values) use($onFulfilled) {
99-
call_user_func_array($onFulfilled, (array) $values);
100-
},
98+
null,
10199
function($rejections) use($onRejected) {
102-
call_user_func_array($onRejected, (array) $rejections);
103-
},
104-
function($reasons) use($onCancel) {
105-
call_user_func_array($onCancel, (array) $reasons);
100+
return call_user_func_array($onRejected, (array) $rejections);
106101
}
107102
);
108103
}

0 commit comments

Comments
 (0)