Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

seregazhuk
Copy link
Contributor

This PR extends DirectoryInterface and adds method to rename() current directory object. The api is the same as FileInterface has:

$loop = Factory::create();
$filesystem = Filesystem::create($loop);
$dir = $filesystem->dir('new');

$dir->rename('new_name')->then(function(\React\Filesystem\Node\DirectoryInterface $newDir){
    echo 'Renamed to ' . $newDir->getPath() . PHP_EOL;
}, function(Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

* Rename the directory and return the new directory through a promise
*
* @param string $toDirectoryName
* @return PromiseInterface<FileInterface>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be PromiseInterface<DirectoryInterface>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure! Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍

@WyriHaximus WyriHaximus added this to the v0.1.1 milestone Feb 25, 2018
use React\EventLoop\Factory;
use React\Filesystem\Filesystem;

require '../vendor/autoload.php';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be relative to __DIR__ so that this example works irrespective of from where it is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@WyriHaximus WyriHaximus merged commit 1a326f2 into reactphp:master Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants