Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if key/property exists in array/object #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/Observable.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Rx;

Expand Down Expand Up @@ -104,13 +104,13 @@ public function subscribe($onNextOrObserver = null, callable $onError = null, ca
$onNextOrObserver === null
? null
: function ($value) use ($onNextOrObserver, &$observer, &$disposable) {
try {
$onNextOrObserver($value);
} catch (\Throwable $throwable) {
$disposable->dispose();
$observer->onError($throwable);
}
},
try {
$onNextOrObserver($value);
} catch (\Throwable $throwable) {
$disposable->dispose();
$observer->onError($throwable);
}
},
$onError,
$onCompleted
);
Expand Down Expand Up @@ -1684,7 +1684,7 @@ public function bufferWithCount(int $count, int $skip = null): Observable
* @operator
* @reactivex catch
*/
public function catch (callable $selector): Observable
public function catch(callable $selector): Observable
{
return $this->lift(function () use ($selector) {
return new CatchErrorOperator(new ObservableFactoryWrapper($selector));
Expand Down Expand Up @@ -1831,7 +1831,7 @@ public function timestamp(SchedulerInterface $scheduler = null): Observable
* @operator
* @reactivex switch
*/
public function switch (): Observable
public function switch(): Observable
{
return $this->lift(function () {
return new SwitchLatestOperator();
Expand Down Expand Up @@ -1978,10 +1978,10 @@ public function pluck($property): Observable
}

return $this->map(function ($x) use ($property) {
if (is_array($x) && isset($x[$property])) {
if (is_array($x) && array_key_exists($property, $x)) {
return $x[$property];
}
if (is_object($x) && isset($x->$property)) {
if (is_object($x) && property_exists($x, $property)) {
return $x->$property;
}

Expand Down