Skip to content

Commit 99c4464

Browse files
author
Charlotte Dunois
committed
Let ObjectStreamSink::promise resolve with an array
1 parent 5ca5146 commit 99c4464

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

src/ObjectStreamSink.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class ObjectStreamSink
1313
public static function promise(ObjectStream $stream)
1414
{
1515
$deferred = new Deferred();
16-
$list = new \SplObjectStorage();
16+
$list = array();
1717

18-
$stream->on('data', function ($object) use ($list) {
19-
$list->attach($object);
18+
$stream->on('data', function ($object) use (&$list) {
19+
$list[] = $object;
2020
});
21-
$stream->on('end', function () use ($deferred, $list) {
21+
$stream->on('end', function () use ($deferred, &$list) {
2222
$deferred->resolve($list);
2323
});
2424

tests/Adapters/DirectoryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ public function testLs(LoopInterface $loop, FilesystemInterface $filesystem)
2121
$path = $this->tmpDir . 'path';
2222
touch($path);
2323
$listing = $this->await($filesystem->dir($this->tmpDir)->ls(), $loop);
24-
$listing->rewind();
25-
$this->assertSame(1, $listing->count());
26-
$this->assertSame($path, $listing->current()->getPath());
24+
$this->assertSame(1, count($listing));
25+
$this->assertSame($path, reset($listing)->getPath());
2726
}
2827

2928
/**

tests/ChildProcess/AdapterTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,8 @@ public function testLs()
319319
]);
320320

321321
$nodes = $this->await($promise, $loop);
322-
$nodes->rewind();
323322

324-
$this->assertEquals(new File('foo.bar/bar.foo', $fs), $nodes->current());
323+
$this->assertEquals(new File('foo.bar/bar.foo', $fs), reset($nodes));
325324
}
326325

327326
public function testLsStream()

tests/ObjectStreamSinkTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ public function testSink()
1515
$this->assertInstanceOf('React\Promise\PromiseInterface', $sink);
1616
$stream->emit('data', [$node]);
1717
$stream->close();
18+
1819
$nodes = null;
19-
$sink->then(function (\SplObjectStorage $list) use (&$nodes) {
20+
$sink->then(function ($list) use (&$nodes) {
2021
$nodes = $list;
2122
});
22-
$nodes->rewind();
23-
$this->assertSame(1, $nodes->count());
24-
$this->assertSame($node, $nodes->current());
23+
24+
$this->assertSame(1, count($nodes));
25+
$this->assertSame($node, reset($nodes));
2526
}
2627
}

0 commit comments

Comments
 (0)