22
33namespace React \Tests \Filesystem ;
44
5- use React \EventLoop \LoopInterface ;
65use React \Filesystem \AdapterInterface ;
76use React \Filesystem \Node \FileInterface ;
87use React \Filesystem \Node \NotExistInterface ;
98use React \Filesystem \Stat ;
109use React \Promise \Promise ;
1110use React \Promise \PromiseInterface ;
12- use function Clue \ React \Block \await ;
11+ use function React \Async \await ;
1312use function React \Promise \all ;
1413
1514final class FileTest extends AbstractFilesystemTestCase
@@ -21,7 +20,7 @@ final class FileTest extends AbstractFilesystemTestCase
2120 */
2221 public function stat (AdapterInterface $ filesystem ): void
2322 {
24- $ stat = $ this -> await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
23+ $ stat = await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
2524 return $ file ->stat ();
2625 }));
2726
@@ -36,7 +35,7 @@ public function stat(AdapterInterface $filesystem): void
3635 */
3736 public function getContents (AdapterInterface $ filesystem ): void
3837 {
39- $ fileContents = $ this -> await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
38+ $ fileContents = await ($ filesystem ->detect (__FILE__ )->then (static function (FileInterface $ file ): PromiseInterface {
4039 return $ file ->getContents ();
4140 }));
4241
@@ -54,7 +53,7 @@ public function getContents34and5thCharacterFromFile(AdapterInterface $filesyste
5453 $ fileName = $ directoryName . bin2hex (random_bytes (13 ));
5554 mkdir ($ directoryName );
5655 \file_put_contents ($ fileName , 'abcdefghijklmnopqrstuvwxyz ' );
57- $ fileContents = $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
56+ $ fileContents = await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
5857 return $ file ->getContents (3 , 3 );
5958 }));
6059
@@ -71,7 +70,7 @@ public function putContents(AdapterInterface $filesystem): void
7170 $ fileName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR . bin2hex (random_bytes (9 ));
7271 $ fileContents = bin2hex (random_bytes (128 ));
7372
74- $ writtenLength = $ this -> await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (function (FileInterface $ file ) use ($ fileContents ): PromiseInterface {
73+ $ writtenLength = await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (function (FileInterface $ file ) use ($ fileContents ): PromiseInterface {
7574 return $ file ->putContents ($ fileContents );
7675 }));
7776
@@ -89,7 +88,7 @@ public function putContents(AdapterInterface $filesystem): void
8988 public function putContentsMultipleBigFiles (AdapterInterface $ filesystem ): void
9089 {
9190 $ directoryName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR ;
92- $ this -> await ($ filesystem ->detect ($ directoryName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createDirectory ()));
91+ await ($ filesystem ->detect ($ directoryName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createDirectory ()));
9392 $ fileNames = [];
9493 $ fileContents = [];
9594 for ($ i = 0 ; $ i < 25 ; $ i ++) {
@@ -107,7 +106,7 @@ public function putContentsMultipleBigFiles(AdapterInterface $filesystem): void
107106 });
108107 }
109108
110- $ writtenLengths = $ this -> await (all ($ promises ));
109+ $ writtenLengths = await (all ($ promises ));
111110
112111 foreach ($ writtenLengths as $ fileName => $ writtenLength ) {
113112 self ::assertSame ($ writtenLength , strlen (file_get_contents ($ fileName )));
@@ -126,14 +125,14 @@ public function putContentsAppend(AdapterInterface $filesystem): void
126125 $ fileName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR . bin2hex (random_bytes (9 ));
127126 $ fileContentsFirst = bin2hex (random_bytes (128 ));
128127 $ fileContentsSecond = bin2hex (random_bytes (128 ));
129- $ writtenLengthFirst = $ this -> await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (static function (FileInterface $ file ) use ($ fileContentsFirst ): PromiseInterface {
128+ $ writtenLengthFirst = await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ())->then (static function (FileInterface $ file ) use ($ fileContentsFirst ): PromiseInterface {
130129 return $ file ->putContents ($ fileContentsFirst );
131130 }));
132131
133132 self ::assertSame ($ writtenLengthFirst , strlen (file_get_contents ($ fileName )));
134133 self ::assertSame ($ fileContentsFirst , file_get_contents ($ fileName ));
135134
136- $ writtenLengthSecond = $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContentsSecond ): PromiseInterface {
135+ $ writtenLengthSecond = await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContentsSecond ): PromiseInterface {
137136 return $ file ->putContents ($ fileContentsSecond , \FILE_APPEND );
138137 }));
139138
@@ -151,7 +150,7 @@ public function putContentsAppend(AdapterInterface $filesystem): void
151150 public function putContentsAppendBigFile (AdapterInterface $ filesystem ): void
152151 {
153152 $ fileName = sys_get_temp_dir () . DIRECTORY_SEPARATOR . bin2hex (random_bytes (13 )) . DIRECTORY_SEPARATOR . bin2hex (random_bytes (9 ));
154- $ this -> await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ()));
153+ await ($ filesystem ->detect ($ fileName )->then (static fn (NotExistInterface $ notExist ): PromiseInterface => $ notExist ->createFile ()));
155154
156155 $ fileContents = [];
157156 $ writtenLength = 0 ;
@@ -160,7 +159,7 @@ public function putContentsAppendBigFile(AdapterInterface $filesystem): void
160159 }
161160
162161 foreach ($ fileContents as $ fileContent ) {
163- $ writtenLength += $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContent ): PromiseInterface {
162+ $ writtenLength += await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ) use ($ fileContent ): PromiseInterface {
164163 return $ file ->putContents ($ fileContent , \FILE_APPEND );
165164 }));
166165 }
@@ -246,7 +245,7 @@ public function runMultipleFilesTests(AdapterInterface $filesystem, int $fileCou
246245 });
247246 }
248247
249- $ writtenLengths = $ this -> await (all ($ promises ));
248+ $ writtenLengths = await (all ($ promises ));
250249
251250 foreach ($ writtenLengths as $ fileName => $ writtenLength ) {
252251 self ::assertSame ($ writtenLength , strlen (file_get_contents ($ fileName )));
@@ -266,7 +265,7 @@ public function unlink(AdapterInterface $filesystem): void
266265 $ fileContents = bin2hex (random_bytes (2048 ));
267266 file_put_contents ($ fileName , $ fileContents );
268267 self ::assertFileExists ($ fileName );
269- $ this -> await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
268+ await ($ filesystem ->detect ($ fileName )->then (static function (FileInterface $ file ): PromiseInterface {
270269 return $ file ->unlink ();
271270 }));
272271
0 commit comments