From 8b76df4ab77dcf7680eee4b83353d038e28f92f7 Mon Sep 17 00:00:00 2001 From: Brent Roose Date: Mon, 29 Jan 2018 16:09:29 +0100 Subject: [PATCH] Rename `execute` to `run` in Tasks --- README.md | 4 ++-- src/Process/SynchronousProcess.php | 2 +- src/Task.php | 4 ++-- tests/MyTask.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fbd92375..5fed875d 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ class MyTask extends Task // Setup eg. dependency container, load config,... } - public function execute() + public function run() { // Do the real work here. } @@ -178,7 +178,7 @@ If the required extensions (`pctnl` and `posix`) are not installed in your curre The `Pool` class has a static method `isSupported` you can call to check whether your platform is able to run asynchronous processes. -If you're using a `Task` to run processes, only the `execute` method of those tasks will be called when running in synchronous mode. +If you're using a `Task` to run processes, only the `run` method of those tasks will be called when running in synchronous mode. ## Behind the curtains diff --git a/src/Process/SynchronousProcess.php b/src/Process/SynchronousProcess.php index 8ac292bc..f8c352e0 100644 --- a/src/Process/SynchronousProcess.php +++ b/src/Process/SynchronousProcess.php @@ -44,7 +44,7 @@ public function start() $startTime = microtime(true); $this->output = $this->task instanceof Task - ? $this->task->execute() + ? $this->task->run() : call_user_func($this->task); $this->executionTime = microtime(true) - $startTime; diff --git a/src/Task.php b/src/Task.php index 14b7aa49..d64fb349 100644 --- a/src/Task.php +++ b/src/Task.php @@ -6,12 +6,12 @@ abstract class Task { abstract public function configure(); - abstract public function execute(); + abstract public function run(); public function __invoke() { $this->configure(); - return $this->execute(); + return $this->run(); } } diff --git a/tests/MyTask.php b/tests/MyTask.php index 06c254a8..23bc2d56 100644 --- a/tests/MyTask.php +++ b/tests/MyTask.php @@ -13,7 +13,7 @@ public function configure() $this->i = 2; } - public function execute() + public function run() { return $this->i; }