From 19d28484e8fdd7410066d61e54cf9760e43b98ff Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sat, 23 Jul 2016 09:42:51 +0200 Subject: [PATCH 01/12] Update php-cs-fixer dependency to friendsofphp --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 248e496..1076a92 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "require-dev": { "phpunit/phpunit": "~4.8", - "fabpot/php-cs-fixer": "~1.9" + "friendsofphp/php-cs-fixer": "~1.9" }, "autoload": { "psr-4": { From 0577bf7f63125797d3da5b3cf7ea8beeb499f69a Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sun, 14 Aug 2016 20:42:33 +0200 Subject: [PATCH 02/12] Fix return type docs for open --- lib/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions.php b/lib/functions.php index 543454c..f94a1f7 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -40,7 +40,7 @@ function driver() { * * @param string $path * @param string $mode - * @return \Amp\File\Handle + * @return \Amp\Promise<\Amp\File\Handle> */ function open($path, $mode) { return filesystem()->open($path, $mode); From 6eeeeacab2c0ca295ffb80176050e64f8dc9083c Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 24 Aug 2016 11:02:28 -0500 Subject: [PATCH 03/12] Update branch aliases --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1076a92..314db64 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ }, "extra": { "branch-alias": { - "dev-master": "0.1.0-dev" + "dev-master": "0.1.0-dev", + "dev-amp_v2": "0.2.0-dev" } } } From 76701d6918c89613ef39a196d458e76aad0df8f1 Mon Sep 17 00:00:00 2001 From: Sergey Gelunenko Date: Wed, 28 Sep 2016 13:39:24 +0300 Subject: [PATCH 04/12] recursive mkdir, fix #5 --- lib/BlockingDriver.php | 4 ++-- lib/Driver.php | 3 ++- lib/EioDriver.php | 32 ++++++++++++++++++++++++++++++-- lib/UvDriver.php | 41 ++++++++++++++++++++++++++++++++++++----- lib/functions.php | 5 +++-- test/DriverTest.php | 7 ++++++- 6 files changed, 79 insertions(+), 13 deletions(-) diff --git a/lib/BlockingDriver.php b/lib/BlockingDriver.php index 202b74a..67e18bc 100644 --- a/lib/BlockingDriver.php +++ b/lib/BlockingDriver.php @@ -203,8 +203,8 @@ class BlockingDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644) { - return new Success((bool) @\mkdir($path, $mode)); + public function mkdir($path, $mode = 0644, $recursive) { + return new Success((bool) @\mkdir($path, $mode, $recursive)); } /** diff --git a/lib/Driver.php b/lib/Driver.php index d2c57c1..03b03e6 100644 --- a/lib/Driver.php +++ b/lib/Driver.php @@ -129,9 +129,10 @@ interface Driver { * * @param string $path * @param int $mode + * @param bool $recursive * @return \Amp\Promise */ - public function mkdir($path, $mode = 0644); + public function mkdir($path, $mode = 0644, $recursive); /** * Delete a directory diff --git a/lib/EioDriver.php b/lib/EioDriver.php index ad2c592..b649ead 100644 --- a/lib/EioDriver.php +++ b/lib/EioDriver.php @@ -356,11 +356,39 @@ class EioDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644) { + public function mkdir($path, $mode = 0644, $recursive) { \call_user_func($this->incrementor, 1); $promisor = new Deferred; $priority = \EIO_PRI_DEFAULT; - \eio_mkdir($path, $mode, $priority, [$this, "onGenericResult"], $promisor); + + if ($recursive) { + $arrayPath = array_filter(explode(DIRECTORY_SEPARATOR, $path)); + $tmpPath = ""; + + $callback = function() use ( + &$callback, &$arrayPath, &$tmpPath, $mode, $priority, $promisor + ) { + $tmpPath .= DIRECTORY_SEPARATOR . array_shift($arrayPath); + + if (empty($arrayPath)) { + \eio_mkdir($tmpPath, $mode, $priority, [$this, "onGenericResult"], $promisor); + } else { + $this->isdir($tmpPath)->when(function ($error, $result) use ( + $callback, $tmpPath, $mode, $priority + ) { + if ($result) { + $callback(); + } else { + \eio_mkdir($tmpPath, $mode, $priority, $callback); + } + }); + } + }; + + $callback(); + } else { + \eio_mkdir($path, $mode, $priority, [$this, "onGenericResult"], $promisor); + } return $promisor->promise(); } diff --git a/lib/UvDriver.php b/lib/UvDriver.php index 921b673..a5c615a 100644 --- a/lib/UvDriver.php +++ b/lib/UvDriver.php @@ -300,13 +300,44 @@ class UvDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644) { + public function mkdir($path, $mode = 0644, $recursive) { $this->reactor->addRef(); $promisor = new Deferred; - \uv_fs_mkdir($this->loop, $path, $mode, function($fh) use ($promisor) { - $this->reactor->delRef(); - $promisor->succeed((bool)$fh); - }); + + if ($recursive) { + $arrayPath = array_filter(explode(DIRECTORY_SEPARATOR, $path)); + $tmpPath = ""; + + $callback = function() use ( + &$callback, &$arrayPath, &$tmpPath, $mode, $promisor + ) { + $tmpPath .= DIRECTORY_SEPARATOR . array_shift($arrayPath); + + if (empty($arrayPath)) { + \uv_fs_mkdir($this->loop, $tmpPath, $mode, function($fh) use ($promisor) { + $this->reactor->delRef(); + $promisor->succeed((bool)$fh); + }); + } else { + $this->isdir($tmpPath)->when(function ($error, $result) use ( + $callback, $tmpPath, $mode + ) { + if ($result) { + $callback(); + } else { + \uv_fs_mkdir($this->loop, $tmpPath, $mode, $callback); + } + }); + } + }; + + $callback(); + } else { + \uv_fs_mkdir($this->loop, $path, $mode, function($fh) use ($promisor) { + $this->reactor->delRef(); + $promisor->succeed((bool)$fh); + }); + } return $promisor->promise(); } diff --git a/lib/functions.php b/lib/functions.php index f94a1f7..297ec8a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -197,10 +197,11 @@ function unlink($path) { * * @param string $path * @param int $mode + * @param bool $recursive * @return \Amp\Promise */ -function mkdir($path, $mode = 0644) { - return filesystem()->mkdir($path, $mode); +function mkdir($path, $mode = 0644, $recursive = false) { + return filesystem()->mkdir($path, $mode, $recursive); } /** diff --git a/test/DriverTest.php b/test/DriverTest.php index 2e9e91b..edc1b16 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -261,9 +261,14 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $dir = "{$fixtureDir}/newdir"; yield file\mkdir($dir); - $stat = (yield file\stat($dir)); + $this->assertNotNull(yield file\stat($dir)); yield file\rmdir($dir); $this->assertNull(yield file\stat($dir)); + + $dir = "{$fixtureDir}/newdir/with/recursive/creation"; + + yield file\mkdir($dir, 0744, true); + $this->assertNotNull(yield file\stat($dir)); }); } From 058ef8b563c775a4065c9f9654bfa5d280c772d8 Mon Sep 17 00:00:00 2001 From: Sergey Gelunenko Date: Wed, 28 Sep 2016 15:15:12 +0300 Subject: [PATCH 05/12] add default value --- lib/BlockingDriver.php | 2 +- lib/Driver.php | 2 +- lib/EioDriver.php | 2 +- lib/UvDriver.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/BlockingDriver.php b/lib/BlockingDriver.php index 67e18bc..192127a 100644 --- a/lib/BlockingDriver.php +++ b/lib/BlockingDriver.php @@ -203,7 +203,7 @@ class BlockingDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644, $recursive) { + public function mkdir($path, $mode = 0644, $recursive = false) { return new Success((bool) @\mkdir($path, $mode, $recursive)); } diff --git a/lib/Driver.php b/lib/Driver.php index 03b03e6..059ccf9 100644 --- a/lib/Driver.php +++ b/lib/Driver.php @@ -132,7 +132,7 @@ interface Driver { * @param bool $recursive * @return \Amp\Promise */ - public function mkdir($path, $mode = 0644, $recursive); + public function mkdir($path, $mode = 0644, $recursive = false); /** * Delete a directory diff --git a/lib/EioDriver.php b/lib/EioDriver.php index b649ead..7be5555 100644 --- a/lib/EioDriver.php +++ b/lib/EioDriver.php @@ -356,7 +356,7 @@ class EioDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644, $recursive) { + public function mkdir($path, $mode = 0644, $recursive = false) { \call_user_func($this->incrementor, 1); $promisor = new Deferred; $priority = \EIO_PRI_DEFAULT; diff --git a/lib/UvDriver.php b/lib/UvDriver.php index a5c615a..68e498e 100644 --- a/lib/UvDriver.php +++ b/lib/UvDriver.php @@ -300,7 +300,7 @@ class UvDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644, $recursive) { + public function mkdir($path, $mode = 0644, $recursive = false) { $this->reactor->addRef(); $promisor = new Deferred; From ada86677c9275de600bebf76fdad2e07e2983985 Mon Sep 17 00:00:00 2001 From: Sergey Gelunenko Date: Wed, 28 Sep 2016 15:18:05 +0300 Subject: [PATCH 06/12] replace slashes to DS --- lib/EioDriver.php | 1 + lib/UvDriver.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/EioDriver.php b/lib/EioDriver.php index 7be5555..e0285bb 100644 --- a/lib/EioDriver.php +++ b/lib/EioDriver.php @@ -362,6 +362,7 @@ class EioDriver implements Driver { $priority = \EIO_PRI_DEFAULT; if ($recursive) { + $path = str_replace("/", DIRECTORY_SEPARATOR, $path); $arrayPath = array_filter(explode(DIRECTORY_SEPARATOR, $path)); $tmpPath = ""; diff --git a/lib/UvDriver.php b/lib/UvDriver.php index 68e498e..c946b22 100644 --- a/lib/UvDriver.php +++ b/lib/UvDriver.php @@ -305,6 +305,7 @@ class UvDriver implements Driver { $promisor = new Deferred; if ($recursive) { + $path = str_replace("/", DIRECTORY_SEPARATOR, $path); $arrayPath = array_filter(explode(DIRECTORY_SEPARATOR, $path)); $tmpPath = ""; From 6612ae6757d4719492ed8b34ea6181ff67cfbed1 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 1 Oct 2016 18:43:52 +0100 Subject: [PATCH 07/12] EioDriver and UvDriver did not pass O_TRUNC in file\put Also prepare tag 0.1.3 --- CHANGELOG | 5 +++++ lib/EioDriver.php | 2 +- lib/UvDriver.php | 2 +- test/DriverTest.php | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3c2efb1..5dcc569 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +### 0.1.3 + +- Add recursive mkdir() +- EioDriver and UvDriver now pass O_TRUNC in file\put() + ### 0.1.2 - Make UvHandle throw FilesystemException instead of \RuntimeException diff --git a/lib/EioDriver.php b/lib/EioDriver.php index e0285bb..ce3213a 100644 --- a/lib/EioDriver.php +++ b/lib/EioDriver.php @@ -538,7 +538,7 @@ class EioDriver implements Driver { * {@inheritdoc} */ public function put($path, $contents) { - $flags = \EIO_O_RDWR | \EIO_O_CREAT; + $flags = \EIO_O_RDWR | \EIO_O_CREAT | \EIO_O_TRUNC; $mode = \EIO_S_IRUSR | \EIO_S_IWUSR | \EIO_S_IXUSR; $priority = \EIO_PRI_DEFAULT; diff --git a/lib/UvDriver.php b/lib/UvDriver.php index c946b22..ab92d73 100644 --- a/lib/UvDriver.php +++ b/lib/UvDriver.php @@ -515,7 +515,7 @@ class UvDriver implements Driver { } private function doPut($path, $contents): \Generator { - $flags = \UV::O_WRONLY | \UV::O_CREAT; + $flags = \UV::O_WRONLY | \UV::O_CREAT | \UV::O_TRUNC; $mode = \UV::S_IRWXU | \UV::S_IRUSR; $this->reactor->addRef(); $promise = $this->doFsOpen($path, $flags, $mode); diff --git a/test/DriverTest.php b/test/DriverTest.php index edc1b16..b6f5bac 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -243,6 +243,21 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { }); } + public function testPutTruncates() { + amp\run(function () { + $fixturePath = self::getFixturePath() . "/trunc"; + $contents = "long data"; + $short = "data"; + + yield file\put($fixturePath, $contents); + yield file\put($fixturePath, $short); + $contents2 = (yield file\get($fixturePath)); + yield file\unlink($fixturePath); + + $this->assertSame($short, $contents2); + }); + } + public function testUnlink() { amp\run(function () { $fixtureDir = self::getFixturePath(); From c822717106af4e1a456c9bbcaa953e2767776695 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 1 Oct 2016 19:28:30 +0100 Subject: [PATCH 08/12] Tabs <3 --- test/DriverTest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/DriverTest.php b/test/DriverTest.php index b6f5bac..6851af9 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -244,19 +244,19 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { } public function testPutTruncates() { - amp\run(function () { - $fixturePath = self::getFixturePath() . "/trunc"; - $contents = "long data"; - $short = "data"; + amp\run(function () { + $fixturePath = self::getFixturePath() . "/trunc"; + $contents = "long data"; + $short = "data"; - yield file\put($fixturePath, $contents); - yield file\put($fixturePath, $short); - $contents2 = (yield file\get($fixturePath)); - yield file\unlink($fixturePath); + yield file\put($fixturePath, $contents); + yield file\put($fixturePath, $short); + $contents2 = (yield file\get($fixturePath)); + yield file\unlink($fixturePath); - $this->assertSame($short, $contents2); - }); - } + $this->assertSame($short, $contents2); + }); + } public function testUnlink() { amp\run(function () { From cf7a9669004ee32d6e15e1b1de8319f6dc408d1f Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 3 Oct 2016 12:17:05 +0200 Subject: [PATCH 09/12] Fix #11 - use 0666 default permissions and rely on umask() --- lib/BlockingDriver.php | 2 +- lib/EioDriver.php | 8 ++++---- lib/UvDriver.php | 6 +++--- test/DriverTest.php | 18 +++++++++++++----- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/BlockingDriver.php b/lib/BlockingDriver.php index 192127a..fdbdaa2 100644 --- a/lib/BlockingDriver.php +++ b/lib/BlockingDriver.php @@ -203,7 +203,7 @@ class BlockingDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644, $recursive = false) { + public function mkdir($path, $mode = 0666, $recursive = false) { return new Success((bool) @\mkdir($path, $mode, $recursive)); } diff --git a/lib/EioDriver.php b/lib/EioDriver.php index ce3213a..1e1f0aa 100644 --- a/lib/EioDriver.php +++ b/lib/EioDriver.php @@ -71,7 +71,7 @@ class EioDriver implements Driver { "Invalid open mode" )); } - $chmod = ($flags & \EIO_O_CREAT) ? 0644 : 0; + $chmod = ($flags & \EIO_O_CREAT) ? 0666 : 0; \call_user_func($this->incrementor, 1); $promisor = new Deferred; $openArr = [$mode, $path, $promisor]; @@ -356,7 +356,7 @@ class EioDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644, $recursive = false) { + public function mkdir($path, $mode = 0666, $recursive = false) { \call_user_func($this->incrementor, 1); $promisor = new Deferred; $priority = \EIO_PRI_DEFAULT; @@ -538,8 +538,8 @@ class EioDriver implements Driver { * {@inheritdoc} */ public function put($path, $contents) { - $flags = \EIO_O_RDWR | \EIO_O_CREAT | \EIO_O_TRUNC; - $mode = \EIO_S_IRUSR | \EIO_S_IWUSR | \EIO_S_IXUSR; + $flags = \EIO_O_WRONLY | \EIO_O_CREAT | \EIO_O_TRUNC; + $mode = 0666; $priority = \EIO_PRI_DEFAULT; \call_user_func($this->incrementor, 1); diff --git a/lib/UvDriver.php b/lib/UvDriver.php index ab92d73..0b9a826 100644 --- a/lib/UvDriver.php +++ b/lib/UvDriver.php @@ -38,7 +38,7 @@ class UvDriver implements Driver { "Invalid open mode" )); } - $chmod = ($flags & \UV::O_CREAT) ? 0644 : 0; + $chmod = ($flags & \UV::O_CREAT) ? 0666 : 0; $this->reactor->addRef(); $promisor = new Deferred; $openArr = [$mode, $path, $promisor]; @@ -300,7 +300,7 @@ class UvDriver implements Driver { /** * {@inheritdoc} */ - public function mkdir($path, $mode = 0644, $recursive = false) { + public function mkdir($path, $mode = 0666, $recursive = false) { $this->reactor->addRef(); $promisor = new Deferred; @@ -516,7 +516,7 @@ class UvDriver implements Driver { private function doPut($path, $contents): \Generator { $flags = \UV::O_WRONLY | \UV::O_CREAT | \UV::O_TRUNC; - $mode = \UV::S_IRWXU | \UV::S_IRUSR; + $mode = 0666; $this->reactor->addRef(); $promise = $this->doFsOpen($path, $flags, $mode); if (!$fh = (yield $promise)) { diff --git a/test/DriverTest.php b/test/DriverTest.php index 6851af9..ac2b144 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -7,6 +7,7 @@ use Amp\File as file; abstract class DriverTest extends \PHPUnit_Framework_TestCase { private static $fixtureId; + private static $umask; private static function getFixturePath() { if (empty(self::$fixtureId)) { @@ -33,6 +34,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $fixtureDir = self::getFixturePath(); self::clearFixtureDir(); + self::$umask = umask(0022); if (!\mkdir($fixtureDir, $mode = 0777, $recursive = true)) { throw new \RuntimeException( @@ -53,6 +55,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { public static function tearDownAfterClass() { self::clearFixtureDir(); + umask(self::$umask); } protected function setUp() { @@ -258,12 +261,15 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { }); } - public function testUnlink() { + public function testPermsAndUnlink() { amp\run(function () { $fixtureDir = self::getFixturePath(); $toUnlink = "{$fixtureDir}/unlink"; + $mask = umask(062); yield file\put($toUnlink, "unlink me"); - $this->assertTrue((bool) (yield file\stat($toUnlink))); + umask($mask); + $stat = yield file\stat($toUnlink); + $this->assertTrue(($stat["mode"] & 0777) == 0604); yield file\unlink($toUnlink); $this->assertNull(yield file\stat($toUnlink)); }); @@ -276,14 +282,16 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $dir = "{$fixtureDir}/newdir"; yield file\mkdir($dir); - $this->assertNotNull(yield file\stat($dir)); + $stat = yield file\stat($dir); + $this->assertTrue(($stat["mode"] & 0777) == 0644); yield file\rmdir($dir); $this->assertNull(yield file\stat($dir)); $dir = "{$fixtureDir}/newdir/with/recursive/creation"; - yield file\mkdir($dir, 0744, true); - $this->assertNotNull(yield file\stat($dir)); + yield file\mkdir($dir, 0764, true); // the umask is 022 by default + $stat = yield file\stat($dir); + $this->assertTrue(($stat["mode"] & 0777) == 0744); }); } From af2ce9b2563a15f24d1e7631cf2fd6652c28d750 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 3 Oct 2016 12:28:19 +0200 Subject: [PATCH 10/12] Add PHP 5 yield parenthesis... --- test/DriverTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/DriverTest.php b/test/DriverTest.php index ac2b144..6130d98 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -268,7 +268,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $mask = umask(062); yield file\put($toUnlink, "unlink me"); umask($mask); - $stat = yield file\stat($toUnlink); + $stat = (yield file\stat($toUnlink)); $this->assertTrue(($stat["mode"] & 0777) == 0604); yield file\unlink($toUnlink); $this->assertNull(yield file\stat($toUnlink)); @@ -290,7 +290,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $dir = "{$fixtureDir}/newdir/with/recursive/creation"; yield file\mkdir($dir, 0764, true); // the umask is 022 by default - $stat = yield file\stat($dir); + $stat = (yield file\stat($dir)); $this->assertTrue(($stat["mode"] & 0777) == 0744); }); } From 534f67f7ef50e22f3157f28900ff39d60fe1fead Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 4 Oct 2016 14:02:51 +0200 Subject: [PATCH 11/12] Add PHP 5 yield parenthesis... --- test/DriverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/DriverTest.php b/test/DriverTest.php index 6130d98..2627daa 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -282,7 +282,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $dir = "{$fixtureDir}/newdir"; yield file\mkdir($dir); - $stat = yield file\stat($dir); + $stat = (yield file\stat($dir)); $this->assertTrue(($stat["mode"] & 0777) == 0644); yield file\rmdir($dir); $this->assertNull(yield file\stat($dir)); From 2712356453ab111c92217a2761cd9cae226197dd Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 4 Oct 2016 14:09:19 +0200 Subject: [PATCH 12/12] Tabs <3 ? (Use spaces instead) --- test/DriverTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/DriverTest.php b/test/DriverTest.php index 2627daa..57e7b69 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -7,7 +7,7 @@ use Amp\File as file; abstract class DriverTest extends \PHPUnit_Framework_TestCase { private static $fixtureId; - private static $umask; + private static $umask; private static function getFixturePath() { if (empty(self::$fixtureId)) { @@ -34,7 +34,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $fixtureDir = self::getFixturePath(); self::clearFixtureDir(); - self::$umask = umask(0022); + self::$umask = umask(0022); if (!\mkdir($fixtureDir, $mode = 0777, $recursive = true)) { throw new \RuntimeException( @@ -55,7 +55,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { public static function tearDownAfterClass() { self::clearFixtureDir(); - umask(self::$umask); + umask(self::$umask); } protected function setUp() { @@ -265,10 +265,10 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { amp\run(function () { $fixtureDir = self::getFixturePath(); $toUnlink = "{$fixtureDir}/unlink"; - $mask = umask(062); + $mask = umask(062); yield file\put($toUnlink, "unlink me"); - umask($mask); - $stat = (yield file\stat($toUnlink)); + umask($mask); + $stat = (yield file\stat($toUnlink)); $this->assertTrue(($stat["mode"] & 0777) == 0604); yield file\unlink($toUnlink); $this->assertNull(yield file\stat($toUnlink)); @@ -282,7 +282,7 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $dir = "{$fixtureDir}/newdir"; yield file\mkdir($dir); - $stat = (yield file\stat($dir)); + $stat = (yield file\stat($dir)); $this->assertTrue(($stat["mode"] & 0777) == 0644); yield file\rmdir($dir); $this->assertNull(yield file\stat($dir)); @@ -290,8 +290,8 @@ abstract class DriverTest extends \PHPUnit_Framework_TestCase { $dir = "{$fixtureDir}/newdir/with/recursive/creation"; yield file\mkdir($dir, 0764, true); // the umask is 022 by default - $stat = (yield file\stat($dir)); - $this->assertTrue(($stat["mode"] & 0777) == 0744); + $stat = (yield file\stat($dir)); + $this->assertTrue(($stat["mode"] & 0777) == 0744); }); }