Test Setup Failed
Branch master (aed244)
by Joe
01:52
created
class.cisco.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	}
92 92
 
93 93
 	/**
94
-	 * @param     $string
94
+	 * @param     string $string
95 95
 	 * @param int $index
96 96
 	 * @return string
97 97
 	 */
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	/**
145
-	 * @param $cmd
145
+	 * @param string $cmd
146 146
 	 */
147 147
 	public function write($cmd) {
148 148
 		fwrite($this->_stream, $cmd);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	 * @param $cmd
214
+	 * @param string $cmd
215 215
 	 * @return string
216 216
 	 */
217 217
 	public function exec($cmd) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	}
237 237
 
238 238
 	/**
239
-	 * @return mixed
239
+	 * @return string
240 240
 	 */
241 241
 	public function get_response() {
242 242
 		return $this->_response;
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 
736 736
 	/**
737 737
 	 * @param $config
738
-	 * @return bool
738
+	 * @return null|boolean
739 739
 	 */
740 740
 	public function configure($config) {
741 741
 		// USE AT OWN RISK: This function will apply configuration statements to a device.
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 				if (mb_strpos($entry[1], 'Auto') !== FALSE) {
387 387
 					$result['speed'] = 'auto';
388 388
 				} else {
389
-					$result['speed'] = (int)$entry[1];
389
+					$result['speed'] = (int) $entry[1];
390 390
 				} // if .. else
391 391
 				$entry[2] = rtrim($entry[2]);
392 392
 				$result['type'] = mb_substr($entry[2], mb_strrpos($entry[2], ' ') + 1);
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 			foreach ($this->_data as $vlan) {
564 564
 				$vlan = explode(' ', $vlan);
565 565
 				$vlan = mb_substr($vlan[0], 4);
566
-				$result[] = (int)$vlan;
566
+				$result[] = (int) $vlan;
567 567
 			} // foreach
568 568
 		} // if
569 569
 		$this->_data = $result;
@@ -748,14 +748,14 @@  discard block
 block discarded – undo
748 748
 		$config_prompt = str_replace("\r\n", '', trim($config_prompt));
749 749
 		if (mb_strpos($config_prompt, 'config)#') !== FALSE) {
750 750
 			foreach ($this->_data as $c)
751
-				$this->_ssh->write($c . "\n");
751
+				$this->_ssh->write($c."\n");
752 752
 			$this->_ssh->write("end\n");
753 753
 		}
754 754
 		$result = $this->_ssh->read($this->_prompt);
755 755
 		$result = explode("\r\n", $result);
756 756
 		if (count($this->_data) == (count($result) - 2))
757 757
 			return true; else
758
-			die('Error: Switch rejected configuration: '.PHP_EOL . $config . "\n");
758
+			die('Error: Switch rejected configuration: '.PHP_EOL.$config."\n");
759 759
 	}
760 760
 
761 761
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @var bool
27 27
 	 */
28
-	public $autoconnect = true; // Sets whether or not exec() will automatically connect() if needed
28
+	public $autoconnect = TRUE; // Sets whether or not exec() will automatically connect() if needed
29 29
 	/**
30 30
 	 * @var int
31 31
 	 */
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				//echo 'M:'.print_r($matches, TRUE).'<br>';
123 123
 				$match = isset($matches[0]) ? $matches[0] : [];
124 124
 			}
125
-			$pos = !empty($match) ? mb_strpos($this->_response, $match) : false;
125
+			$pos = !empty($match) ? mb_strpos($this->_response, $match) : FALSE;
126 126
 			//echo ++$i . "POS:".var_export($pos, TRUE).'<br>';
127 127
 			if ($pos !== FALSE) {
128 128
 				//echo "$match Matching $pattern @ $pos <br>";
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 		//echo "Connecting to " . $this->_hostname . "<br>";
156 156
 		$this->_ssh = ssh2_connect($this->_hostname, $this->_port);
157 157
 		if ($this->_ssh === FALSE) {
158
-			return false;
158
+			return FALSE;
159 159
 		}
160 160
 		ssh2_auth_password($this->_ssh, $this->_username, $this->_password);
161 161
 		$this->_stream = ssh2_shell($this->_ssh);
162
-		$this->connected = true;
162
+		$this->connected = TRUE;
163 163
 		$this->parse_motd_and_prompt();
164
-		return true;
164
+		return TRUE;
165 165
 	}
166 166
 
167 167
 	/**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 			$this->_motd = mb_substr($this->_motd, 0, -$length);
177 177
 		//echo "MOTD:".$this->_motd."<br>";
178 178
 		//echo "Prompt:".$this->_prompt.'<br>';
179
-		return true;
179
+		return TRUE;
180 180
 		sleep(1);
181 181
 		$this->_motd = '';
182 182
 		while ($this->_response = fgets($this->_stream)) {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @return string
216 216
 	 */
217 217
 	public function exec($cmd) {
218
-		if ($this->autoconnect === true && $this->connected === FALSE)
218
+		if ($this->autoconnect === TRUE && $this->connected === FALSE)
219 219
 			$this->connect();
220 220
 		if (mb_substr($cmd, -1) != "\n") {
221 221
 			//error_log("Adding NEWLINE Character To SSH2 Command $cmd", __LINE__, __FILE__);
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 */
256 256
 	public function __destruct() {
257
-		if ($this->connected === true)
257
+		if ($this->connected === TRUE)
258 258
 			$this->disconnect();
259 259
 	}
260 260
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		$result = $this->_ssh->read($this->_prompt);
755 755
 		$result = explode("\r\n", $result);
756 756
 		if (count($this->_data) == (count($result) - 2))
757
-			return true; else
757
+			return TRUE; else
758 758
 			die('Error: Switch rejected configuration: '.PHP_EOL . $config . "\n");
759 759
 	}
760 760
 
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 	public function write_config() {
765 765
 		$this->exec('write');
766 766
 		if (mb_strpos($this->_data, '[OK]') !== FALSE)
767
-			return true; else
768
-			return false;
767
+			return TRUE; else
768
+			return FALSE;
769 769
 	}
770 770
 }
771 771
 
Please login to merge, or discard this patch.