From 7567b74ce0b63d8ac9738302f83a0ec53119611d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 4 Jul 2014 15:03:16 +0200 Subject: [PATCH] moved to namespace Deployment (BC break) --- Deployment/deployment.php | 2 ++ Deployment/libs/CliRunner.php | 3 ++- Deployment/libs/CommandLine.php | 1 + Deployment/libs/Deployer.php | 9 +++++---- Deployment/libs/FtpServer.php | 5 +++-- Deployment/libs/Logger.php | 1 + Deployment/libs/Preprocessor.php | 3 ++- Deployment/libs/Server.php | 3 ++- Deployment/libs/SshServer.php | 5 +++-- deployment.sample.php | 2 +- 10 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Deployment/deployment.php b/Deployment/deployment.php index 35a21a29..1ac9b593 100644 --- a/Deployment/deployment.php +++ b/Deployment/deployment.php @@ -1,5 +1,7 @@ local = realpath($local); if (!$this->local) { - throw new InvalidArgumentException("Directory $local not found."); + throw new \InvalidArgumentException("Directory $local not found."); } $this->server = $server; $this->logger = $logger; @@ -374,16 +375,16 @@ private function runJobs(array $jobs) } $this->logger->log("$job: $out"); if ($err) { - throw new RuntimeException("Error in job $job"); + throw new \RuntimeException("Error in job $job"); } } elseif (is_callable($job)) { if ($job($this->server, $this->logger, $this) === FALSE) { - throw new RuntimeException('Error in job'); + throw new \RuntimeException('Error in job'); } } else { - throw new InvalidArgumentException("Invalid job $job."); + throw new \InvalidArgumentException("Invalid job $job."); } } } diff --git a/Deployment/libs/FtpServer.php b/Deployment/libs/FtpServer.php index 53490368..72a0cc0c 100644 --- a/Deployment/libs/FtpServer.php +++ b/Deployment/libs/FtpServer.php @@ -6,6 +6,7 @@ * Copyright (c) 2009 David Grudl (http://davidgrudl.com) */ +namespace Deployment; /** @@ -35,11 +36,11 @@ class FtpServer implements Server public function __construct($url, $passiveMode = TRUE) { if (!extension_loaded('ftp')) { - throw new Exception('PHP extension FTP is not loaded.'); + throw new \Exception('PHP extension FTP is not loaded.'); } $parts = parse_url($url); if (!isset($parts['scheme'], $parts['user'], $parts['pass']) || ($parts['scheme'] !== 'ftp' && $parts['scheme'] !== 'ftps')) { - throw new InvalidArgumentException("Invalid URL or missing username or password: $url"); + throw new \InvalidArgumentException("Invalid URL or missing username or password: $url"); } $this->url = $url; $this->passiveMode = (bool) $passiveMode; diff --git a/Deployment/libs/Logger.php b/Deployment/libs/Logger.php index 09230d7e..f3791eb8 100644 --- a/Deployment/libs/Logger.php +++ b/Deployment/libs/Logger.php @@ -6,6 +6,7 @@ * Copyright (c) 2009 David Grudl (http://davidgrudl.com) */ +namespace Deployment; /** diff --git a/Deployment/libs/Preprocessor.php b/Deployment/libs/Preprocessor.php index 1f99e3cc..5e6ab247 100644 --- a/Deployment/libs/Preprocessor.php +++ b/Deployment/libs/Preprocessor.php @@ -6,6 +6,7 @@ * Copyright (c) 2009 David Grudl (http://davidgrudl.com) */ +namespace Deployment; /** @@ -121,7 +122,7 @@ private function execute($command, $input) NULL, NULL, ['bypass_shell' => TRUE] ); if (!is_resource($process)) { - throw new Exception("Unable start process $command."); + throw new \Exception("Unable start process $command."); } fwrite($pipes[0], $input); diff --git a/Deployment/libs/Server.php b/Deployment/libs/Server.php index 393b74fc..247f91bb 100644 --- a/Deployment/libs/Server.php +++ b/Deployment/libs/Server.php @@ -6,6 +6,7 @@ * Copyright (c) 2009 David Grudl (http://davidgrudl.com) */ +namespace Deployment; /** @@ -81,6 +82,6 @@ function execute($command); -class ServerException extends Exception +class ServerException extends \Exception { } diff --git a/Deployment/libs/SshServer.php b/Deployment/libs/SshServer.php index 0e0a78e7..1458465d 100644 --- a/Deployment/libs/SshServer.php +++ b/Deployment/libs/SshServer.php @@ -6,6 +6,7 @@ * Copyright (c) 2009 David Grudl (http://davidgrudl.com) */ +namespace Deployment; /** @@ -32,11 +33,11 @@ class SshServer implements Server public function __construct($url) { if (!extension_loaded('ssh2')) { - throw new Exception('PHP extension SSH2 is not loaded.'); + throw new \Exception('PHP extension SSH2 is not loaded.'); } $parts = parse_url($url); if (!isset($parts['scheme'], $parts['user']) || $parts['scheme'] !== 'sftp') { - throw new InvalidArgumentException("Invalid URL or missing username: $url"); + throw new \InvalidArgumentException("Invalid URL or missing username: $url"); } $this->url = $url; } diff --git a/deployment.sample.php b/deployment.sample.php index 3ea248e8..cdb36f08 100644 --- a/deployment.sample.php +++ b/deployment.sample.php @@ -15,7 +15,7 @@ ', 'allowdelete' => TRUE, 'before' => array( - function (Server $server, Logger $logger, Deployer $deployer) { + function (Deployment\Server $server, Deployment\Logger $logger, Deployment\Deployer $deployer) { $logger->log('Hello!'); }, ),