@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Construct method |
37 | 37 | * |
38 | - * @param mixed $loader |
|
38 | + * @param string $loader |
|
39 | 39 | * @param array $params list of options to be used for this run |
40 | 40 | * @throws MissingTestLoaderException When a loader class could not be found. |
41 | 41 | */ |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @throws MissingTestLoaderException When a loader class could not be found. |
41 | 41 | */ |
42 | 42 | public function __construct($loader, $params = array()) { |
43 | - if ($loader && !class_exists($loader)) { |
|
43 | + if ($loader && ! class_exists($loader)) { |
|
44 | 44 | throw new MissingTestLoaderException(array('class' => $loader)); |
45 | 45 | } |
46 | 46 | $this->arguments['loader'] = $loader; |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | try { |
96 | 96 | $result = $runner->doRun($suite, $this->arguments); |
97 | 97 | } catch (PHPUnit_Framework_Exception $e) { |
98 | - print $e->getMessage() . "\n"; |
|
98 | + print $e->getMessage()."\n"; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | if ($exit) { |
102 | 102 | if (isset($result) && $result->wasSuccessful()) { |
103 | 103 | exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); |
104 | - } elseif (!isset($result) || $result->errorCount() > 0) { |
|
104 | + } elseif ( ! isset($result) || $result->errorCount() > 0) { |
|
105 | 105 | exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); |
106 | 106 | } |
107 | 107 | exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | $object = null; |
139 | 139 | |
140 | 140 | $reporter = ucwords($reporter); |
141 | - $coreClass = 'Cake' . $reporter . 'Reporter'; |
|
141 | + $coreClass = 'Cake'.$reporter.'Reporter'; |
|
142 | 142 | App::uses($coreClass, 'TestSuite/Reporter'); |
143 | 143 | |
144 | - $appClass = $reporter . 'Reporter'; |
|
144 | + $appClass = $reporter.'Reporter'; |
|
145 | 145 | App::uses($appClass, 'TestSuite/Reporter'); |
146 | 146 | |
147 | - if (!class_exists($appClass)) { |
|
147 | + if ( ! class_exists($appClass)) { |
|
148 | 148 | $object = new $coreClass(null, $this->_params); |
149 | 149 | } else { |
150 | 150 | $object = new $appClass(null, $this->_params); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * Gets the base path that the files we are interested in live in. |
97 | 97 | * |
98 | - * @return void |
|
98 | + * @return string |
|
99 | 99 | */ |
100 | 100 | public function getPathFilter() { |
101 | 101 | $path = ROOT . DS; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @param array $fileLines |
138 | 138 | * @param array $coverageData |
139 | - * @return array Array of covered, total lines. |
|
139 | + * @return integer[] Array of covered, total lines. |
|
140 | 140 | */ |
141 | 141 | protected function _calculateCoveredLines($fileLines, $coverageData) { |
142 | 142 | $covered = $total = 0; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @return void |
99 | 99 | */ |
100 | 100 | public function getPathFilter() { |
101 | - $path = ROOT . DS; |
|
101 | + $path = ROOT.DS; |
|
102 | 102 | if ($this->appTest) { |
103 | - $path .= APP_DIR . DS; |
|
103 | + $path .= APP_DIR.DS; |
|
104 | 104 | } elseif ($this->pluginTest) { |
105 | 105 | $path = App::pluginPath($this->pluginTest); |
106 | 106 | } else { |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | unset($fileLines[0]); |
147 | 147 | |
148 | 148 | foreach ($fileLines as $lineno => $line) { |
149 | - if (!isset($coverageData[$lineno])) { |
|
149 | + if ( ! isset($coverageData[$lineno])) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | - if (is_array($coverageData[$lineno]) && !empty($coverageData[$lineno])) { |
|
152 | + if (is_array($coverageData[$lineno]) && ! empty($coverageData[$lineno])) { |
|
153 | 153 | $covered++; |
154 | 154 | $total++; |
155 | 155 | } elseif ($coverageData[$lineno] === -1 || $coverageData[$lineno] === array()) { |
@@ -108,6 +108,7 @@ discard block |
||
108 | 108 | * Guess the class name the test was for based on the test case filename. |
109 | 109 | * |
110 | 110 | * @param ReflectionClass $testReflection. |
111 | + * @param ReflectionClass $testReflection |
|
111 | 112 | * @return string Possible test subject name. |
112 | 113 | */ |
113 | 114 | protected function _guessSubjectName($testReflection) { |
@@ -127,7 +128,7 @@ discard block |
||
127 | 128 | * @param integer $linenumber |
128 | 129 | * @param string $class |
129 | 130 | * @param array $coveringTests |
130 | - * @return void |
|
131 | + * @return string |
|
131 | 132 | */ |
132 | 133 | protected function _paintLine($line, $linenumber, $class, $coveringTests) { |
133 | 134 | $coveredBy = ''; |
@@ -150,7 +151,7 @@ discard block |
||
150 | 151 | /** |
151 | 152 | * generate some javascript for the coverage report. |
152 | 153 | * |
153 | - * @return void |
|
154 | + * @return string |
|
154 | 155 | */ |
155 | 156 | public function coverageScript() { |
156 | 157 | return <<<HTML |
@@ -199,7 +200,7 @@ discard block |
||
199 | 200 | /** |
200 | 201 | * Generate an HTML snippet for coverage footers |
201 | 202 | * |
202 | - * @return void |
|
203 | + * @return string |
|
203 | 204 | */ |
204 | 205 | public function coverageFooter() { |
205 | 206 | return "</pre></div></div>"; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | foreach ($fileLines as $lineno => $line) { |
78 | 78 | $class = 'ignored'; |
79 | 79 | $coveringTests = array(); |
80 | - if (!empty($coverageData[$lineno]) && is_array($coverageData[$lineno])) { |
|
80 | + if ( ! empty($coverageData[$lineno]) && is_array($coverageData[$lineno])) { |
|
81 | 81 | $coveringTests = array(); |
82 | 82 | foreach ($coverageData[$lineno] as $test) { |
83 | 83 | $class = (is_array($test) && isset($test['id'])) ? $test['id'] : $test; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | protected function _guessSubjectName($testReflection) { |
114 | 114 | $basename = basename($testReflection->getFilename()); |
115 | 115 | if (strpos($basename, '.test') !== false) { |
116 | - list($subject, ) = explode('.', $basename, 2); |
|
116 | + list($subject,) = explode('.', $basename, 2); |
|
117 | 117 | return $subject; |
118 | 118 | } |
119 | 119 | $subject = str_replace('Test.php', '', $basename); |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function _paintLine($line, $linenumber, $class, $coveringTests) { |
133 | 133 | $coveredBy = ''; |
134 | - if (!empty($coveringTests)) { |
|
134 | + if ( ! empty($coveringTests)) { |
|
135 | 135 | $coveredBy = "Covered by:\n"; |
136 | 136 | foreach ($coveringTests as $test) { |
137 | - $coveredBy .= $test . "\n"; |
|
137 | + $coveredBy .= $test."\n"; |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * of this fixture could be executed successfully. |
265 | 265 | * |
266 | 266 | * @param DboSource $db An instance of the database into which the records will be inserted |
267 | - * @return boolean on success or if there are no records to insert, or false on failure |
|
267 | + * @return boolean|null on success or if there are no records to insert, or false on failure |
|
268 | 268 | * @throws CakeException if counts of values and fields do not match. |
269 | 269 | */ |
270 | 270 | public function insert($db) { |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | } |
97 | 97 | $connection = 'test'; |
98 | - if (!empty($this->useDbConfig)) { |
|
98 | + if ( ! empty($this->useDbConfig)) { |
|
99 | 99 | $connection = $this->useDbConfig; |
100 | 100 | if (strpos($connection, 'test') !== 0) { |
101 | 101 | $message = __d( |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | $this->Schema->connection = $import['connection']; |
128 | 128 | if (isset($import['model'])) { |
129 | 129 | list($plugin, $modelClass) = pluginSplit($import['model'], true); |
130 | - App::uses($modelClass, $plugin . 'Model'); |
|
131 | - if (!class_exists($modelClass)) { |
|
130 | + App::uses($modelClass, $plugin.'Model'); |
|
131 | + if ( ! class_exists($modelClass)) { |
|
132 | 132 | throw new MissingModelException(array('class' => $modelClass)); |
133 | 133 | } |
134 | 134 | $model = new $modelClass(null, null, $import['connection']); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | ClassRegistry::flush(); |
156 | 156 | } |
157 | 157 | |
158 | - if (!empty($db->config['prefix']) && strpos($this->table, $db->config['prefix']) === 0) { |
|
158 | + if ( ! empty($db->config['prefix']) && strpos($this->table, $db->config['prefix']) === 0) { |
|
159 | 159 | $this->table = str_replace($db->config['prefix'], '', $this->table); |
160 | 160 | } |
161 | 161 | |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | ); |
173 | 173 | $records = $db->fetchAll($db->buildStatement($query, $model), false, $model->alias); |
174 | 174 | |
175 | - if ($records !== false && !empty($records)) { |
|
176 | - $this->records = Hash::extract($records, '{n}.' . $model->alias); |
|
175 | + if ($records !== false && ! empty($records)) { |
|
176 | + $this->records = Hash::extract($records, '{n}.'.$model->alias); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - if (!isset($this->table)) { |
|
181 | + if ( ! isset($this->table)) { |
|
182 | 182 | $this->table = Inflector::underscore(Inflector::pluralize($this->name)); |
183 | 183 | } |
184 | 184 | |
185 | - if (!isset($this->primaryKey) && isset($this->fields['id'])) { |
|
185 | + if ( ! isset($this->primaryKey) && isset($this->fields['id'])) { |
|
186 | 186 | $this->primaryKey = 'id'; |
187 | 187 | } |
188 | 188 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @return boolean True on success, false on failure |
195 | 195 | */ |
196 | 196 | public function create($db) { |
197 | - if (!isset($this->fields) || empty($this->fields)) { |
|
197 | + if ( ! isset($this->fields) || empty($this->fields)) { |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | if (is_string($args)) { |
206 | 206 | $type = $args; |
207 | - } elseif (!empty($args['type'])) { |
|
207 | + } elseif ( ! empty($args['type'])) { |
|
208 | 208 | $type = $args['type']; |
209 | 209 | } else { |
210 | 210 | continue; |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | * @throws CakeException if counts of values and fields do not match. |
269 | 269 | */ |
270 | 270 | public function insert($db) { |
271 | - if (!isset($this->_insert)) { |
|
271 | + if ( ! isset($this->_insert)) { |
|
272 | 272 | $values = array(); |
273 | - if (isset($this->records) && !empty($this->records)) { |
|
273 | + if (isset($this->records) && ! empty($this->records)) { |
|
274 | 274 | $fields = array(); |
275 | 275 | foreach ($this->records as $record) { |
276 | 276 | $fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields))); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | * |
47 | 47 | * @param array $data |
48 | 48 | * @param boolean|array $validate |
49 | - * @param array $fieldList |
|
49 | + * @param string[] $fieldList |
|
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | public function save($data = null, $validate = true, $fieldList = array()) { |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function __construct($id = false, $table = null, $ds = null) { |
40 | 40 | parent::__construct($id, $table, $ds); |
41 | - $this->order = array($this->alias . '.' . $this->primaryKey => 'ASC'); |
|
41 | + $this->order = array($this->alias.'.'.$this->primaryKey => 'ASC'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -295,7 +295,6 @@ |
||
295 | 295 | /** |
296 | 296 | * Paints a PHP exception. |
297 | 297 | * |
298 | - * @param Exception $exception Exception to display. |
|
299 | 298 | * @param mixed $test |
300 | 299 | * @return void |
301 | 300 | */ |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | public function sendContentType() { |
49 | - if (!headers_sent()) { |
|
50 | - header('Content-Type: text/html; charset=' . Configure::read('App.encoding')); |
|
49 | + if ( ! headers_sent()) { |
|
50 | + header('Content-Type: text/html; charset='.Configure::read('App.encoding')); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function paintDocumentStart() { |
60 | 60 | ob_start(); |
61 | 61 | $baseDir = $this->params['baseDir']; |
62 | - include CAKE . 'TestSuite' . DS . 'templates' . DS . 'header.php'; |
|
62 | + include CAKE.'TestSuite'.DS.'templates'.DS.'header.php'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return void |
70 | 70 | */ |
71 | 71 | public function paintTestMenu() { |
72 | - $cases = $this->baseUrl() . '?show=cases'; |
|
72 | + $cases = $this->baseUrl().'?show=cases'; |
|
73 | 73 | $plugins = App::objects('plugin', null, false); |
74 | 74 | sort($plugins); |
75 | - include CAKE . 'TestSuite' . DS . 'templates' . DS . 'menu.php'; |
|
75 | + include CAKE.'TestSuite'.DS.'templates'.DS.'menu.php'; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | $buffer = "<h3>Core Test Cases:</h3>\n<ul>"; |
92 | 92 | $urlExtra = '&core=true'; |
93 | 93 | } elseif ($plugin) { |
94 | - $buffer = "<h3>" . Inflector::humanize($plugin) . " Test Cases:</h3>\n<ul>"; |
|
95 | - $urlExtra = '&plugin=' . $plugin; |
|
94 | + $buffer = "<h3>".Inflector::humanize($plugin)." Test Cases:</h3>\n<ul>"; |
|
95 | + $urlExtra = '&plugin='.$plugin; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | if (count($testCases) < 1) { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $title = explode(DS, str_replace('.test.php', '', $testCase)); |
104 | 104 | $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]); |
105 | 105 | $title = implode(' / ', $title); |
106 | - $buffer .= "<li><a href='" . $this->baseUrl() . "?case=" . urlencode($testCase) . $urlExtra . "'>" . $title . "</a></li>\n"; |
|
106 | + $buffer .= "<li><a href='".$this->baseUrl()."?case=".urlencode($testCase).$urlExtra."'>".$title."</a></li>\n"; |
|
107 | 107 | } |
108 | 108 | $buffer .= "</ul>\n"; |
109 | 109 | echo $buffer; |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * @return void |
118 | 118 | */ |
119 | 119 | public function sendNoCacheHeaders() { |
120 | - if (!headers_sent()) { |
|
120 | + if ( ! headers_sent()) { |
|
121 | 121 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
122 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
122 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
123 | 123 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
124 | 124 | header("Cache-Control: post-check=0, pre-check=0", false); |
125 | 125 | header("Pragma: no-cache"); |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | echo "<div style=\""; |
141 | 141 | echo "padding: 8px; margin: 1em 0; background-color: $colour; color: white;"; |
142 | 142 | echo "\">"; |
143 | - echo ($result->count() - $result->skippedCount()) . "/" . $result->count(); |
|
143 | + echo ($result->count() - $result->skippedCount())."/".$result->count(); |
|
144 | 144 | echo " test methods complete:\n"; |
145 | - echo "<strong>" . count($result->passed()) . "</strong> passes, "; |
|
146 | - echo "<strong>" . $result->failureCount() . "</strong> fails, "; |
|
147 | - echo "<strong>" . $this->numAssertions . "</strong> assertions and "; |
|
148 | - echo "<strong>" . $result->errorCount() . "</strong> exceptions."; |
|
145 | + echo "<strong>".count($result->passed())."</strong> passes, "; |
|
146 | + echo "<strong>".$result->failureCount()."</strong> fails, "; |
|
147 | + echo "<strong>".$this->numAssertions."</strong> assertions and "; |
|
148 | + echo "<strong>".$result->errorCount()."</strong> exceptions."; |
|
149 | 149 | echo "</div>\n"; |
150 | 150 | echo '<div style="padding:0 0 5px;">'; |
151 | - echo '<p><strong>Time:</strong> ' . $result->time() . ' seconds</p>'; |
|
152 | - echo '<p><strong>Peak memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>'; |
|
151 | + echo '<p><strong>Time:</strong> '.$result->time().' seconds</p>'; |
|
152 | + echo '<p><strong>Peak memory:</strong> '.number_format(memory_get_peak_usage()).' bytes</p>'; |
|
153 | 153 | echo $this->_paintLinks(); |
154 | 154 | echo '</div>'; |
155 | 155 | if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { |
@@ -186,25 +186,25 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function _paintLinks() { |
188 | 188 | $show = $query = array(); |
189 | - if (!empty($this->params['case'])) { |
|
189 | + if ( ! empty($this->params['case'])) { |
|
190 | 190 | $show['show'] = 'cases'; |
191 | 191 | } |
192 | 192 | |
193 | - if (!empty($this->params['core'])) { |
|
193 | + if ( ! empty($this->params['core'])) { |
|
194 | 194 | $show['core'] = $query['core'] = 'true'; |
195 | 195 | } |
196 | - if (!empty($this->params['plugin'])) { |
|
196 | + if ( ! empty($this->params['plugin'])) { |
|
197 | 197 | $show['plugin'] = $query['plugin'] = $this->params['plugin']; |
198 | 198 | } |
199 | - if (!empty($this->params['case'])) { |
|
199 | + if ( ! empty($this->params['case'])) { |
|
200 | 200 | $query['case'] = $this->params['case']; |
201 | 201 | } |
202 | 202 | $show = $this->_queryString($show); |
203 | 203 | $query = $this->_queryString($query); |
204 | 204 | |
205 | - echo "<p><a href='" . $this->baseUrl() . $show . "'>Run more tests</a> | <a href='" . $this->baseUrl() . $query . "&show_passes=1'>Show Passes</a> | \n"; |
|
206 | - echo "<a href='" . $this->baseUrl() . $query . "&debug=1'>Enable Debug Output</a> | \n"; |
|
207 | - echo "<a href='" . $this->baseUrl() . $query . "&code_coverage=true'>Analyze Code Coverage</a></p>\n"; |
|
205 | + echo "<p><a href='".$this->baseUrl().$show."'>Run more tests</a> | <a href='".$this->baseUrl().$query."&show_passes=1'>Show Passes</a> | \n"; |
|
206 | + echo "<a href='".$this->baseUrl().$query."&debug=1'>Enable Debug Output</a> | \n"; |
|
207 | + echo "<a href='".$this->baseUrl().$query."&code_coverage=true'>Analyze Code Coverage</a></p>\n"; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function paintDocumentEnd() { |
232 | 232 | $baseDir = $this->params['baseDir']; |
233 | - include CAKE . 'TestSuite' . DS . 'templates' . DS . 'footer.php'; |
|
233 | + include CAKE.'TestSuite'.DS.'templates'.DS.'footer.php'; |
|
234 | 234 | if (ob_get_length()) { |
235 | 235 | ob_end_flush(); |
236 | 236 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function paintFail($message, $test) { |
250 | 250 | $trace = $this->_getStackTrace($message); |
251 | - $testName = get_class($test) . '(' . $test->getName() . ')'; |
|
251 | + $testName = get_class($test).'('.$test->getName().')'; |
|
252 | 252 | |
253 | 253 | $actualMsg = $expectedMsg = null; |
254 | 254 | if (method_exists($message, 'getComparisonFailure')) { |
@@ -261,15 +261,15 @@ discard block |
||
261 | 261 | |
262 | 262 | echo "<li class='fail'>\n"; |
263 | 263 | echo "<span>Failed</span>"; |
264 | - echo "<div class='msg'><pre>" . $this->_htmlEntities($message->toString()); |
|
264 | + echo "<div class='msg'><pre>".$this->_htmlEntities($message->toString()); |
|
265 | 265 | |
266 | 266 | if ((is_string($actualMsg) && is_string($expectedMsg)) || (is_array($actualMsg) && is_array($expectedMsg))) { |
267 | - echo "<br />" . PHPUnit_Util_Diff::diff($expectedMsg, $actualMsg); |
|
267 | + echo "<br />".PHPUnit_Util_Diff::diff($expectedMsg, $actualMsg); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | echo "</pre></div>\n"; |
271 | - echo "<div class='msg'>" . __d('cake_dev', 'Test case: %s', $testName) . "</div>\n"; |
|
272 | - echo "<div class='msg'>" . __d('cake_dev', 'Stack trace:') . '<br />' . $trace . "</div>\n"; |
|
271 | + echo "<div class='msg'>".__d('cake_dev', 'Test case: %s', $testName)."</div>\n"; |
|
272 | + echo "<div class='msg'>".__d('cake_dev', 'Stack trace:').'<br />'.$trace."</div>\n"; |
|
273 | 273 | echo "</li>\n"; |
274 | 274 | } |
275 | 275 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | echo "<li class='pass'>\n"; |
288 | 288 | echo "<span>Passed</span> "; |
289 | 289 | |
290 | - echo "<br />" . $this->_htmlEntities($test->getName()) . " ($time seconds)\n"; |
|
290 | + echo "<br />".$this->_htmlEntities($test->getName())." ($time seconds)\n"; |
|
291 | 291 | echo "</li>\n"; |
292 | 292 | } |
293 | 293 | } |
@@ -301,14 +301,14 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function paintException($message, $test) { |
303 | 303 | $trace = $this->_getStackTrace($message); |
304 | - $testName = get_class($test) . '(' . $test->getName() . ')'; |
|
304 | + $testName = get_class($test).'('.$test->getName().')'; |
|
305 | 305 | |
306 | 306 | echo "<li class='fail'>\n"; |
307 | - echo "<span>" . get_class($message) . "</span>"; |
|
307 | + echo "<span>".get_class($message)."</span>"; |
|
308 | 308 | |
309 | - echo "<div class='msg'>" . $this->_htmlEntities($message->getMessage()) . "</div>\n"; |
|
310 | - echo "<div class='msg'>" . __d('cake_dev', 'Test case: %s', $testName) . "</div>\n"; |
|
311 | - echo "<div class='msg'>" . __d('cake_dev', 'Stack trace:') . '<br />' . $trace . "</div>\n"; |
|
309 | + echo "<div class='msg'>".$this->_htmlEntities($message->getMessage())."</div>\n"; |
|
310 | + echo "<div class='msg'>".__d('cake_dev', 'Test case: %s', $testName)."</div>\n"; |
|
311 | + echo "<div class='msg'>".__d('cake_dev', 'Stack trace:').'<br />'.$trace."</div>\n"; |
|
312 | 312 | echo "</li>\n"; |
313 | 313 | } |
314 | 314 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | public function paintSkip($message, $test) { |
323 | 323 | echo "<li class='skipped'>\n"; |
324 | 324 | echo "<span>Skipped</span> "; |
325 | - echo $test->getName() . ': ' . $this->_htmlEntities($message->getMessage()); |
|
325 | + echo $test->getName().': '.$this->_htmlEntities($message->getMessage()); |
|
326 | 326 | echo "</li>\n"; |
327 | 327 | } |
328 | 328 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return void |
334 | 334 | */ |
335 | 335 | public function paintFormattedMessage($message) { |
336 | - echo '<pre>' . $this->_htmlEntities($message) . '</pre>'; |
|
336 | + echo '<pre>'.$this->_htmlEntities($message).'</pre>'; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | $out = array(); |
358 | 358 | foreach ($trace as $frame) { |
359 | 359 | if (isset($frame['file']) && isset($frame['line'])) { |
360 | - $out[] = $frame['file'] . ' : ' . $frame['line']; |
|
360 | + $out[] = $frame['file'].' : '.$frame['line']; |
|
361 | 361 | } elseif (isset($frame['class']) && isset($frame['function'])) { |
362 | - $out[] = $frame['class'] . '::' . $frame['function']; |
|
362 | + $out[] = $frame['class'].'::'.$frame['function']; |
|
363 | 363 | } else { |
364 | 364 | $out[] = '[internal]'; |
365 | 365 | } |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | * @return void |
375 | 375 | */ |
376 | 376 | public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { |
377 | - if (!$this->_headerSent) { |
|
377 | + if ( ! $this->_headerSent) { |
|
378 | 378 | echo $this->paintHeader(); |
379 | 379 | } |
380 | - echo '<h2>' . __d('cake_dev', 'Running %s', $suite->getName()) . '</h2>'; |
|
380 | + echo '<h2>'.__d('cake_dev', 'Running %s', $suite->getName()).'</h2>'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | } |
@@ -97,7 +97,7 @@ |
||
97 | 97 | * |
98 | 98 | * @param float $value A floating point number. |
99 | 99 | * @param integer $precision The precision of the returned number. |
100 | - * @return float Formatted float. |
|
100 | + * @return string Formatted float. |
|
101 | 101 | * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::precision |
102 | 102 | */ |
103 | 103 | public static function precision($value, $precision = 3) { |
@@ -1,22 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * CakeNumber Utility. |
|
4 | - * |
|
5 | - * Methods to make numbers more readable. |
|
6 | - * |
|
7 | - * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
|
8 | - * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
9 | - * |
|
10 | - * Licensed under The MIT License |
|
11 | - * For full copyright and license information, please see the LICENSE.txt |
|
12 | - * Redistributions of files must retain the above copyright notice. |
|
13 | - * |
|
14 | - * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
15 | - * @link http://cakephp.org CakePHP(tm) Project |
|
16 | - * @package Cake.Utility |
|
17 | - * @since CakePHP(tm) v 0.10.0.1076 |
|
18 | - * @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
19 | - */ |
|
3 | + * CakeNumber Utility. |
|
4 | + * |
|
5 | + * Methods to make numbers more readable. |
|
6 | + * |
|
7 | + * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) |
|
8 | + * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
9 | + * |
|
10 | + * Licensed under The MIT License |
|
11 | + * For full copyright and license information, please see the LICENSE.txt |
|
12 | + * Redistributions of files must retain the above copyright notice. |
|
13 | + * |
|
14 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) |
|
15 | + * @link http://cakephp.org CakePHP(tm) Project |
|
16 | + * @package Cake.Utility |
|
17 | + * @since CakePHP(tm) v 0.10.0.1076 |
|
18 | + * @license http://www.opensource.org/licenses/mit-license.php MIT License |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Number helper library. |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function fromReadableSize($size, $default = false) { |
139 | 139 | if (ctype_digit($size)) { |
140 | - return (int)$size; |
|
140 | + return (int) $size; |
|
141 | 141 | } |
142 | 142 | $size = strtoupper($size); |
143 | 143 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | if (substr($size, -1) === 'B' && ctype_digit(substr($size, 0, -1))) { |
156 | 156 | $size = substr($size, 0, -1); |
157 | - return (int)$size; |
|
157 | + return (int) $size; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | if ($default !== false) { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if ($options['multiply']) { |
182 | 182 | $value *= 100; |
183 | 183 | } |
184 | - return self::precision($value, $precision) . '%'; |
|
184 | + return self::precision($value, $precision).'%'; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -202,15 +202,15 @@ discard block |
||
202 | 202 | $separators = array(',', '.', '-', ':'); |
203 | 203 | |
204 | 204 | $before = $after = null; |
205 | - if (is_string($options) && !in_array($options, $separators)) { |
|
205 | + if (is_string($options) && ! in_array($options, $separators)) { |
|
206 | 206 | $before = $options; |
207 | 207 | } |
208 | 208 | $thousands = ','; |
209 | - if (!is_array($options) && in_array($options, $separators)) { |
|
209 | + if ( ! is_array($options) && in_array($options, $separators)) { |
|
210 | 210 | $thousands = $options; |
211 | 211 | } |
212 | 212 | $decimals = '.'; |
213 | - if (!is_array($options) && in_array($options, $separators)) { |
|
213 | + if ( ! is_array($options) && in_array($options, $separators)) { |
|
214 | 214 | $decimals = $options; |
215 | 215 | } |
216 | 216 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | $value = self::_numberFormat($value, $places, '.', ''); |
225 | - $out = $before . self::_numberFormat($value, $places, $decimals, $thousands) . $after; |
|
225 | + $out = $before.self::_numberFormat($value, $places, $decimals, $thousands).$after; |
|
226 | 226 | |
227 | 227 | if ($escape) { |
228 | 228 | return h($out); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $places = isset($options['places']) ? $options['places'] : 0; |
252 | 252 | $value = self::_numberFormat($value, $places, '.', ''); |
253 | 253 | $sign = $value > 0 ? '+' : ''; |
254 | - $options['before'] = isset($options['before']) ? $options['before'] . $sign : $sign; |
|
254 | + $options['before'] = isset($options['before']) ? $options['before'].$sign : $sign; |
|
255 | 255 | return self::format($value, $options); |
256 | 256 | } |
257 | 257 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @return string |
266 | 266 | */ |
267 | 267 | protected static function _numberFormat($value, $places = 0, $decimals = '.', $thousands = ',') { |
268 | - if (!isset(self::$_numberFormatSupport)) { |
|
268 | + if ( ! isset(self::$_numberFormatSupport)) { |
|
269 | 269 | self::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>='); |
270 | 270 | } |
271 | 271 | if (self::$_numberFormatSupport) { |
@@ -339,15 +339,15 @@ discard block |
||
339 | 339 | if (isset($options['before']) && $options['before'] !== '') { |
340 | 340 | $options['wholeSymbol'] = $options['before']; |
341 | 341 | } |
342 | - if (isset($options['after']) && !$options['after'] !== '') { |
|
342 | + if (isset($options['after']) && ! $options['after'] !== '') { |
|
343 | 343 | $options['fractionSymbol'] = $options['after']; |
344 | 344 | } |
345 | 345 | |
346 | 346 | $result = $options['before'] = $options['after'] = null; |
347 | 347 | |
348 | 348 | $symbolKey = 'whole'; |
349 | - $value = (float)$value; |
|
350 | - if (!$value) { |
|
349 | + $value = (float) $value; |
|
350 | + if ( ! $value) { |
|
351 | 351 | if ($options['zero'] !== 0) { |
352 | 352 | return $options['zero']; |
353 | 353 | } |
@@ -360,17 +360,17 @@ discard block |
||
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | - $position = $options[$symbolKey . 'Position'] !== 'after' ? 'before' : 'after'; |
|
364 | - $options[$position] = $options[$symbolKey . 'Symbol']; |
|
363 | + $position = $options[$symbolKey.'Position'] !== 'after' ? 'before' : 'after'; |
|
364 | + $options[$position] = $options[$symbolKey.'Symbol']; |
|
365 | 365 | |
366 | 366 | $abs = abs($value); |
367 | 367 | $result = self::format($abs, $options); |
368 | 368 | |
369 | 369 | if ($value < 0) { |
370 | 370 | if ($options['negative'] === '()') { |
371 | - $result = '(' . $result . ')'; |
|
371 | + $result = '('.$result.')'; |
|
372 | 372 | } else { |
373 | - $result = $options['negative'] . $result; |
|
373 | + $result = $options['negative'].$result; |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | return $result; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | /** |
296 | 296 | * Returns server's offset from GMT in seconds. |
297 | 297 | * |
298 | - * @return integer Offset |
|
298 | + * @return string Offset |
|
299 | 299 | * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::serverOffset |
300 | 300 | */ |
301 | 301 | public static function serverOffset() { |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object |
624 | 624 | * @param string|DateTimeZone $timezone Timezone string or DateTimeZone object |
625 | 625 | * @param string $format date format string |
626 | - * @return mixed Formatted date |
|
626 | + * @return false|string Formatted date |
|
627 | 627 | * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toServer |
628 | 628 | */ |
629 | 629 | public static function toServer($dateString, $timezone = null, $format = 'Y-m-d H:i:s') { |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | /** |
940 | 940 | * Returns true if specified datetime was within the interval specified, else false. |
941 | 941 | * |
942 | - * @param string|integer $timeInterval the numeric value with space then time type. |
|
942 | + * @param string $timeInterval the numeric value with space then time type. |
|
943 | 943 | * Example of valid types: 6 hours, 2 days, 1 minute. |
944 | 944 | * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object |
945 | 945 | * @param string|DateTimeZone $timezone Timezone string or DateTimeZone object |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | /** |
963 | 963 | * Returns true if specified datetime is within the interval specified, else false. |
964 | 964 | * |
965 | - * @param string|integer $timeInterval the numeric value with space then time type. |
|
965 | + * @param string $timeInterval the numeric value with space then time type. |
|
966 | 966 | * Example of valid types: 6 hours, 2 days, 1 minute. |
967 | 967 | * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object |
968 | 968 | * @param string|DateTimeZone $timezone Timezone string or DateTimeZone object |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | * CakeTime::format('2012-02-15 23:01:01', '%c', 'N/A', 'America/New_York'); // converts passed date to timezone |
1020 | 1020 | * }}} |
1021 | 1021 | * |
1022 | - * @param integer|string|DateTime $date UNIX timestamp, strtotime() valid string or DateTime object (or a date format string) |
|
1022 | + * @param string $date UNIX timestamp, strtotime() valid string or DateTime object (or a date format string) |
|
1023 | 1023 | * @param integer|string|DateTime $format date format string (or UNIX timestamp, strtotime() valid string or DateTime object) |
1024 | 1024 | * @param boolean|string $default if an invalid date is passed it will output supplied default value. Pass false if you want raw conversion value |
1025 | 1025 | * @param string|DateTimeZone $timezone Timezone string or DateTimeZone object |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::convertSpecifiers |
133 | 133 | */ |
134 | 134 | public static function convertSpecifiers($format, $time = null) { |
135 | - if (!$time) { |
|
135 | + if ( ! $time) { |
|
136 | 136 | $time = time(); |
137 | 137 | } |
138 | 138 | self::$_time = $time; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | $day = date('j', self::$_time); |
178 | 178 | if ($day < 10) { |
179 | - $day = ' ' . $day; |
|
179 | + $day = ' '.$day; |
|
180 | 180 | } |
181 | 181 | return $day; |
182 | 182 | case 'eS' : |
@@ -249,16 +249,16 @@ discard block |
||
249 | 249 | if ($serverTimezone === null || (date_default_timezone_get() !== $serverTimezone->getName())) { |
250 | 250 | $serverTimezone = new DateTimeZone(date_default_timezone_get()); |
251 | 251 | } |
252 | - $serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime)); |
|
252 | + $serverOffset = $serverTimezone->getOffset(new DateTime('@'.$serverTime)); |
|
253 | 253 | $gmtTime = $serverTime - $serverOffset; |
254 | 254 | if (is_numeric($timezone)) { |
255 | 255 | $userOffset = $timezone * (60 * 60); |
256 | 256 | } else { |
257 | 257 | $timezone = self::timezone($timezone); |
258 | - $userOffset = $timezone->getOffset(new DateTime('@' . $gmtTime)); |
|
258 | + $userOffset = $timezone->getOffset(new DateTime('@'.$gmtTime)); |
|
259 | 259 | } |
260 | 260 | $userTime = $gmtTime + $userOffset; |
261 | - return (int)$userTime; |
|
261 | + return (int) $userTime; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | ) { |
329 | 329 | $clone = clone $dateString; |
330 | 330 | $clone->setTimezone(new DateTimeZone(date_default_timezone_get())); |
331 | - $date = (int)$clone->format('U') + $clone->getOffset(); |
|
331 | + $date = (int) $clone->format('U') + $clone->getOffset(); |
|
332 | 332 | } elseif ($dateString instanceof DateTime) { |
333 | - $date = (int)$dateString->format('U'); |
|
333 | + $date = (int) $dateString->format('U'); |
|
334 | 334 | } else { |
335 | 335 | $date = strtotime($dateString); |
336 | 336 | } |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::nice |
363 | 363 | */ |
364 | 364 | public static function nice($dateString = null, $timezone = null, $format = null) { |
365 | - if (!$dateString) { |
|
365 | + if ( ! $dateString) { |
|
366 | 366 | $dateString = time(); |
367 | 367 | } |
368 | 368 | $date = self::fromString($dateString, $timezone); |
369 | 369 | |
370 | - if (!$format) { |
|
370 | + if ( ! $format) { |
|
371 | 371 | $format = self::$niceFormat; |
372 | 372 | } |
373 | 373 | return self::_strftime(self::convertSpecifiers($format, $date), $date); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::niceShort |
390 | 390 | */ |
391 | 391 | public static function niceShort($dateString = null, $timezone = null) { |
392 | - if (!$dateString) { |
|
392 | + if ( ! $dateString) { |
|
393 | 393 | $dateString = time(); |
394 | 394 | } |
395 | 395 | $date = self::fromString($dateString, $timezone); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | $y = ''; |
425 | - if (!self::isThisYear($date)) { |
|
425 | + if ( ! self::isThisYear($date)) { |
|
426 | 426 | $y = ' %Y'; |
427 | 427 | } |
428 | 428 | return self::_strftime(self::convertSpecifiers("%b %eS{$y}, %H:%M", $date), $date); |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | public static function daysAsSql($begin, $end, $fieldName, $timezone = null) { |
442 | 442 | $begin = self::fromString($begin, $timezone); |
443 | 443 | $end = self::fromString($end, $timezone); |
444 | - $begin = date('Y-m-d', $begin) . ' 00:00:00'; |
|
445 | - $end = date('Y-m-d', $end) . ' 23:59:59'; |
|
444 | + $begin = date('Y-m-d', $begin).' 00:00:00'; |
|
445 | + $end = date('Y-m-d', $end).' 23:59:59'; |
|
446 | 446 | |
447 | 447 | return "($fieldName >= '$begin') AND ($fieldName <= '$end')"; |
448 | 448 | } |
@@ -589,13 +589,13 @@ discard block |
||
589 | 589 | $year = date('Y', $time); |
590 | 590 | switch ($date) { |
591 | 591 | case 1: |
592 | - return array($year . '-01-01', $year . '-03-31'); |
|
592 | + return array($year.'-01-01', $year.'-03-31'); |
|
593 | 593 | case 2: |
594 | - return array($year . '-04-01', $year . '-06-30'); |
|
594 | + return array($year.'-04-01', $year.'-06-30'); |
|
595 | 595 | case 3: |
596 | - return array($year . '-07-01', $year . '-09-30'); |
|
596 | + return array($year.'-07-01', $year.'-09-30'); |
|
597 | 597 | case 4: |
598 | - return array($year . '-10-01', $year . '-12-31'); |
|
598 | + return array($year.'-10-01', $year.'-12-31'); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
@@ -631,16 +631,16 @@ discard block |
||
631 | 631 | $timezone = new DateTimeZone('UTC'); |
632 | 632 | } elseif (is_string($timezone)) { |
633 | 633 | $timezone = new DateTimeZone($timezone); |
634 | - } elseif (!($timezone instanceof DateTimeZone)) { |
|
634 | + } elseif ( ! ($timezone instanceof DateTimeZone)) { |
|
635 | 635 | return false; |
636 | 636 | } |
637 | 637 | |
638 | 638 | if ($dateString instanceof DateTime) { |
639 | 639 | $date = $dateString; |
640 | 640 | } elseif (is_int($dateString) || is_numeric($dateString)) { |
641 | - $dateString = (int)$dateString; |
|
641 | + $dateString = (int) $dateString; |
|
642 | 642 | |
643 | - $date = new DateTime('@' . $dateString); |
|
643 | + $date = new DateTime('@'.$dateString); |
|
644 | 644 | $date->setTimezone($timezone); |
645 | 645 | } else { |
646 | 646 | $date = new DateTime($dateString, $timezone); |
@@ -678,22 +678,22 @@ discard block |
||
678 | 678 | } |
679 | 679 | |
680 | 680 | $userOffset = $timezone; |
681 | - if (!is_numeric($timezone)) { |
|
682 | - if (!is_object($timezone)) { |
|
681 | + if ( ! is_numeric($timezone)) { |
|
682 | + if ( ! is_object($timezone)) { |
|
683 | 683 | $timezone = new DateTimeZone($timezone); |
684 | 684 | } |
685 | - $currentDate = new DateTime('@' . $date); |
|
685 | + $currentDate = new DateTime('@'.$date); |
|
686 | 686 | $currentDate->setTimezone($timezone); |
687 | 687 | $userOffset = $timezone->getOffset($currentDate) / 60 / 60; |
688 | 688 | } |
689 | 689 | |
690 | 690 | $timezone = '+0000'; |
691 | 691 | if ($userOffset != 0) { |
692 | - $hours = (int)floor(abs($userOffset)); |
|
693 | - $minutes = (int)(fmod(abs($userOffset), $hours) * 60); |
|
694 | - $timezone = ($userOffset < 0 ? '-' : '+') . str_pad($hours, 2, '0', STR_PAD_LEFT) . str_pad($minutes, 2, '0', STR_PAD_LEFT); |
|
692 | + $hours = (int) floor(abs($userOffset)); |
|
693 | + $minutes = (int) (fmod(abs($userOffset), $hours) * 60); |
|
694 | + $timezone = ($userOffset < 0 ? '-' : '+').str_pad($hours, 2, '0', STR_PAD_LEFT).str_pad($minutes, 2, '0', STR_PAD_LEFT); |
|
695 | 695 | } |
696 | - return date('D, d M Y H:i:s', $date) . ' ' . $timezone; |
|
696 | + return date('D, d M Y H:i:s', $date).' '.$timezone; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | } |
792 | 792 | $diff = $futureTime - $pastTime; |
793 | 793 | |
794 | - if (!$diff) { |
|
794 | + if ( ! $diff) { |
|
795 | 795 | return __d('cake', 'just now', 'just now'); |
796 | 796 | } |
797 | 797 | |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | $daysInPastMonth = date('t', $pastTime); |
824 | 824 | $daysInFutureMonth = date('t', mktime(0, 0, 0, $future['m'] - 1, 1, $future['Y'])); |
825 | 825 | |
826 | - if (!$backwards) { |
|
826 | + if ( ! $backwards) { |
|
827 | 827 | $days = ($daysInPastMonth - $past['d']) + $future['d']; |
828 | 828 | } else { |
829 | 829 | $days = ($daysInFutureMonth - $past['d']) + $future['d']; |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | } |
835 | 835 | } |
836 | 836 | |
837 | - if (!$months && $years >= 1 && $diff < ($years * 31536000)) { |
|
837 | + if ( ! $months && $years >= 1 && $diff < ($years * 31536000)) { |
|
838 | 838 | $months = 11; |
839 | 839 | $years--; |
840 | 840 | } |
@@ -881,32 +881,32 @@ discard block |
||
881 | 881 | |
882 | 882 | $relativeDate = ''; |
883 | 883 | if ($fNum >= 1 && $years > 0) { |
884 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d year', '%d years', $years, $years); |
|
884 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d year', '%d years', $years, $years); |
|
885 | 885 | } |
886 | 886 | if ($fNum >= 2 && $months > 0) { |
887 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d month', '%d months', $months, $months); |
|
887 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d month', '%d months', $months, $months); |
|
888 | 888 | } |
889 | 889 | if ($fNum >= 3 && $weeks > 0) { |
890 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks); |
|
890 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d week', '%d weeks', $weeks, $weeks); |
|
891 | 891 | } |
892 | 892 | if ($fNum >= 4 && $days > 0) { |
893 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days); |
|
893 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d day', '%d days', $days, $days); |
|
894 | 894 | } |
895 | 895 | if ($fNum >= 5 && $hours > 0) { |
896 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d hour', '%d hours', $hours, $hours); |
|
896 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d hour', '%d hours', $hours, $hours); |
|
897 | 897 | } |
898 | 898 | if ($fNum >= 6 && $minutes > 0) { |
899 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d minute', '%d minutes', $minutes, $minutes); |
|
899 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d minute', '%d minutes', $minutes, $minutes); |
|
900 | 900 | } |
901 | 901 | if ($fNum >= 7 && $seconds > 0) { |
902 | - $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d second', '%d seconds', $seconds, $seconds); |
|
902 | + $relativeDate .= ($relativeDate ? ', ' : '').__dn('cake', '%d second', '%d seconds', $seconds, $seconds); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | // When time has passed |
906 | - if (!$backwards && $relativeDate) { |
|
906 | + if ( ! $backwards && $relativeDate) { |
|
907 | 907 | return sprintf($relativeString, $relativeDate); |
908 | 908 | } |
909 | - if (!$backwards) { |
|
909 | + if ( ! $backwards) { |
|
910 | 910 | $aboutAgo = array( |
911 | 911 | 'second' => __d('cake', 'about a second ago'), |
912 | 912 | 'minute' => __d('cake', 'about a minute ago'), |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | } |
921 | 921 | |
922 | 922 | // When time is to come |
923 | - if (!$relativeDate) { |
|
923 | + if ( ! $relativeDate) { |
|
924 | 924 | $aboutIn = array( |
925 | 925 | 'second' => __d('cake', 'in about a second'), |
926 | 926 | 'minute' => __d('cake', 'in about a minute'), |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | public static function wasWithinLast($timeInterval, $dateString, $timezone = null) { |
950 | 950 | $tmp = str_replace(' ', '', $timeInterval); |
951 | 951 | if (is_numeric($tmp)) { |
952 | - $timeInterval = $tmp . ' ' . __d('cake', 'days'); |
|
952 | + $timeInterval = $tmp.' '.__d('cake', 'days'); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | $date = self::fromString($dateString, $timezone); |
956 | - $interval = self::fromString('-' . $timeInterval); |
|
956 | + $interval = self::fromString('-'.$timeInterval); |
|
957 | 957 | $now = self::fromString('now', $timezone); |
958 | 958 | |
959 | 959 | return $date >= $interval && $date <= $now; |
@@ -971,11 +971,11 @@ discard block |
||
971 | 971 | public static function isWithinNext($timeInterval, $dateString, $timezone = null) { |
972 | 972 | $tmp = str_replace(' ', '', $timeInterval); |
973 | 973 | if (is_numeric($tmp)) { |
974 | - $timeInterval = $tmp . ' ' . __d('cake', 'days'); |
|
974 | + $timeInterval = $tmp.' '.__d('cake', 'days'); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | $date = self::fromString($dateString, $timezone); |
978 | - $interval = self::fromString('+' . $timeInterval); |
|
978 | + $interval = self::fromString('+'.$timeInterval); |
|
979 | 979 | $now = self::fromString('now', $timezone); |
980 | 980 | |
981 | 981 | return $date <= $interval && $date >= $now; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | |
1092 | 1092 | if ($regex) { |
1093 | 1093 | foreach ($identifiers as $key => $tz) { |
1094 | - if (!preg_match($regex, $tz)) { |
|
1094 | + if ( ! preg_match($regex, $tz)) { |
|
1095 | 1095 | unset($identifiers[$key]); |
1096 | 1096 | } |
1097 | 1097 | } |
@@ -1125,13 +1125,13 @@ discard block |
||
1125 | 1125 | $format = strftime($format, $date); |
1126 | 1126 | $encoding = Configure::read('App.encoding'); |
1127 | 1127 | |
1128 | - if (!empty($encoding) && $encoding === 'UTF-8') { |
|
1128 | + if ( ! empty($encoding) && $encoding === 'UTF-8') { |
|
1129 | 1129 | if (function_exists('mb_check_encoding')) { |
1130 | 1130 | $valid = mb_check_encoding($format, $encoding); |
1131 | 1131 | } else { |
1132 | - $valid = !Multibyte::checkMultibyte($format); |
|
1132 | + $valid = ! Multibyte::checkMultibyte($format); |
|
1133 | 1133 | } |
1134 | - if (!$valid) { |
|
1134 | + if ( ! $valid) { |
|
1135 | 1135 | $format = utf8_encode($format); |
1136 | 1136 | } |
1137 | 1137 | } |
@@ -199,7 +199,7 @@ |
||
199 | 199 | * @param string $file File on which error occurred |
200 | 200 | * @param integer $line Line that triggered the error |
201 | 201 | * @param array $context Context |
202 | - * @return boolean true if error was handled |
|
202 | + * @return null|boolean true if error was handled |
|
203 | 203 | * @deprecated Will be removed in 3.0. This function is superseded by Debugger::outputError(). |
204 | 204 | */ |
205 | 205 | public static function showError($code, $description, $file = null, $line = null, $context = null) { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if (empty($docRef) && function_exists('ini_set')) { |
100 | 100 | ini_set('docref_root', 'http://php.net/'); |
101 | 101 | } |
102 | - if (!defined('E_RECOVERABLE_ERROR')) { |
|
102 | + if ( ! defined('E_RECOVERABLE_ERROR')) { |
|
103 | 103 | define('E_RECOVERABLE_ERROR', 4096); |
104 | 104 | } |
105 | 105 | |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public static function getInstance($class = null) { |
155 | 155 | static $instance = array(); |
156 | - if (!empty($class)) { |
|
157 | - if (!$instance || strtolower($class) != strtolower(get_class($instance[0]))) { |
|
156 | + if ( ! empty($class)) { |
|
157 | + if ( ! $instance || strtolower($class) != strtolower(get_class($instance[0]))) { |
|
158 | 158 | $instance[0] = new $class(); |
159 | 159 | } |
160 | 160 | } |
161 | - if (!$instance) { |
|
161 | + if ( ! $instance) { |
|
162 | 162 | $instance[0] = new Debugger(); |
163 | 163 | } |
164 | 164 | return $instance[0]; |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::log |
188 | 188 | */ |
189 | 189 | public static function log($var, $level = LOG_DEBUG) { |
190 | - $source = self::trace(array('start' => 1)) . "\n"; |
|
191 | - CakeLog::write($level, "\n" . $source . self::exportVar($var)); |
|
190 | + $source = self::trace(array('start' => 1))."\n"; |
|
191 | + CakeLog::write($level, "\n".$source.self::exportVar($var)); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | $info = compact('code', 'description', 'file', 'line'); |
216 | - if (!in_array($info, $self->errors)) { |
|
216 | + if ( ! in_array($info, $self->errors)) { |
|
217 | 217 | $self->errors[] = $info; |
218 | 218 | } else { |
219 | 219 | return; |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | $next = array_merge($_trace, $backtrace[$i + 1]); |
308 | 308 | $signature = $reference = $next['function']; |
309 | 309 | |
310 | - if (!empty($next['class'])) { |
|
311 | - $signature = $next['class'] . '::' . $next['function']; |
|
312 | - $reference = $signature . '('; |
|
310 | + if ( ! empty($next['class'])) { |
|
311 | + $signature = $next['class'].'::'.$next['function']; |
|
312 | + $reference = $signature.'('; |
|
313 | 313 | if ($options['args'] && isset($next['args'])) { |
314 | 314 | $args = array(); |
315 | 315 | foreach ($next['args'] as $arg) { |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | * @return string Normalized path |
355 | 355 | */ |
356 | 356 | public static function trimPath($path) { |
357 | - if (!defined('CAKE_CORE_INCLUDE_PATH') || !defined('APP')) { |
|
357 | + if ( ! defined('CAKE_CORE_INCLUDE_PATH') || ! defined('APP')) { |
|
358 | 358 | return $path; |
359 | 359 | } |
360 | 360 | |
361 | 361 | if (strpos($path, APP) === 0) { |
362 | - return str_replace(APP, 'APP' . DS, $path); |
|
362 | + return str_replace(APP, 'APP'.DS, $path); |
|
363 | 363 | } elseif (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) { |
364 | 364 | return str_replace(CAKE_CORE_INCLUDE_PATH, 'CORE', $path); |
365 | 365 | } elseif (strpos($path, ROOT) === 0) { |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public static function excerpt($file, $line, $context = 2) { |
392 | 392 | $lines = array(); |
393 | - if (!file_exists($file)) { |
|
393 | + if ( ! file_exists($file)) { |
|
394 | 394 | return array(); |
395 | 395 | } |
396 | 396 | $data = file_get_contents($file); |
@@ -400,16 +400,16 @@ discard block |
||
400 | 400 | if (strpos($data, "\n") !== false) { |
401 | 401 | $data = explode("\n", $data); |
402 | 402 | } |
403 | - if (!isset($data[$line])) { |
|
403 | + if ( ! isset($data[$line])) { |
|
404 | 404 | return $lines; |
405 | 405 | } |
406 | 406 | for ($i = $line - ($context + 1); $i < $line + $context; $i++) { |
407 | - if (!isset($data[$i])) { |
|
407 | + if ( ! isset($data[$i])) { |
|
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | $string = str_replace(array("\r\n", "\n"), "", self::_highlight($data[$i])); |
411 | 411 | if ($i == $line) { |
412 | - $lines[] = '<span class="code-highlight">' . $string . '</span>'; |
|
412 | + $lines[] = '<span class="code-highlight">'.$string.'</span>'; |
|
413 | 413 | } else { |
414 | 414 | $lines[] = $string; |
415 | 415 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $added = false; |
432 | 432 | if (strpos($str, '<?php') === false) { |
433 | 433 | $added = true; |
434 | - $str = "<?php \n" . $str; |
|
434 | + $str = "<?php \n".$str; |
|
435 | 435 | } |
436 | 436 | $highlight = highlight_string($str, true); |
437 | 437 | if ($added) { |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | case 'boolean': |
484 | 484 | return ($var) ? 'true' : 'false'; |
485 | 485 | case 'integer': |
486 | - return '(int) ' . $var; |
|
486 | + return '(int) '.$var; |
|
487 | 487 | case 'float': |
488 | - return '(float) ' . $var; |
|
488 | + return '(float) '.$var; |
|
489 | 489 | case 'string': |
490 | 490 | if (trim($var) === '') { |
491 | 491 | return "''"; |
492 | 492 | } |
493 | - return "'" . $var . "'"; |
|
493 | + return "'".$var."'"; |
|
494 | 494 | case 'array': |
495 | 495 | return self::_array($var, $depth - 1, $indent + 1); |
496 | 496 | case 'resource': |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | |
538 | 538 | $out = "array("; |
539 | 539 | $break = $end = null; |
540 | - if (!empty($var)) { |
|
541 | - $break = "\n" . str_repeat("\t", $indent); |
|
542 | - $end = "\n" . str_repeat("\t", $indent - 1); |
|
540 | + if ( ! empty($var)) { |
|
541 | + $break = "\n".str_repeat("\t", $indent); |
|
542 | + $end = "\n".str_repeat("\t", $indent - 1); |
|
543 | 543 | } |
544 | 544 | $vars = array(); |
545 | 545 | |
@@ -551,14 +551,14 @@ discard block |
||
551 | 551 | } elseif ($val !== $var) { |
552 | 552 | $val = self::_export($val, $depth, $indent); |
553 | 553 | } |
554 | - $vars[] = $break . self::exportVar($key) . |
|
555 | - ' => ' . |
|
554 | + $vars[] = $break.self::exportVar($key). |
|
555 | + ' => '. |
|
556 | 556 | $val; |
557 | 557 | } |
558 | 558 | } else { |
559 | - $vars[] = $break . '[maximum depth reached]'; |
|
559 | + $vars[] = $break.'[maximum depth reached]'; |
|
560 | 560 | } |
561 | - return $out . implode(',', $vars) . $end . ')'; |
|
561 | + return $out.implode(',', $vars).$end.')'; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -575,15 +575,15 @@ discard block |
||
575 | 575 | $props = array(); |
576 | 576 | |
577 | 577 | $className = get_class($var); |
578 | - $out .= 'object(' . $className . ') {'; |
|
578 | + $out .= 'object('.$className.') {'; |
|
579 | 579 | |
580 | 580 | if ($depth > 0) { |
581 | - $end = "\n" . str_repeat("\t", $indent - 1); |
|
582 | - $break = "\n" . str_repeat("\t", $indent); |
|
581 | + $end = "\n".str_repeat("\t", $indent - 1); |
|
582 | + $break = "\n".str_repeat("\t", $indent); |
|
583 | 583 | $objectVars = get_object_vars($var); |
584 | 584 | foreach ($objectVars as $key => $value) { |
585 | 585 | $value = self::_export($value, $depth - 1, $indent); |
586 | - $props[] = "$key => " . $value; |
|
586 | + $props[] = "$key => ".$value; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | - $out .= $break . implode($break, $props) . $end; |
|
609 | + $out .= $break.implode($break, $props).$end; |
|
610 | 610 | } |
611 | 611 | $out .= '}'; |
612 | 612 | return $out; |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | if ($format === null) { |
626 | 626 | return $self->_outputFormat; |
627 | 627 | } |
628 | - if ($format !== false && !isset($self->_templates[$format])) { |
|
628 | + if ($format !== false && ! isset($self->_templates[$format])) { |
|
629 | 629 | throw new CakeException(__d('cake_dev', 'Invalid Debugger output format.')); |
630 | 630 | } |
631 | 631 | $self->_outputFormat = $format; |
@@ -706,11 +706,11 @@ discard block |
||
706 | 706 | return Debugger::outputAs(); |
707 | 707 | } |
708 | 708 | |
709 | - if (!empty($strings)) { |
|
709 | + if ( ! empty($strings)) { |
|
710 | 710 | return Debugger::addFormat($format, $strings); |
711 | 711 | } |
712 | 712 | |
713 | - if ($format === true && !empty($self->_data)) { |
|
713 | + if ($format === true && ! empty($self->_data)) { |
|
714 | 714 | $data = $self->_data; |
715 | 715 | $self->_data = array(); |
716 | 716 | $format = false; |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | $links = array(); |
756 | 756 | $info = ''; |
757 | 757 | |
758 | - foreach ((array)$data['context'] as $var => $value) { |
|
759 | - $context[] = "\${$var} = " . $this->exportVar($value, 3); |
|
758 | + foreach ((array) $data['context'] as $var => $value) { |
|
759 | + $context[] = "\${$var} = ".$this->exportVar($value, 3); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | switch ($this->_outputFormat) { |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | } |
770 | 770 | |
771 | 771 | $data['trace'] = $trace; |
772 | - $data['id'] = 'cakeErr' . uniqid(); |
|
772 | + $data['id'] = 'cakeErr'.uniqid(); |
|
773 | 773 | $tpl = array_merge($this->_templates['base'], $this->_templates[$this->_outputFormat]); |
774 | 774 | |
775 | 775 | if (isset($tpl['links'])) { |
@@ -778,13 +778,13 @@ discard block |
||
778 | 778 | } |
779 | 779 | } |
780 | 780 | |
781 | - if (!empty($tpl['escapeContext'])) { |
|
781 | + if ( ! empty($tpl['escapeContext'])) { |
|
782 | 782 | $context = h($context); |
783 | 783 | } |
784 | 784 | |
785 | 785 | $infoData = compact('code', 'context', 'trace'); |
786 | 786 | foreach ($infoData as $key => $value) { |
787 | - if (empty($value) || !isset($tpl[$key])) { |
|
787 | + if (empty($value) || ! isset($tpl[$key])) { |
|
788 | 788 | continue; |
789 | 789 | } |
790 | 790 | if (is_array($value)) { |