Skip to content

Commit b98d205

Browse files
committed
Replace promise with future
1 parent 83d8532 commit b98d205

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

src/Driver/ParallelFilesystemDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class ParallelFilesystemDriver implements FilesystemDriver
2525
/** @var \SplObjectStorage Worker storage. */
2626
private \SplObjectStorage $workerStorage;
2727

28-
/** @var Future Pending worker request promise. */
28+
/** @var Future Pending worker request */
2929
private Future $pendingWorker;
3030

3131
/**

src/Filesystem.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function openFile(string $path, string $mode): File
2424
/**
2525
* Execute a file stat operation.
2626
*
27-
* If the requested path does not exist the resulting Promise will resolve to NULL.
27+
* If the requested path does not exist, it will return NULL.
2828
*
2929
* @param string $path File system path.
3030
*/
@@ -36,7 +36,7 @@ public function getStatus(string $path): ?array
3636
/**
3737
* Same as {@see Filesystem::getStatus()} except if the path is a link then the link's data is returned.
3838
*
39-
* If the requested path does not exist the resulting Promise will resolve to NULL.
39+
* If the requested path does not exist, it will return NULL.
4040
*
4141
* @param string $path File system path.
4242
*/
@@ -63,8 +63,7 @@ public function exists(string $path): bool
6363
/**
6464
* Retrieve the size in bytes of the file at the specified path.
6565
*
66-
* If the path does not exist or is not a regular file this
67-
* function's returned Promise WILL resolve as a failure.
66+
* If the path does not exist or is not a regular file, this method will throw.
6867
*
6968
* @param string $path File system path.
7069
*
@@ -119,8 +118,7 @@ public function isFile(string $path): bool
119118
/**
120119
* Does the specified path exist and is it a symlink?
121120
*
122-
* If the path does not exist the returned Promise will resolve
123-
* to FALSE and will not reject with an error.
121+
* If the path does not exist, this method will return FALSE.
124122
*
125123
* @param string $path File system path.
126124
*/

src/FilesystemDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function getStatus(string $path): ?array;
2323
/**
2424
* Same as {@see FilesystemDriver::getStatus()} except if the path is a link then the link's data is returned.
2525
*
26-
* If the requested path does not exist the resulting Promise will resolve to NULL.
26+
* If the requested path does not exist, this method will return NULL.
2727
*
2828
* @param string $path The file system path to stat.
2929
*
@@ -130,7 +130,7 @@ public function touch(string $path, ?int $modificationTime, ?int $accessTime): v
130130
*
131131
* @param string $path The file path from which to buffer contents.
132132
*
133-
* @return string A promise resolving to a string upon successful resolution.
133+
* @return string The file contents.
134134
*
135135
* @throws FilesystemException If the operation fails.
136136
*/

test/AsyncFileTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ public function testSimultaneousReads()
1616

1717
$handle = $this->driver->openFile(__FILE__, "r");
1818

19-
$promise1 = async(fn () => $handle->read(length: 20));
20-
$promise2 = async(fn () => $handle->read(length: 20));
19+
$future1 = async(fn () => $handle->read(length: 20));
20+
$future2 = async(fn () => $handle->read(length: 20));
2121

2222
$expected = \substr(File\read(__FILE__), 0, 20);
23-
$this->assertSame($expected, $promise1->await());
23+
$this->assertSame($expected, $future1->await());
2424

25-
$promise2->await();
25+
$future2->await();
2626
}
2727

2828
public function testSeekWhileReading()
@@ -31,13 +31,13 @@ public function testSeekWhileReading()
3131

3232
$handle = $this->driver->openFile(__FILE__, "r");
3333

34-
$promise1 = async(fn () => $handle->read(length: 10));
35-
$promise2 = async(fn () => $handle->read(length: 0));
34+
$future1 = async(fn () => $handle->read(length: 10));
35+
$future2 = async(fn () => $handle->read(length: 0));
3636

3737
$expected = \substr(File\read(__FILE__), 0, 10);
38-
$this->assertSame($expected, $promise1->await());
38+
$this->assertSame($expected, $future1->await());
3939

40-
$promise2->await();
40+
$future2->await();
4141
}
4242

4343
public function testReadWhileWriting()
@@ -50,12 +50,12 @@ public function testReadWhileWriting()
5050

5151
$data = "test";
5252

53-
$promise1 = async(fn () => $handle->write($data));
54-
$promise2 = async(fn () => $handle->read(length: 10));
53+
$future1 = async(fn () => $handle->write($data));
54+
$future2 = async(fn () => $handle->read(length: 10));
5555

56-
$this->assertNull($promise1->await());
56+
$this->assertNull($future1->await());
5757

58-
$promise2->await();
58+
$future2->await();
5959
}
6060

6161
public function testWriteWhileReading()
@@ -66,12 +66,12 @@ public function testWriteWhileReading()
6666

6767
$handle = $this->driver->openFile($path, "c+");
6868

69-
$promise1 = async(fn () => $handle->read(length: 10));
70-
$promise2 = async(fn () => $handle->write("test"));
69+
$future1 = async(fn () => $handle->read(length: 10));
70+
$future2 = async(fn () => $handle->write("test"));
7171

72-
$this->assertNull($promise1->await());
72+
$this->assertNull($future1->await());
7373

74-
$promise2->await();
74+
$future2->await();
7575
}
7676

7777
public function testCancelReadThenReadAgain()

0 commit comments

Comments
 (0)