From a6fd9ea8b6f1e74d7db159b66705cb9e7efad392 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 31 Aug 2015 23:28:20 -0500 Subject: [PATCH] SCP: replace user_error's with exceptions --- phpseclib/Net/SCP.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index e54e3c0b..6853e072 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -34,6 +34,7 @@ namespace phpseclib\Net; use phpseclib\Net\SSH1; use phpseclib\Net\SSH2; +use phpseclib\Exception\FileNotFoundException; /** * Pure-PHP implementations of SCP. @@ -140,6 +141,7 @@ class SCP * @param String $data * @param optional Integer $mode * @param optional Callable $callback + * @throws \phpseclib\Exception\FileNotFoundException if you're uploading via a file and the file doesn't exist * @return Boolean * @access public */ @@ -168,8 +170,7 @@ class SCP $size = strlen($data); } else { if (!is_file($data)) { - user_error("$data is not a valid file", E_USER_NOTICE); - return false; + throw new FileNotFoundException("$data is not a valid file"); } $fp = @fopen($data, 'rb'); @@ -289,6 +290,7 @@ class SCP * Receives a packet from an SSH server * * @return String + * @throws \UnexpectedValueException on receipt of an unexpected packet * @access private */ function _receive() @@ -314,8 +316,7 @@ class SCP $this->ssh->bitmap = 0; return false; default: - user_error('Unknown packet received', E_USER_NOTICE); - return false; + throw new \UnexpectedValueException('Unknown packet received'); } } }