Skip to content

Commit 1138c18

Browse files
committed
Merge commit '02e0b2a21e94523a248e3f634d842b57813fd508' into test-updates-8.3
2 parents 7a8a180 + 02e0b2a commit 1138c18

File tree

2 files changed

+74
-12
lines changed

2 files changed

+74
-12
lines changed

src/Observable.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace Rx;
66

@@ -104,13 +104,13 @@ public function subscribe($onNextOrObserver = null, callable $onError = null, ca
104104
$onNextOrObserver === null
105105
? null
106106
: function ($value) use ($onNextOrObserver, &$observer, &$disposable) {
107-
try {
108-
$onNextOrObserver($value);
109-
} catch (\Throwable $throwable) {
110-
$disposable->dispose();
111-
$observer->onError($throwable);
112-
}
113-
},
107+
try {
108+
$onNextOrObserver($value);
109+
} catch (\Throwable $throwable) {
110+
$disposable->dispose();
111+
$observer->onError($throwable);
112+
}
113+
},
114114
$onError,
115115
$onCompleted
116116
);
@@ -1684,7 +1684,7 @@ public function bufferWithCount(int $count, int $skip = null): Observable
16841684
* @operator
16851685
* @reactivex catch
16861686
*/
1687-
public function catch (callable $selector): Observable
1687+
public function catch(callable $selector): Observable
16881688
{
16891689
return $this->lift(function () use ($selector) {
16901690
return new CatchErrorOperator(new ObservableFactoryWrapper($selector));
@@ -1831,7 +1831,7 @@ public function timestamp(SchedulerInterface $scheduler = null): Observable
18311831
* @operator
18321832
* @reactivex switch
18331833
*/
1834-
public function switch (): Observable
1834+
public function switch(): Observable
18351835
{
18361836
return $this->lift(function () {
18371837
return new SwitchLatestOperator();
@@ -1978,10 +1978,10 @@ public function pluck($property): Observable
19781978
}
19791979

19801980
return $this->map(function ($x) use ($property) {
1981-
if (is_array($x) && isset($x[$property])) {
1981+
if (is_array($x) && array_key_exists($property, $x)) {
19821982
return $x[$property];
19831983
}
1984-
if (is_object($x) && isset($x->$property)) {
1984+
if (is_object($x) && property_exists($x, $property)) {
19851985
return $x->$property;
19861986
}
19871987

test/Rx/Functional/Operator/PluckTest.php

+62
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,66 @@ public function pluck_nested_numeric_key_with_object_properties()
254254
subscribe(200, 400)
255255
], $xs->getSubscriptions());
256256
}
257+
258+
/**
259+
* @test
260+
*/
261+
public function pluck_object_property_null()
262+
{
263+
$xs = $this->createHotObservable([
264+
onNext(180, (object)['prop' => 1]),
265+
onNext(210, (object)['prop' => 2]),
266+
onNext(240, (object)['prop' => 3]),
267+
onNext(290, (object)['prop' => null]),
268+
onNext(350, (object)['prop' => 5]),
269+
onError(400, new \Exception())
270+
]);
271+
272+
$results = $this->scheduler->startWithCreate(function () use ($xs) {
273+
return $xs->pluck('prop');
274+
});
275+
276+
$this->assertMessages([
277+
onNext(210, 2),
278+
onNext(240, 3),
279+
onNext(290, null),
280+
onNext(350, 5),
281+
onError(400, new \Exception())
282+
], $results->getMessages());
283+
284+
$this->assertSubscriptions([
285+
subscribe(200, 400)
286+
], $xs->getSubscriptions());
287+
}
288+
289+
/**
290+
* @test
291+
*/
292+
public function pluck_array_assoc_null()
293+
{
294+
$xs = $this->createHotObservable([
295+
onNext(180, ['prop' => 1]),
296+
onNext(210, ['prop' => 2]),
297+
onNext(240, ['prop' => 3]),
298+
onNext(290, ['prop' => null]),
299+
onNext(350, ['prop' => 5]),
300+
onError(400, new \Exception())
301+
]);
302+
303+
$results = $this->scheduler->startWithCreate(function () use ($xs) {
304+
return $xs->pluck('prop');
305+
});
306+
307+
$this->assertMessages([
308+
onNext(210, 2),
309+
onNext(240, 3),
310+
onNext(290, null),
311+
onNext(350, 5),
312+
onError(400, new \Exception())
313+
], $results->getMessages());
314+
315+
$this->assertSubscriptions([
316+
subscribe(200, 400)
317+
], $xs->getSubscriptions());
318+
}
257319
}

0 commit comments

Comments
 (0)